2010-01-25 08:59:44 -05:00
|
|
|
{
|
|
|
|
This file is part of the Mufasa Macro Library (MML)
|
|
|
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
|
|
|
|
|
|
|
MML is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
MML is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with MML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
See the file COPYING, included in this distribution,
|
|
|
|
for details about the copyright.
|
|
|
|
|
|
|
|
TestUnit/GUI for the Mufasa Macro Library
|
|
|
|
}
|
|
|
|
|
|
|
|
unit TestUnit;
|
|
|
|
|
|
|
|
{$undef EditButtons}
|
|
|
|
{$Undef ProcessMessages} //Define this for processmessages in ThreadSafeCall
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$ifdef linux}cthreads,{$endif}Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2010-03-02 16:27:49 -05:00
|
|
|
StdCtrls, Menus, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas,
|
2010-01-25 08:59:44 -05:00
|
|
|
//Client,
|
|
|
|
MufasaTypes,
|
|
|
|
mmlpsthread,synedittypes,
|
2010-03-06 07:06:19 -05:00
|
|
|
{$IFDEF MSWINDOWS} os_windows, windows,{$ENDIF} //For ColorPicker etc.
|
2010-01-25 08:59:44 -05:00
|
|
|
{$IFDEF LINUX} os_linux, {$ENDIF} //For ColorPicker etc.
|
2010-03-02 16:27:49 -05:00
|
|
|
colourpicker, framescript, windowselector, lcltype, ActnList,
|
|
|
|
SynExportHTML, SynEditKeyCmds, SynEditHighlighter,
|
2010-03-29 12:24:21 -04:00
|
|
|
SynEditMarkupHighAll, LMessages, Buttons,mmisc,
|
2010-03-30 13:58:41 -04:00
|
|
|
stringutil,mufasatypesutil,mufasabase, v_ideCodeParser,
|
2010-03-22 17:21:08 -04:00
|
|
|
about, framefunctionlist, ocr, updateform, simbasettings, psextension, virtualextension,
|
2010-03-27 16:17:00 -04:00
|
|
|
extensionmanager, settingssandbox, v_ideCodeInsight, CastaliaPasLexTypes,
|
|
|
|
CastaliaSimplePasPar, v_AutoCompleteForm, PSDump;
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
const
|
2010-05-08 19:12:42 -04:00
|
|
|
SimbaVersion = 656;
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TMufasaTab }
|
|
|
|
|
|
|
|
TMufasaTab = class(Tobject)
|
|
|
|
private
|
|
|
|
PageCtrl : TPageControl;
|
|
|
|
public
|
|
|
|
TabSheet : TTabsheet;
|
|
|
|
ScriptFrame : TScriptFrame;
|
|
|
|
procedure Clear;//This will 'reset' the ScriptFrame
|
|
|
|
constructor Create(Page : TPageControl);
|
|
|
|
destructor Destroy; override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
// Tab
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
2010-03-07 10:57:10 -05:00
|
|
|
ActionConsole: TAction;
|
2010-02-28 14:48:26 -05:00
|
|
|
ActionNormalSize: TAction;
|
2010-01-31 07:29:33 -05:00
|
|
|
ActionCompileScript: TAction;
|
2010-01-25 08:59:44 -05:00
|
|
|
ActionExit: TAction;
|
|
|
|
ActionReplace: TAction;
|
|
|
|
ActionFindNext: TAction;
|
|
|
|
ActionRedo: TAction;
|
|
|
|
ActionUndo: TAction;
|
|
|
|
ActionSelectAll: TAction;
|
|
|
|
ActionDelete: TAction;
|
|
|
|
ActionPaste: TAction;
|
|
|
|
ActionCopy: TAction;
|
|
|
|
ActionCut: TAction;
|
|
|
|
ActionFindStart: TAction;
|
|
|
|
ActionClearDebug: TAction;
|
|
|
|
ActionSaveAll: TAction;
|
|
|
|
ActionStopScript: TAction;
|
|
|
|
ActionSaveScript: TAction;
|
|
|
|
ActionSaveScriptAs: TAction;
|
|
|
|
ActionRunScript: TAction;
|
|
|
|
ActionPauseScript: TAction;
|
|
|
|
ActionNewScript: TAction;
|
|
|
|
ActionOpenScript: TAction;
|
|
|
|
ActionNewTab: TAction;
|
|
|
|
ActionCloseTab: TAction;
|
|
|
|
ActionTabLast: TAction;
|
|
|
|
ActionTabNext: TAction;
|
|
|
|
ActionList: TActionList;
|
|
|
|
CheckBoxMatchCase: TCheckBox;
|
2010-04-05 07:56:20 -04:00
|
|
|
LazHighlighter: TSynFreePascalSyn;
|
2010-01-25 08:59:44 -05:00
|
|
|
frmFunctionList: TFunctionListFrame;
|
|
|
|
LabeledEditSearch: TLabeledEdit;
|
|
|
|
MainMenu: TMainMenu;
|
|
|
|
Memo1: TMemo;
|
|
|
|
MenuFile: TMenuItem;
|
|
|
|
MenuEdit: TMenuItem;
|
|
|
|
MenuHelp: TMenuItem;
|
2010-03-22 17:21:08 -04:00
|
|
|
MenuItemExtensions: TMenuItem;
|
2010-03-06 07:06:19 -05:00
|
|
|
MenuItemSettingsButton: TMenuItem;
|
|
|
|
MenuItemDivider10: TMenuItem;
|
|
|
|
MenuTools: TMenuItem;
|
2010-02-26 20:36:33 -05:00
|
|
|
MenuItemOpenRecent: TMenuItem;
|
2010-01-31 07:29:33 -05:00
|
|
|
MenuItemCompile: TMenuItem;
|
|
|
|
MenuItemHandbook: TMenuItem;
|
2010-01-25 08:59:44 -05:00
|
|
|
MenuItemAbout: TMenuItem;
|
|
|
|
MenuItemReportBug: TMenuItem;
|
|
|
|
MenuItemExportHTML: TMenuItem;
|
|
|
|
MenuItemDivider9: TMenuItem;
|
2010-02-05 09:50:49 -05:00
|
|
|
MouseTimer: TTimer;
|
2010-02-21 12:13:29 -05:00
|
|
|
NewsTimer: TTimer;
|
2010-04-05 07:56:20 -04:00
|
|
|
SCARHighlighter: TSynFreePascalSyn;
|
2010-04-07 10:23:48 -04:00
|
|
|
FunctionListTimer: TTimer;
|
2010-03-07 10:57:10 -05:00
|
|
|
TT_Console: TToolButton;
|
2010-01-25 08:59:44 -05:00
|
|
|
TT_Cut: TToolButton;
|
|
|
|
TT_Copy: TToolButton;
|
|
|
|
TT_Paste: TToolButton;
|
|
|
|
ToolButton9: TToolButton;
|
|
|
|
UpdateTimer: TTimer;
|
|
|
|
ToolButton3: TToolButton;
|
|
|
|
TT_Update: TToolButton;
|
|
|
|
UpdateMenuButton: TMenuItem;
|
|
|
|
MenuitemFillFunctionList: TMenuItem;
|
|
|
|
MenuItemFunctionList: TMenuItem;
|
|
|
|
MenuItemHide: TMenuItem;
|
|
|
|
MenuItemDebugImage: TMenuItem;
|
|
|
|
MenuItemMainExit: TMenuItem;
|
|
|
|
MenuItemDivider6: TMenuItem;
|
|
|
|
PopupItemReplace: TMenuItem;
|
|
|
|
MenuItemReplace: TMenuItem;
|
|
|
|
dlgReplace: TReplaceDialog;
|
|
|
|
MenuItemColourHistory: TMenuItem;
|
|
|
|
MenuView: TMenuItem;
|
|
|
|
MenuItemFindNext: TMenuItem;
|
|
|
|
PopupItemDelete: TMenuItem;
|
|
|
|
MenuItemDelete: TMenuItem;
|
|
|
|
MenuItemDivider5: TMenuItem;
|
|
|
|
MenuItemSelectAll: TMenuItem;
|
|
|
|
PopupItemSelectAll: TMenuItem;
|
|
|
|
PopupItemDivider2: TMenuItem;
|
|
|
|
PopupItemPaste: TMenuItem;
|
|
|
|
PopupItemCopy: TMenuItem;
|
|
|
|
PopupItemCut: TMenuItem;
|
|
|
|
PopupItemDivider1: TMenuItem;
|
|
|
|
PopupItemRedo: TMenuItem;
|
|
|
|
PopupItemUndo: TMenuItem;
|
|
|
|
PopupItemDivider3: TMenuItem;
|
|
|
|
PopupItemFind: TMenuItem;
|
|
|
|
MenuItemFind: TMenuItem;
|
|
|
|
MenuItemDivider4: TMenuItem;
|
|
|
|
MenuItemDivider3: TMenuItem;
|
|
|
|
MenuItemCopy: TMenuItem;
|
|
|
|
MenuItemSaveAll: TMenuItem;
|
|
|
|
MenuItemTabCloseOthers: TMenuItem;
|
|
|
|
MenuItemTabAdd: TMenuItem;
|
|
|
|
MenuItemTabClose: TMenuItem;
|
|
|
|
MenuItemCloseTabs: TMenuItem;
|
|
|
|
MenuItemCloseTab: TMenuItem;
|
|
|
|
MenuItemNewTab: TMenuItem;
|
|
|
|
MenuItemDivider2: TMenuItem;
|
|
|
|
MenuItemDivider: TMenuItem;
|
|
|
|
PageControl1: TPageControl;
|
|
|
|
ScriptPopup: TPopupMenu;
|
|
|
|
SearchPanel: TPanel;
|
|
|
|
ScriptPanel: TPanel;
|
|
|
|
SpeedButtonSearch: TSpeedButton;
|
|
|
|
SplitterFunctionList: TSplitter;
|
|
|
|
TabPopup: TPopupMenu;
|
|
|
|
TB_SaveAll: TToolButton;
|
|
|
|
DebugTimer: TTimer;
|
|
|
|
TrayDivider: TMenuItem;
|
|
|
|
TrayPlay: TMenuItem;
|
|
|
|
TrayStop: TMenuItem;
|
|
|
|
TrayPause: TMenuItem;
|
|
|
|
MenuItemPause: TMenuItem;
|
|
|
|
MenuItemStop: TMenuItem;
|
|
|
|
MenuItemShow: TMenuItem;
|
|
|
|
MenuItemExit: TMenuItem;
|
|
|
|
MenuItemCut: TMenuItem;
|
|
|
|
MenuItemPaste: TMenuItem;
|
|
|
|
MenuItemNew: TMenuItem;
|
|
|
|
MenuItemSaveAs: TMenuItem;
|
|
|
|
MenuItemOpen: TMenuItem;
|
|
|
|
MenuItemRedo: TMenuItem;
|
|
|
|
MenuItemUndo: TMenuItem;
|
|
|
|
MenuItemSave: TMenuItem;
|
|
|
|
Mufasa_Image_List: TImageList;
|
|
|
|
MenuItemScript: TMenuItem;
|
|
|
|
MenuItemRun: TMenuItem;
|
|
|
|
PanelMemo: TPanel;
|
|
|
|
SplitterMemoSynedit: TSplitter;
|
|
|
|
TrayPopup: TPopupMenu;
|
|
|
|
StatusBar: TStatusBar;
|
|
|
|
ToolBar1: TToolBar;
|
|
|
|
TB_Run: TToolButton;
|
|
|
|
TB_Pause: TToolButton;
|
|
|
|
TB_Stop: TToolButton;
|
|
|
|
ToolButton1: TToolButton;
|
|
|
|
TB_ReloadPlugins: TToolButton;
|
|
|
|
TB_Tray: TToolButton;
|
|
|
|
TB_NewTab: TToolButton;
|
|
|
|
TB_CloseTab: TToolButton;
|
|
|
|
TB_New: TToolButton;
|
|
|
|
ToolButton2: TToolButton;
|
|
|
|
TB_Open: TToolButton;
|
|
|
|
TB_Save: TToolButton;
|
|
|
|
ToolButton4: TToolButton;
|
|
|
|
TB_ClearDebug: TToolButton;
|
|
|
|
TB_PickColour: TToolButton;
|
|
|
|
TB_SelectClient: TToolButton;
|
|
|
|
ToolButton8: TToolButton;
|
|
|
|
MTrayIcon: TTrayIcon;
|
|
|
|
procedure ActionClearDebugExecute(Sender: TObject);
|
|
|
|
procedure ActionCloseTabExecute(Sender: TObject);
|
2010-01-31 07:29:33 -05:00
|
|
|
procedure ActionCompileScriptExecute(Sender: TObject);
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure ActionConsoleExecute(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure ActionCopyExecute(Sender: TObject);
|
|
|
|
procedure ActionCutExecute(Sender: TObject);
|
|
|
|
procedure ActionDeleteExecute(Sender: TObject);
|
|
|
|
procedure ActionExitExecute(Sender: TObject);
|
|
|
|
procedure ActionFindNextExecute(Sender: TObject);
|
|
|
|
procedure ActionFindstartExecute(Sender: TObject);
|
|
|
|
procedure ActionNewExecute(Sender: TObject);
|
|
|
|
procedure ActionNewTabExecute(Sender: TObject);
|
2010-02-28 14:48:26 -05:00
|
|
|
procedure ActionNormalSizeExecute(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure ActionOpenExecute(Sender: TObject);
|
|
|
|
procedure ActionPasteExecute(Sender: TObject);
|
|
|
|
procedure ActionPauseExecute(Sender: TObject);
|
|
|
|
procedure ActionRedoExecute(Sender: TObject);
|
|
|
|
procedure ActionReplaceExecute(Sender: TObject);
|
|
|
|
procedure ActionRunExecute(Sender: TObject);
|
|
|
|
procedure ActionSaveAllExecute(Sender: TObject);
|
|
|
|
procedure ActionSaveAsExecute(Sender: TObject);
|
|
|
|
procedure ActionSaveExecute(Sender: TObject);
|
|
|
|
procedure ActionSelectAllExecute(Sender: TObject);
|
|
|
|
procedure ActionStopExecute(Sender: TObject);
|
|
|
|
procedure ActionTabLastExecute(Sender: TObject);
|
|
|
|
procedure ActionTabNextExecute(Sender: TObject);
|
|
|
|
procedure ActionUndoExecute(Sender: TObject);
|
2010-02-05 09:50:49 -05:00
|
|
|
procedure ChangeMouseStatus(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure CheckBoxMatchCaseClick(Sender: TObject);
|
|
|
|
procedure CloseFindPanel;
|
2010-04-29 13:01:20 -04:00
|
|
|
procedure doOnHide(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure editSearchListExit(Sender: TObject);
|
|
|
|
procedure editSearchListKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
|
|
|
procedure editSearchListKeyPress(Sender: TObject; var Key: char);
|
2010-03-03 12:56:05 -05:00
|
|
|
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure FunctionListChange(Sender: TObject; Node: TTreeNode);
|
|
|
|
procedure FunctionListEnter(Sender: TObject);
|
|
|
|
procedure FunctionListExit(Sender: TObject);
|
2010-04-07 10:23:48 -04:00
|
|
|
procedure FunctionListTimerTimer(Sender: TObject);
|
2010-03-22 17:21:08 -04:00
|
|
|
procedure MenuItemExtensionsClick(Sender: TObject);
|
2010-01-31 07:29:33 -05:00
|
|
|
procedure MenuItemHandbookClick(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure MenuItemColourHistoryClick(Sender: TObject);
|
|
|
|
procedure dlgReplaceFind(Sender: TObject);
|
|
|
|
procedure dlgReplaceReplace(Sender: TObject);
|
|
|
|
procedure EditSearchChange(Sender: TObject);
|
|
|
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure FormDestroy(Sender: TObject);
|
|
|
|
procedure FormShortCuts(var Msg: TLMKey; var Handled: Boolean);
|
|
|
|
procedure LabeledEditSearchEnter(Sender: TObject);
|
|
|
|
procedure LabeledEditSearchExit(Sender: TObject);
|
|
|
|
procedure LabeledEditSearchKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
|
|
|
procedure LabeledEditSearchKeyPress(Sender: TObject; var Key: char);
|
|
|
|
procedure MenuEditClick(Sender: TObject);
|
|
|
|
procedure MenuItemAboutClick(Sender: TObject);
|
|
|
|
procedure MenuItemCloseTabsClick(Sender: TObject);
|
|
|
|
procedure MenuItemDebugImageClick(Sender: TObject);
|
|
|
|
procedure MenuItemExportHTMLClick(Sender: TObject);
|
|
|
|
procedure MenuitemFillFunctionListClick(Sender: TObject);
|
|
|
|
procedure MenuItemHideClick(Sender: TObject);
|
|
|
|
procedure MenuItemReportBugClick(Sender: TObject);
|
2010-03-06 07:06:19 -05:00
|
|
|
procedure MenuItemSettingsButtonClick(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure MenuItemShowClick(Sender: TObject);
|
|
|
|
procedure MenuItemTabCloseClick(Sender: TObject);
|
|
|
|
procedure MenuItemTabCloseOthersClick(Sender: TObject);
|
|
|
|
procedure MenuItemFunctionListClick(Sender: TObject);
|
2010-04-15 18:30:19 -04:00
|
|
|
procedure MTrayIconClick(Sender: TObject);
|
2010-02-21 12:13:29 -05:00
|
|
|
procedure NewsTimerTimer(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure OnLinePSScript(Sender: TObject);
|
|
|
|
procedure ButtonPickClick(Sender: TObject);
|
|
|
|
procedure ButtonSelectorDown(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
procedure PageControl1Change(Sender: TObject);
|
|
|
|
procedure ButtonTrayClick(Sender: TObject);
|
|
|
|
procedure PageControl1Changing(Sender: TObject; var AllowChange: Boolean);
|
|
|
|
procedure PageControl1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
|
var Handled: Boolean);
|
|
|
|
procedure PageControl1DragDrop(Sender, Source: TObject; X, Y: Integer);
|
|
|
|
procedure PageControl1DragOver(Sender, Source: TObject; X, Y: Integer;
|
|
|
|
State: TDragState; var Accept: Boolean);
|
|
|
|
procedure PageControl1MouseDown(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
procedure PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure PickerPick(Sender: TObject; const Colour, colourx,
|
|
|
|
coloury: integer);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure PopupItemFindClick(Sender: TObject);
|
|
|
|
procedure ProcessDebugStream(Sender: TObject);
|
2010-02-26 20:36:33 -05:00
|
|
|
procedure RecentFileItemsClick(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure ScriptPanelDockDrop(Sender: TObject; Source: TDragDockObject; X,
|
|
|
|
Y: Integer);
|
|
|
|
procedure ScriptPanelDockOver(Sender: TObject; Source: TDragDockObject; X,
|
|
|
|
Y: Integer; State: TDragState; var Accept: Boolean);
|
|
|
|
procedure ScriptPopupPopup(Sender: TObject);
|
|
|
|
procedure SpeedButtonSearchClick(Sender: TObject);
|
|
|
|
procedure SplitterFunctionListCanResize(Sender: TObject; var NewSize: Integer;
|
|
|
|
var Accept: Boolean);
|
2010-02-04 18:32:24 -05:00
|
|
|
procedure TB_ReloadPluginsClick(Sender: TObject);
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure ThreadOpenConnectionEvent(Sender: TObject; var url: string;
|
|
|
|
var Continue: boolean);
|
|
|
|
procedure ThreadOpenFileEvent(Sender: TObject; var Filename: string;
|
|
|
|
var Continue: boolean);
|
|
|
|
procedure ThreadWriteFileEvent(Sender: TObject; var Filename: string;
|
|
|
|
var Continue: boolean);
|
|
|
|
procedure ScriptStartEvent(Sender: TObject; var Script : string; var Continue : boolean);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TrayPopupPopup(Sender: TObject);
|
|
|
|
procedure TT_UpdateClick(Sender: TObject);
|
|
|
|
procedure UpdateMenuButtonClick(Sender: TObject);
|
|
|
|
procedure UpdateTimerCheck(Sender: TObject);
|
2010-03-26 16:34:41 -04:00
|
|
|
|
|
|
|
procedure OnCCMessage(Sender: TObject; const Typ: TMessageEventType; const Msg: string; X, Y: Integer);
|
|
|
|
procedure OnCompleteCode(Str: string);
|
|
|
|
function OnCCFindInclude(Sender: TObject; var FileName: string): Boolean;
|
2010-01-25 08:59:44 -05:00
|
|
|
private
|
|
|
|
PopupTab : integer;
|
2010-02-26 20:36:33 -05:00
|
|
|
RecentFileItems : array of TMenuItem;
|
|
|
|
RecentFiles : TStringList;
|
2010-01-25 08:59:44 -05:00
|
|
|
FirstRun : boolean;//Only show the warnings the first run (path not existing one's)
|
|
|
|
SearchStart : TPoint;
|
|
|
|
LastTab : integer;
|
2010-03-29 17:01:54 -04:00
|
|
|
UpdatingFonts : boolean;
|
2010-04-07 08:01:26 -04:00
|
|
|
OpenConnectionData : TOpenConnectionData;
|
|
|
|
OpenFileData : TOpenFileData;
|
|
|
|
WriteFileData : TWriteFileData;
|
|
|
|
ScriptStartData : TScriptStartData;
|
|
|
|
procedure HandleConnectionData;
|
|
|
|
procedure HandleOpenFileData;
|
|
|
|
procedure HandleWriteFileData;
|
|
|
|
procedure HandleScriptStartData;
|
2010-04-16 10:09:01 -04:00
|
|
|
function GetScriptPath : string;
|
2010-04-05 07:56:20 -04:00
|
|
|
function GetExtPath: string;
|
2010-03-29 17:01:54 -04:00
|
|
|
function GetFontPath: String;
|
2010-04-05 07:56:20 -04:00
|
|
|
function GetHighlighter: TSynCustomHighlighter;
|
2010-03-27 09:10:16 -04:00
|
|
|
function GetIncludePath: String;
|
2010-04-05 07:56:20 -04:00
|
|
|
function GetPluginPath: string;
|
2010-01-25 08:59:44 -05:00
|
|
|
function GetScriptState: TScriptState;
|
2010-03-31 15:40:53 -04:00
|
|
|
function GetShowHintAuto: boolean;
|
2010-04-05 07:56:20 -04:00
|
|
|
function GetSimbaNews: String;
|
|
|
|
procedure SetExtPath(const AValue: string);
|
2010-03-29 17:01:54 -04:00
|
|
|
procedure SetFontPath(const AValue: String);
|
2010-03-27 09:10:16 -04:00
|
|
|
procedure SetIncludePath(const AValue: String);
|
2010-04-05 07:56:20 -04:00
|
|
|
procedure SetPluginPath(const AValue: string);
|
2010-04-16 10:09:01 -04:00
|
|
|
procedure SetScriptPath(const AValue: string);
|
2010-03-31 15:40:53 -04:00
|
|
|
procedure SetShowHintAuto(const AValue: boolean);
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure SetScriptState(const State: TScriptState);
|
2010-04-03 08:05:15 -04:00
|
|
|
function LoadSettingDef(const Key, Def : string) : string;
|
|
|
|
function CreateSetting(const Key, Value : string) : string;
|
|
|
|
procedure SetSetting(const key,Value : string; save : boolean = false);
|
|
|
|
function SettingExtists(const key : string) : boolean;
|
2010-03-29 17:01:54 -04:00
|
|
|
procedure FontUpdate;
|
2010-01-25 08:59:44 -05:00
|
|
|
public
|
|
|
|
DebugStream: String;
|
|
|
|
SearchString : string;
|
|
|
|
CurrScript : TScriptFrame; //The current scriptframe
|
|
|
|
CurrTab : TMufasaTab; //The current TMufasaTab
|
2010-03-26 16:34:41 -04:00
|
|
|
CodeCompletionForm: TAutoCompletePopup;
|
|
|
|
CodeCompletionStart: TPoint;
|
2010-03-31 14:23:39 -04:00
|
|
|
ParamHint : TParamHint;
|
2010-01-25 08:59:44 -05:00
|
|
|
Tabs : TList;
|
|
|
|
Manager: TIOManager;
|
|
|
|
OCR_Fonts: TMOCR;
|
|
|
|
Picker: TMColorPicker;
|
|
|
|
Selector: TMWindowSelector;
|
2010-04-07 08:01:26 -04:00
|
|
|
OnScriptStart : TScriptStartEvent;
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef mswindows}
|
|
|
|
ConsoleVisible : boolean;
|
|
|
|
procedure ShowConsole( ShowIt : boolean);
|
|
|
|
{$endif}
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure FunctionListShown( ShowIt : boolean);
|
|
|
|
property ScriptState : TScriptState read GetScriptState write SetScriptState;
|
|
|
|
procedure SafeCallThread;
|
|
|
|
function OpenScript : boolean;
|
2010-03-28 16:11:12 -04:00
|
|
|
function LoadScriptFile(filename : string; AlwaysOpenInNewTab : boolean = false; CheckOtherTabs : boolean = true) : boolean;
|
2010-01-25 08:59:44 -05:00
|
|
|
function SaveCurrentScript : boolean;
|
|
|
|
function SaveCurrentScriptAs : boolean;
|
|
|
|
function CanExitOrOpen : boolean;
|
|
|
|
function ClearScript : boolean;
|
|
|
|
procedure RunScript;
|
|
|
|
procedure PauseScript;
|
|
|
|
procedure StopScript;
|
|
|
|
procedure AddTab;
|
|
|
|
procedure StopCodeCompletion;
|
2010-03-28 16:11:12 -04:00
|
|
|
function FindTab(filename : string) : integer;
|
2010-01-25 08:59:44 -05:00
|
|
|
function DeleteTab( TabIndex : integer; CloseLast : boolean; Silent : boolean = false) : boolean;
|
|
|
|
procedure ClearTab( TabIndex : integer);
|
|
|
|
procedure CloseTabs(Exclude: integer = -1; Silent : boolean = false); //-1 for no exclusion
|
|
|
|
procedure SetEditActions;
|
|
|
|
procedure DoSearch(Next : boolean; HighlightAll : boolean);
|
|
|
|
procedure RefreshTab;//Refreshes all the form items that depend on the Script (Panels, title etc.)
|
|
|
|
procedure RefreshTabSender(sender : PtrInt);
|
2010-02-07 10:59:03 -05:00
|
|
|
procedure CreateDefaultEnvironment;
|
2010-02-26 20:36:33 -05:00
|
|
|
procedure LoadFormSettings;
|
|
|
|
procedure SaveFormSettings;
|
2010-04-05 07:56:20 -04:00
|
|
|
procedure LoadExtensions;
|
2010-04-03 09:10:13 -04:00
|
|
|
procedure AddRecentFile(const filename : string);
|
2010-02-07 17:57:08 -05:00
|
|
|
procedure InitalizeTMThread(var Thread : TMThread);
|
2010-02-13 11:56:46 -05:00
|
|
|
procedure HandleParameters;
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure OnSaveScript(const Filename : string);
|
2010-03-31 15:40:53 -04:00
|
|
|
property ShowHintAuto : boolean read GetShowHintAuto write SetShowHintAuto;
|
2010-03-27 09:10:16 -04:00
|
|
|
property IncludePath : String read GetIncludePath write SetIncludePath;
|
2010-03-29 17:01:54 -04:00
|
|
|
property FontPath : String read GetFontPath write SetFontPath;
|
2010-04-05 07:56:20 -04:00
|
|
|
property PluginPath : string read GetPluginPath write SetPluginPath;
|
|
|
|
property ExtPath : string read GetExtPath write SetExtPath;
|
2010-04-16 10:09:01 -04:00
|
|
|
property ScriptDir : string read GetScriptPath write SetScriptPath;
|
2010-04-05 07:56:20 -04:00
|
|
|
property CurrHighlighter : TSynCustomHighlighter read GetHighlighter;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
2010-03-06 09:23:24 -05:00
|
|
|
procedure ClearDebug;
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure formWriteln( S : String);
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure formWritelnEx( S : String);
|
2010-01-25 08:59:44 -05:00
|
|
|
function GetMethodName( Decl : string; PlusNextChar : boolean) : string;
|
|
|
|
|
|
|
|
const
|
|
|
|
// Rip Mufasa -> Simba ftw
|
|
|
|
//WindowTitle = 'Mufasa v2 - %s';//Title, where %s = the place of the filename.
|
|
|
|
WindowTitle = 'Simba - %s';//Title, where %s = the place of the filename.
|
|
|
|
Panel_State = 0;
|
2010-02-05 09:50:49 -05:00
|
|
|
Panel_Coords = 1;
|
|
|
|
Panel_ScriptName = 2;
|
|
|
|
Panel_ScriptPath = 3;
|
|
|
|
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
Image_Stop = 7;
|
|
|
|
Image_Terminate = 19;
|
|
|
|
var
|
|
|
|
Form1: TForm1;
|
|
|
|
MainDir : string;
|
2010-03-22 10:58:30 -04:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
PrevWndProc : WNDPROC;
|
|
|
|
{$endif}
|
2010-01-25 08:59:44 -05:00
|
|
|
CurrentSyncInfo : TSyncInfo;//We need this for SafeCallThread
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
2010-03-02 16:27:49 -05:00
|
|
|
lclintf,
|
2010-01-25 08:59:44 -05:00
|
|
|
syncobjs, // for the critical sections
|
|
|
|
debugimage,
|
2010-03-27 09:10:16 -04:00
|
|
|
files,
|
2010-04-21 11:10:40 -04:00
|
|
|
InterfaceBase,
|
2010-03-22 17:21:08 -04:00
|
|
|
extensionmanagergui,
|
2010-01-25 08:59:44 -05:00
|
|
|
colourhistory,
|
|
|
|
math;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef mswindows}
|
|
|
|
function ConsoleHandler( eventType : DWord) : WINBOOL;stdcall;
|
|
|
|
begin
|
|
|
|
TThread.Synchronize(nil,@Form1.Close);
|
|
|
|
Result := true;
|
|
|
|
end;
|
2010-03-22 10:58:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam;
|
|
|
|
lParam: LParam): LRESULT stdcall;
|
|
|
|
begin
|
|
|
|
if uMsg = WM_HOTKEY then
|
|
|
|
begin
|
|
|
|
Form1.ActionStopScript.Execute;
|
|
|
|
Result := 0;
|
|
|
|
end else
|
|
|
|
Result := Windows.CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);
|
|
|
|
end;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
{$endif}
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
var
|
|
|
|
DebugCriticalSection: syncobjs.TCriticalSection;
|
|
|
|
|
2010-03-26 16:34:41 -04:00
|
|
|
procedure TForm1.OnCCMessage(Sender: TObject; const Typ: TMessageEventType; const Msg: string; X, Y: Integer);
|
|
|
|
begin
|
|
|
|
if (Typ = meNotSupported) then
|
|
|
|
Exit;
|
|
|
|
if (Sender is TmwSimplePasPar) then
|
|
|
|
if (TmwSimplePasPar(Sender).Lexer.TokenID = tok_DONE) then
|
|
|
|
Exit;
|
|
|
|
mDebugLn('ERROR: '+Format('%d:%d %s', [Y + 1, X, Msg])+' in '+TCodeInsight(Sender).FileName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.OnCompleteCode(Str: string);
|
|
|
|
var
|
|
|
|
sp, ep: Integer;
|
|
|
|
s: string;
|
|
|
|
begin
|
|
|
|
if (Str <> '') then
|
|
|
|
begin
|
|
|
|
s := WordAtCaret(CurrScript.SynEdit, sp, ep);
|
|
|
|
if (s <> '') then
|
|
|
|
begin
|
|
|
|
CurrScript.SynEdit.SelStart := CurrScript.SynEdit.SelStart + (sp - CurrScript.SynEdit.CaretX);
|
|
|
|
CurrScript.SynEdit.SelEnd := CurrScript.SynEdit.SelStart + (ep - CurrScript.SynEdit.CaretX) + 1;
|
|
|
|
CurrScript.SynEdit.SelText := Str;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
CurrScript.SynEdit.InsertTextAtCaret(Str);
|
|
|
|
end;
|
|
|
|
end;
|
2010-01-25 08:59:44 -05:00
|
|
|
|
2010-03-26 16:34:41 -04:00
|
|
|
function TForm1.OnCCFindInclude(Sender: TObject; var FileName: string): Boolean;
|
2010-03-27 09:10:16 -04:00
|
|
|
var
|
|
|
|
Temp : string;
|
2010-03-26 16:34:41 -04:00
|
|
|
begin
|
2010-03-28 09:31:08 -04:00
|
|
|
Temp := FindFile(filename,[MainDir+DS,IncludePath]);
|
2010-03-27 09:10:16 -04:00
|
|
|
if temp <> '' then
|
|
|
|
begin;
|
|
|
|
filename := temp;
|
|
|
|
result := true;
|
|
|
|
end else
|
|
|
|
result := false;
|
2010-03-26 16:34:41 -04:00
|
|
|
end;
|
|
|
|
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure TForm1.HandleConnectionData;
|
|
|
|
var
|
|
|
|
Args : TVariantArray;
|
|
|
|
begin
|
|
|
|
SetLength(Args,2);
|
|
|
|
Args[0] := OpenConnectionData.URL^;
|
|
|
|
Args[1] := OpenConnectionData.Continue^;
|
|
|
|
try
|
|
|
|
ExtManager.HandleHook(EventHooks[SExt_onOpenConnection].HookName,Args);
|
|
|
|
OpenConnectionData.URL^ := Args[0];
|
|
|
|
OpenConnectionData.Continue^ := Args[1];
|
|
|
|
except
|
|
|
|
on e : Exception do
|
|
|
|
mDebugLn('ERROR in HandleConnectiondata: ' + e.message);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-16 10:09:01 -04:00
|
|
|
function TForm1.GetScriptPath: string;
|
|
|
|
begin
|
|
|
|
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Scripts/Path', ExpandFileName(MainDir+DS+'Scripts' + DS)));
|
|
|
|
end;
|
|
|
|
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure TForm1.HandleOpenFileData;
|
|
|
|
var
|
|
|
|
Args : TVariantArray;
|
|
|
|
begin
|
|
|
|
SetLength(Args,2);
|
|
|
|
Args[0] := OpenFileData.FileName^;
|
|
|
|
Args[1] := OpenFileData.Continue^;
|
|
|
|
try
|
|
|
|
ExtManager.HandleHook(EventHooks[SExt_onOpenFile].HookName,Args);
|
|
|
|
OpenFileData.FileName^ := Args[0];
|
|
|
|
OpenFileData.Continue^ := Args[1];
|
|
|
|
except
|
|
|
|
on e : Exception do
|
|
|
|
mDebugLn('ERROR in HandleOpenFileData: ' + e.message);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.HandleWriteFileData;
|
|
|
|
var
|
|
|
|
Args : TVariantArray;
|
|
|
|
begin
|
|
|
|
SetLength(Args,2);
|
|
|
|
Args[0] := WriteFileData.FileName^;
|
|
|
|
Args[1] := WriteFileData.Continue^;
|
|
|
|
try
|
|
|
|
ExtManager.HandleHook(EventHooks[SExt_onWriteFile].HookName,Args);
|
|
|
|
WriteFileData.FileName^ := Args[0];
|
|
|
|
WriteFileData.Continue^ := Args[1];
|
|
|
|
except
|
|
|
|
on e : Exception do
|
|
|
|
mDebugLn('ERROR in HandleWriteFileData: ' + e.message);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.HandleScriptStartData;
|
|
|
|
var
|
|
|
|
Args : TVariantArray;
|
|
|
|
begin
|
|
|
|
SetLength(Args,2);
|
|
|
|
Args[0] := ScriptStartData.Script^;
|
|
|
|
Args[1] := ScriptStartData.Continue^;
|
|
|
|
try
|
|
|
|
ExtManager.HandleHook(EventHooks[SExt_onScriptStart].HookName,Args);
|
|
|
|
ScriptStartData.Script^ := Args[0];
|
|
|
|
ScriptStartData.Continue^ := Args[1];
|
|
|
|
except
|
|
|
|
on e : Exception do
|
|
|
|
mDebugLn('ERROR in HandleScriptStartData: ' + e.message);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-03-26 16:34:41 -04:00
|
|
|
procedure TForm1.ProcessDebugStream(Sender: TObject);
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
if length(DebugStream) = 0 then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
// cut off 1 newline char
|
|
|
|
|
|
|
|
DebugCriticalSection.Enter;
|
|
|
|
|
|
|
|
try
|
|
|
|
setlength(DebugStream, length(DebugStream) - 1);
|
|
|
|
Memo1.Lines.Add(DebugStream);
|
|
|
|
SetLength(DebugStream, 0);
|
|
|
|
finally
|
|
|
|
DebugCriticalSection.Leave;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-02-26 20:36:33 -05:00
|
|
|
procedure TForm1.RecentFileItemsClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
i : integer;
|
|
|
|
begin
|
|
|
|
for i := 0 to high(RecentFileItems) do
|
|
|
|
if RecentFileItems[i] = sender then
|
|
|
|
begin;
|
|
|
|
LoadScriptFile(RecentFiles[RecentFiles.Count - 1 -i]);//Inverse order
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.ScriptPanelDockDrop(Sender: TObject; Source: TDragDockObject;
|
|
|
|
X, Y: Integer);
|
|
|
|
begin
|
|
|
|
if(X <= (ScriptPanel.Width div 2))then
|
|
|
|
begin
|
|
|
|
frmFunctionList.Align := alLeft;
|
|
|
|
PageControl1.Align := alRight;
|
|
|
|
SplitterFunctionList.ResizeAnchor := akLeft;
|
|
|
|
SplitterFunctionList.Align := alLeft;
|
|
|
|
SplitterFunctionList.Left := frmFunctionList.Left + frmFunctionList.Width;
|
|
|
|
end else begin
|
|
|
|
frmFunctionList.Align := alRight;
|
|
|
|
PageControl1.Align := alLeft;
|
|
|
|
SplitterFunctionList.ResizeAnchor := akRight;
|
|
|
|
SplitterFunctionList.Align := alRight;
|
|
|
|
SplitterFunctionList.Left := frmFunctionList.Left;
|
|
|
|
end;
|
|
|
|
PageControl1.Width := ScriptPanel.Width - (Source.DockRect.Right - Source.DockRect.Left);
|
|
|
|
frmFunctionList.Width := ScriptPanel.Width - PageControl1.Width;
|
|
|
|
PageControl1.Align := alClient;
|
|
|
|
SplitterFunctionList.Show;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ScriptPanelDockOver(Sender: TObject; Source: TDragDockObject; //is there a better way to do all of this?
|
|
|
|
X, Y: Integer; State: TDragState; var Accept: Boolean);
|
|
|
|
var
|
|
|
|
P: TPoint;
|
|
|
|
begin
|
|
|
|
Accept := frmFunctionList.DragKind = dkDock;
|
|
|
|
if(Accept)then
|
|
|
|
begin
|
2010-03-06 07:06:19 -05:00
|
|
|
P := ScriptPanel.ClientToScreen(Classes.Point(0, 0));
|
2010-01-25 08:59:44 -05:00
|
|
|
if(X <= (ScriptPanel.Width div 2))then
|
2010-03-06 07:06:19 -05:00
|
|
|
Source.DockRect := Classes.Rect(P.x, P.y, min(P.x + frmFunctionList.Width, P.x + (ScriptPanel.Width div 2)), P.y + ScriptPanel.Height)
|
2010-01-25 08:59:44 -05:00
|
|
|
else
|
2010-03-06 07:06:19 -05:00
|
|
|
Source.DockRect := Classes.Rect(max(P.x + ScriptPanel.Width - frmFunctionList.Width, P.x + (ScriptPanel.Width div 2)), P.y, P.x + ScriptPanel.Width, P.y + ScriptPanel.Height);
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ScriptPopupPopup(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SetEditActions;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.SpeedButtonSearchClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
CloseFindPanel;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.SplitterFunctionListCanResize(Sender: TObject; var NewSize: Integer;
|
|
|
|
var Accept: Boolean);
|
|
|
|
begin
|
|
|
|
if(NewSize > ScriptPanel.Width div 2)then
|
|
|
|
NewSize := ScriptPanel.Width div 2;
|
|
|
|
end;
|
|
|
|
|
2010-02-04 18:32:24 -05:00
|
|
|
procedure TForm1.TB_ReloadPluginsClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
// PluginsGlob.FreePlugins;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure TForm1.ThreadOpenConnectionEvent(Sender: TObject; var url: string;var Continue: boolean);
|
|
|
|
begin
|
|
|
|
OpenConnectionData.Sender := Sender;
|
|
|
|
OpenConnectionData.URL:= @URL;
|
|
|
|
OpenConnectionData.Continue:= @Continue;
|
|
|
|
TThread.Synchronize(nil,@HandleConnectionData);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ThreadOpenFileEvent(Sender: TObject; var Filename: string;
|
|
|
|
var Continue: boolean);
|
|
|
|
begin
|
|
|
|
OpenFileData.Sender := Sender;
|
|
|
|
OpenFileData.FileName:= @FileName;
|
|
|
|
OpenFileData.Continue:= @Continue;
|
|
|
|
TThread.Synchronize(nil,@HandleOpenFileData);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ThreadWriteFileEvent(Sender: TObject; var Filename: string;
|
|
|
|
var Continue: boolean);
|
|
|
|
begin
|
|
|
|
WriteFileData.Sender := Sender;
|
|
|
|
WriteFileData.FileName:= @FileName;
|
|
|
|
WriteFileData.Continue:= @Continue;
|
|
|
|
TThread.Synchronize(nil,@HandleWriteFileData);
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.TrayPopupPopup(Sender: TObject);
|
|
|
|
begin
|
|
|
|
MenuItemHide.enabled:= Form1.Visible;
|
|
|
|
{$ifdef MSWindows}
|
|
|
|
MenuItemShow.Enabled:= not Form1.Visible;
|
|
|
|
if Form1.Visible then
|
|
|
|
if Form1.CanFocus then
|
|
|
|
form1.SetFocus;
|
|
|
|
{$endif}
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.TT_UpdateClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SimbaUpdateForm.ShowModal;
|
|
|
|
TT_Update.Visible:=False;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.UpdateTimerCheck(Sender: TObject);
|
|
|
|
var
|
|
|
|
chk: String;
|
|
|
|
time:integer;
|
2010-03-07 10:57:10 -05:00
|
|
|
LatestVersion : integer;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
2010-03-29 17:01:54 -04:00
|
|
|
UpdateTimer.Interval:= MaxInt;
|
|
|
|
FontUpdate;
|
|
|
|
chk := LowerCase(LoadSettingDef('Settings/Updater/CheckForUpdates','True'));
|
2010-01-25 08:59:44 -05:00
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
if chk <> 'true' then
|
2010-01-25 08:59:44 -05:00
|
|
|
Exit;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
LatestVersion:= SimbaUpdateForm.GetLatestSimbaVersion;
|
|
|
|
if LatestVersion > SimbaVersion then
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
TT_Update.Visible:=True;
|
2010-03-07 10:57:10 -05:00
|
|
|
formWritelnEx('A new update of Simba is available!');
|
|
|
|
formWritelnEx(format('Current version is %d. Latest version is %d',[SimbaVersion,LatestVersion]));
|
|
|
|
end else
|
|
|
|
begin
|
|
|
|
mDebugLn(format('Current Simba version: %d',[SimbaVersion]));
|
|
|
|
mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion));
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
time := StrToIntDef(LoadSettingDef('Settings/Updater/CheckEveryXMinutes','30'),30);
|
|
|
|
UpdateTimer.Interval:= time {mins} * 60 {secs} * 1000 {ms};//Every half hour
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.UpdateMenuButtonClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SimbaUpdateForm.ShowModal;
|
|
|
|
end;
|
|
|
|
|
2010-03-06 09:23:24 -05:00
|
|
|
procedure ClearDebug;
|
|
|
|
begin
|
|
|
|
{$IFNDEF MSWINDOWS}
|
|
|
|
Form1.ProcessDebugStream(nil);
|
|
|
|
{$ENDIF}
|
|
|
|
TThread.Synchronize(nil,@Form1.Memo1.Clear);
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure formWriteln( S : String);
|
|
|
|
begin
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('formWriteln: ' + s);
|
2010-03-06 09:23:24 -05:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
//Ha, we cán acces the debugmemo
|
|
|
|
Form1.Memo1.Lines.Add(s);
|
|
|
|
{$else}
|
2010-01-25 08:59:44 -05:00
|
|
|
DebugCriticalSection.Enter;
|
|
|
|
try
|
|
|
|
s := s + MEOL;
|
|
|
|
Form1.DebugStream:= Form1.DebugStream + s;
|
|
|
|
finally
|
|
|
|
DebugCriticalSection.Leave;
|
|
|
|
end;
|
2010-03-06 09:23:24 -05:00
|
|
|
{$endif}
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
//{$ENDIF}
|
|
|
|
|
|
|
|
procedure TForm1.RunScript;
|
|
|
|
begin
|
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
if ScriptState = ss_Paused then
|
|
|
|
begin;
|
|
|
|
ScriptThread.Resume;
|
|
|
|
ScriptState := ss_Running;
|
|
|
|
Exit;
|
|
|
|
end else
|
|
|
|
if ScriptState <> ss_None then
|
|
|
|
begin;
|
2010-03-07 10:57:10 -05:00
|
|
|
FormWritelnEx('The script hasn''t stopped yet, so we cannot start a new one.');
|
2010-01-25 08:59:44 -05:00
|
|
|
exit;
|
|
|
|
end;
|
2010-02-07 17:57:08 -05:00
|
|
|
InitalizeTMThread(scriptthread);
|
|
|
|
ScriptThread.CompileOnly:= false;
|
2010-01-25 08:59:44 -05:00
|
|
|
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
|
|
|
|
ScriptState:= ss_Running;
|
|
|
|
FirstRun := false;
|
|
|
|
//Lets run it!
|
|
|
|
ScriptThread.Resume;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PauseScript;
|
|
|
|
begin
|
|
|
|
with CurrScript do
|
|
|
|
begin;
|
|
|
|
if ScriptState = ss_Running then
|
|
|
|
begin;
|
|
|
|
{$ifdef MSWindows}
|
|
|
|
ScriptThread.Suspended:= True;
|
|
|
|
ScriptState:= ss_Paused;
|
|
|
|
{$else}
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Linux users are screwed, no pause button for u!');
|
2010-01-25 08:59:44 -05:00
|
|
|
{$endif}
|
|
|
|
end else if ScriptState = ss_Paused then
|
|
|
|
begin;
|
|
|
|
ScriptThread.Resume;
|
|
|
|
ScriptState := ss_Running;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.StopScript;
|
|
|
|
begin
|
|
|
|
with CurrScript do
|
|
|
|
begin;
|
|
|
|
case ScriptState of
|
|
|
|
ss_Stopping:
|
|
|
|
begin //Terminate the thread the tough way.
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Terminating the Scriptthread');
|
|
|
|
mDebugLn('Exit code terminate: ' +inttostr(KillThread(ScriptThread.Handle)));
|
2010-01-25 08:59:44 -05:00
|
|
|
WaitForThreadTerminate(ScriptThread.Handle, 0);
|
|
|
|
ScriptThread.Free;
|
|
|
|
ScriptState := ss_None;
|
|
|
|
end;
|
|
|
|
ss_Running:
|
|
|
|
begin
|
2010-01-25 12:38:43 -05:00
|
|
|
ScriptThread.Terminate;
|
2010-01-25 08:59:44 -05:00
|
|
|
ScriptState := ss_Stopping;
|
|
|
|
end;
|
|
|
|
ss_Paused:
|
|
|
|
begin
|
|
|
|
ScriptThread.Resume;
|
2010-01-25 12:38:43 -05:00
|
|
|
ScriptThread.Terminate;
|
2010-01-25 08:59:44 -05:00
|
|
|
ScriptState:= ss_Stopping;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.AddTab;
|
|
|
|
var
|
|
|
|
Tab : TMufasaTab;
|
|
|
|
begin;
|
|
|
|
Tab := TMufasaTab.Create(Self.PageControl1);
|
|
|
|
Tabs.Add(Tab);
|
|
|
|
Tab.TabSheet.ImageIndex:= 8;
|
|
|
|
// Tab.TabSheet.OnContextPopup:= @TabPopup;
|
|
|
|
PageControl1.TabIndex:= Tabs.Count - 1;
|
|
|
|
RefreshTab;
|
|
|
|
if tabs.count > 1 then
|
|
|
|
begin;
|
|
|
|
TB_SaveAll.Enabled:= True;
|
|
|
|
MenuItemSaveAll.Enabled:= True;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.DeleteTab(TabIndex: integer; CloseLast : boolean; Silent : boolean = false) : boolean;
|
|
|
|
var
|
|
|
|
Tab : TMufasaTab;
|
|
|
|
OldIndex : integer;//So that we can switch back, if needed.
|
|
|
|
begin
|
|
|
|
if not Silent then
|
|
|
|
begin;
|
|
|
|
OldIndex := PageControl1.TabIndex;
|
|
|
|
if TabIndex = OldIndex then
|
|
|
|
begin;
|
|
|
|
if lowercase(LoadSettingDef('Settings/Tabs/OpenNextOnClose','False')) = 'false' then
|
|
|
|
OldIndex := LastTab //We are closing the 'current' tab, lets go back in history
|
|
|
|
else
|
|
|
|
OldIndex := Min(Tabs.Count - 1,OldIndex + 1);
|
|
|
|
end;
|
|
|
|
PageControl1.TabIndex:= TabIndex;
|
|
|
|
end;
|
|
|
|
//ScriptFrame now is now correct ;-D
|
|
|
|
result := CanExitOrOpen;
|
|
|
|
if not result then
|
|
|
|
exit;
|
|
|
|
Tab := TMufasaTab(Tabs[TabIndex]);
|
|
|
|
if (Tabs.Count = 1) and (not CloseLast) then
|
|
|
|
Tab.Clear
|
|
|
|
else
|
|
|
|
begin;
|
|
|
|
Tab.Free;
|
|
|
|
Tabs.Delete(TabIndex);
|
|
|
|
if not Silent then
|
|
|
|
begin;
|
|
|
|
if OldIndex > TabIndex then
|
|
|
|
PageControl1.TabIndex := OldIndex - 1
|
|
|
|
else if OldIndex < TabIndex then
|
|
|
|
PageControl1.TabIndex := OldIndex;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if tabs.count <= 1 then
|
|
|
|
begin;
|
|
|
|
TB_SaveAll.Enabled:= false;
|
|
|
|
MenuItemSaveAll.Enabled:= false;
|
|
|
|
end;
|
|
|
|
if not silent then
|
|
|
|
RefreshTab;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ClearTab(TabIndex: integer);
|
|
|
|
begin
|
|
|
|
TMufasaTab(Tabs[TabIndex]).Clear;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.CloseTabs(Exclude: integer = -1; Silent : boolean = false);
|
|
|
|
var
|
|
|
|
I : integer;
|
|
|
|
begin
|
|
|
|
for i := tabs.count - 1 downto 0 do
|
|
|
|
if i <> exclude then
|
|
|
|
if not DeleteTab(i,false,silent) then
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.SetEditActions;
|
|
|
|
procedure EditActions(Undo,Redo,Cut,Copy,Paste,Delete : boolean);
|
|
|
|
begin;
|
|
|
|
ActionUndo.Enabled:= Undo;
|
|
|
|
ActionRedo.Enabled:= Redo;
|
|
|
|
ActionCut.Enabled:= Cut;
|
|
|
|
ActionCopy.Enabled:= Copy;
|
|
|
|
ActionPaste.Enabled:= Paste;
|
|
|
|
ActionDelete.Enabled:= Delete;
|
|
|
|
{$ifdef UpdateEditButtons}
|
|
|
|
TT_Cut.Enabled:= Cut;
|
|
|
|
TT_Paste.Enabled:=Paste;
|
|
|
|
TT_Copy.enabled := Copy;
|
|
|
|
{$endif}
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
S: String;
|
|
|
|
B: Boolean;
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
begin
|
|
|
|
with CurrScript.SynEdit do
|
|
|
|
begin
|
|
|
|
EditActions(CanUndo,CanRedo,SelText <> '',SelText <> '',CanPaste,SelText <> '');
|
|
|
|
// B:= SelText <> '';
|
|
|
|
B := SelAvail;
|
|
|
|
PopupItemFind.Enabled:= B;
|
|
|
|
PopupItemReplace.Enabled:= B;
|
|
|
|
if(B)then
|
|
|
|
begin
|
|
|
|
s := SelText;
|
|
|
|
if(Length(S) > 13)then
|
|
|
|
S:= Format('"%s"', [Copy(S, 1, 10) + '...'])
|
|
|
|
else
|
|
|
|
S:= Format('"%s"', [S]);
|
|
|
|
PopupItemFind.Caption:= 'Find next: ' + S;
|
|
|
|
PopupItemReplace.Caption:= 'Replace: ' + S;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else if Memo1.Focused then
|
|
|
|
with Memo1 do
|
|
|
|
EditActions(CanUndo,False,SelText <>'',SelText <> '',True,SelText <> '')
|
|
|
|
else
|
|
|
|
EditActions(false,false,false,false,false,false);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.DoSearch(Next: boolean; HighlightAll : boolean);
|
|
|
|
var
|
|
|
|
Res : integer;
|
|
|
|
CurrPos : TPoint;
|
|
|
|
SearchOptions : TSynSearchOptions;
|
|
|
|
begin
|
|
|
|
SearchOptions:= [];
|
|
|
|
if CheckBoxMatchCase.Checked then
|
|
|
|
SearchOptions := [ssoMatchCase];
|
|
|
|
if SearchString = '' then
|
|
|
|
begin
|
|
|
|
res := -1;
|
|
|
|
CurrScript.Synedit.SetHighlightSearch('',[]);
|
|
|
|
// CurrScript.SynEdit.SelectionMode:=
|
|
|
|
// CurrScript.SynEdit.CaretXY := CurrScript.SynEdit.CaretXY;
|
|
|
|
CurrScript.SynEdit.LogicalCaretXY := SearchStart;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Searching: ' + SearchString);
|
2010-01-25 08:59:44 -05:00
|
|
|
if next then
|
|
|
|
CurrPos := CurrScript.SynEdit.LogicalCaretXY
|
|
|
|
else
|
|
|
|
CurrPos := SearchStart;
|
|
|
|
Res := CurrScript.SynEdit.SearchReplaceEx(SearchString,'',SearchOptions,CurrPos);
|
|
|
|
if res = 0 then
|
|
|
|
begin
|
2010-03-06 07:06:19 -05:00
|
|
|
res := CurrScript.SynEdit.SearchReplaceEx(SearchString,'',SearchOptions,Classes.Point(0,0));
|
2010-01-25 08:59:44 -05:00
|
|
|
if res > 0 then
|
|
|
|
begin;
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('End of document reached');
|
2010-01-25 08:59:44 -05:00
|
|
|
SearchStart.x := 0;
|
|
|
|
SearchStart.Y := CurrScript.SynEdit.LogicalCaretXY.y;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if res = 0 then
|
|
|
|
begin;
|
|
|
|
LabeledEditSearch.Color := 6711039;
|
|
|
|
LabeledEditSearch.Font.Color:= clWhite;
|
|
|
|
CurrScript.Synedit.SetHighlightSearch('',[]);
|
|
|
|
CurrScript.SynEdit.LogicalCaretXY := SearchStart;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
LabeledEditSearch.Color:= clWindow;
|
|
|
|
LabeledEditSearch.Font.Color:= clWindowText;
|
|
|
|
with CurrScript.SynEdit do
|
|
|
|
begin
|
|
|
|
HighlightAllColor.Background:= clYellow;
|
|
|
|
if HighlightAll then
|
|
|
|
SetHighlightSearch(SearchString,[])
|
|
|
|
else
|
|
|
|
SetHighlightSearch('',[]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.RefreshTab;
|
|
|
|
var
|
|
|
|
Tab : TMufasaTab;
|
|
|
|
Script : TScriptFrame;
|
|
|
|
NewTab : integer;
|
|
|
|
begin
|
|
|
|
if tabs.Count < 1 then
|
|
|
|
begin;
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Cannot refresh tab, since there are no tabs.');
|
2010-01-25 08:59:44 -05:00
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
NewTab := PageControl1.TabIndex;
|
|
|
|
Tab := TMufasaTab(Tabs[Newtab]);
|
|
|
|
Script := Tab.ScriptFrame;
|
|
|
|
Self.CurrScript := Script;
|
|
|
|
Self.CurrTab := Tab;
|
|
|
|
if Script.ScriptChanged then
|
|
|
|
begin;
|
|
|
|
Tab.TabSheet.Caption:= Script.ScriptName + '*';
|
|
|
|
Self.Caption := Format(WindowTitle,[Script.ScriptName + '*'])
|
|
|
|
end else
|
|
|
|
begin;
|
|
|
|
Tab.TabSheet.Caption:= Script.ScriptName;
|
|
|
|
Self.Caption := Format(WindowTitle,[Script.ScriptName]);
|
|
|
|
end;
|
|
|
|
StatusBar.Panels[Panel_ScriptName].Text:= Script.ScriptName;
|
|
|
|
StatusBar.Panels[Panel_ScriptPath].text:= Script.ScriptFile;
|
|
|
|
SetScriptState(Tab.ScriptFrame.FScriptState);//To set the buttons right
|
|
|
|
if Self.Showing then
|
|
|
|
if Tab.TabSheet.TabIndex = Self.PageControl1.TabIndex then
|
2010-03-07 10:57:10 -05:00
|
|
|
if CurrScript.SynEdit.CanFocus then
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
2010-01-25 08:59:44 -05:00
|
|
|
StopCodeCompletion;//To set the highlighting back to normal;
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
|
|
|
with CurrScript.SynEdit do
|
|
|
|
begin
|
|
|
|
SetHighlightSearch('',[]);
|
|
|
|
UseIncrementalColor:= false;
|
|
|
|
MarkupByClass[TSynEditMarkupHighlightAllCaret].TempEnable;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
LabeledEditSearch.SelLength:= 0;
|
|
|
|
LabeledEditSearch.Color:= clWindow;
|
|
|
|
LabeledEditSearch.Font.Color:= clWindowText;
|
|
|
|
//Set tha edit buttons right
|
|
|
|
SetEditActions;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.RefreshTabSender(sender: PtrInt);
|
|
|
|
begin
|
|
|
|
RefreshTab;
|
|
|
|
end;
|
|
|
|
|
2010-02-07 10:59:03 -05:00
|
|
|
procedure TForm1.CreateDefaultEnvironment;
|
|
|
|
var
|
2010-03-29 17:01:54 -04:00
|
|
|
PluginsPath,extensionsPath : string;
|
2010-02-07 10:59:03 -05:00
|
|
|
begin
|
|
|
|
CreateSetting('Settings/Updater/CheckForUpdates','True');
|
|
|
|
CreateSetting('Settings/Updater/CheckEveryXMinutes','30');
|
|
|
|
CreateSetting('Settings/Interpreter/UseCPascal', 'False');
|
|
|
|
CreateSetting('Settings/Fonts/LoadOnStartUp', 'True');
|
2010-03-29 17:01:54 -04:00
|
|
|
CreateSetting('Settings/Fonts/Version','-1');
|
2010-02-07 10:59:03 -05:00
|
|
|
CreateSetting('Settings/Tabs/OpenNextOnClose','False');
|
2010-02-13 11:56:46 -05:00
|
|
|
CreateSetting('Settings/Tabs/OpenScriptInNewTab','True');
|
2010-03-28 16:11:12 -04:00
|
|
|
CreateSetting('Settings/Tabs/CheckTabsBeforeOpen','True');
|
2010-02-07 10:59:03 -05:00
|
|
|
CreateSetting('Settings/ColourPicker/ShowHistoryOnPick', 'True');
|
2010-02-28 14:48:26 -05:00
|
|
|
CreateSetting('Settings/General/MaxRecentFiles','10');
|
|
|
|
CreateSetting('Settings/MainForm/NormalSize','739:555');
|
2010-03-06 07:06:19 -05:00
|
|
|
CreateSetting('Settings/FunctionList/ShowOnStart','True');
|
2010-03-31 15:40:53 -04:00
|
|
|
CreateSetting('Settings/CodeHints/ShowAutomatically','True');
|
2010-04-05 07:56:20 -04:00
|
|
|
CreateSetting('Settings/SourceEditor/LazColors','True');
|
|
|
|
CreateSetting('Settings/Extensions/FileExtension','sex');
|
2010-02-21 12:13:30 -05:00
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
CreateSetting('Settings/Updater/RemoteLink',SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF});
|
|
|
|
CreateSetting('Settings/Updater/RemoteVersionLink',SimbaURL + 'Version');
|
|
|
|
CreateSetting('Settings/Fonts/VersionLink', FontURL + 'Version');
|
|
|
|
CreateSetting('Settings/Fonts/UpdateLink', FontURL + 'Fonts.tar.bz2');
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
CreateSetting('Settings/News/URL', 'http://simba.villavu.com/bin/news');
|
|
|
|
|
2010-02-07 10:59:03 -05:00
|
|
|
{Creates the paths and returns the path}
|
|
|
|
PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS));
|
2010-03-22 17:21:08 -04:00
|
|
|
extensionsPath := CreateSetting('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS));
|
2010-03-31 18:22:46 -04:00
|
|
|
CreateSetting('Extensions/ExtensionCount','0');
|
2010-02-26 20:36:33 -05:00
|
|
|
CreateSetting('LastConfig/MainForm/Position','');
|
2010-02-28 14:48:26 -05:00
|
|
|
CreateSetting('LastConfig/MainForm/State','Normal');
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
CreateSetting('LastConfig/Console/Visible','True');
|
|
|
|
ShowConsole(True);
|
|
|
|
{$endif}
|
2010-02-07 10:59:03 -05:00
|
|
|
if not DirectoryExists(IncludePath) then
|
|
|
|
CreateDir(IncludePath);
|
|
|
|
if not DirectoryExists(FontPath) then
|
|
|
|
CreateDir(FontPath);
|
|
|
|
if not DirectoryExists(PluginsPath) then
|
|
|
|
CreateDir(PluginsPath);
|
2010-03-22 17:21:08 -04:00
|
|
|
if not DirectoryExists(extensionsPath) then
|
|
|
|
CreateDir(extensionsPath);
|
2010-04-16 10:09:01 -04:00
|
|
|
if not DirectoryExists(ExtPath) then
|
|
|
|
CreateDir(ExtPath);
|
|
|
|
if not DirectoryExists(ScriptDir) then
|
|
|
|
CreateDir(ScriptDir);
|
2010-02-26 20:36:33 -05:00
|
|
|
SettingsForm.SettingsTreeView.Items.GetFirstNode.Expand(false);
|
2010-02-07 10:59:03 -05:00
|
|
|
SettingsForm.SaveCurrent;
|
2010-03-22 17:21:08 -04:00
|
|
|
LoadFormSettings;
|
2010-03-29 17:01:54 -04:00
|
|
|
UpdateTimer.Interval:=25;
|
2010-02-07 10:59:03 -05:00
|
|
|
end;
|
|
|
|
|
2010-02-26 20:36:33 -05:00
|
|
|
procedure TForm1.LoadFormSettings;
|
|
|
|
var
|
2010-03-06 07:06:19 -05:00
|
|
|
str,str2 : string;
|
2010-02-26 20:36:33 -05:00
|
|
|
Data : TStringArray;
|
2010-03-22 17:21:08 -04:00
|
|
|
i,ii : integer;
|
2010-02-26 20:36:33 -05:00
|
|
|
begin
|
2010-04-14 12:12:06 -04:00
|
|
|
self.BeginFormUpdate;
|
2010-02-26 20:36:33 -05:00
|
|
|
str := LoadSettingDef('LastConfig/MainForm/Position','');
|
|
|
|
if str <> '' then
|
|
|
|
begin;
|
|
|
|
Data := Explode(':',str);
|
|
|
|
if length(Data) <> 4 then
|
|
|
|
Exit;
|
|
|
|
Self.Left:= StrToIntDef(Data[0],Self.Left);
|
|
|
|
Self.Top:= StrToIntDef(Data[1],self.top);
|
|
|
|
Self.Width:= StrToIntDef(Data[2],self.width);
|
|
|
|
Self.Height:= StrToIntDef(Data[3],self.height);
|
|
|
|
end;
|
2010-02-28 14:48:26 -05:00
|
|
|
str := lowercase(LoadSettingDef('LastConfig/MainForm/State','Normal'));
|
|
|
|
if str = 'maximized' then
|
|
|
|
self.windowstate := wsMaximized
|
|
|
|
else
|
|
|
|
// if str = 'normal' then
|
|
|
|
Self.WindowState := wsNormal;
|
2010-04-15 10:47:21 -04:00
|
|
|
if SettingExtists('LastConfig/MainForm/RecentFiles/Count') then
|
|
|
|
begin;
|
|
|
|
ii := StrToIntDef(LoadSettingDef('LastConfig/MainForm/RecentFiles/Count','-1'),-1);
|
|
|
|
for i := 0 to ii do
|
|
|
|
begin
|
|
|
|
str := LoadSettingDef('LastConfig/MainForm/RecentFiles/File' + inttostr(I),'');
|
|
|
|
if str <> '' then
|
|
|
|
AddRecentFile(str);
|
|
|
|
end;
|
2010-02-26 20:36:33 -05:00
|
|
|
end;
|
2010-03-06 07:06:19 -05:00
|
|
|
str := LowerCase(LoadSettingDef('Settings/FunctionList/ShowOnStart','True'));
|
|
|
|
str2 := lowercase(LoadSettingDef('LastConfig/MainForm/FunctionListShown',''));
|
|
|
|
if (str = 'true') or (str2 = 'true') then
|
|
|
|
FunctionListShown(True)
|
|
|
|
else
|
|
|
|
FunctionListShown(false);
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
str := LowerCase(LoadSettingDef('LastConfig/Console/Visible','True'));
|
|
|
|
if str = 'true' then
|
|
|
|
ShowConsole(True)
|
|
|
|
else
|
|
|
|
ShowConsole(false);
|
|
|
|
{$endif}
|
2010-04-14 12:12:06 -04:00
|
|
|
self.EndFormUpdate;
|
2010-02-26 20:36:33 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.SaveFormSettings;
|
|
|
|
var
|
|
|
|
Data : TStringArray;
|
2010-03-31 18:22:46 -04:00
|
|
|
path : string;
|
2010-02-26 20:36:33 -05:00
|
|
|
i : integer;
|
|
|
|
begin
|
|
|
|
with SettingsForm.Settings do
|
|
|
|
begin
|
2010-02-28 14:48:26 -05:00
|
|
|
if Self.WindowState = wsMaximized then
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/MainForm/State','maximized')
|
2010-02-28 14:48:26 -05:00
|
|
|
else
|
|
|
|
begin; //Only save the form position if its non maximized.
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/MainForm/State','normal');
|
2010-02-28 14:48:26 -05:00
|
|
|
Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]);
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/MainForm/Position', Implode(':',Data ));
|
2010-02-28 14:48:26 -05:00
|
|
|
end;
|
2010-04-15 10:47:21 -04:00
|
|
|
DeleteKey('LastConfig/MainForm/RecentFiles');
|
2010-02-26 20:36:33 -05:00
|
|
|
if RecentFiles.Count > 0 then
|
|
|
|
begin
|
2010-04-15 10:47:21 -04:00
|
|
|
SetSetting('LastConfig/MainForm/RecentFiles/Count',inttostr(RecentFiles.Count));
|
2010-02-26 20:36:33 -05:00
|
|
|
SetLength(data,RecentFiles.Count);
|
2010-04-15 10:47:21 -04:00
|
|
|
for i := 0 to RecentFiles.Count - 1 do
|
|
|
|
SetSetting('LastConfig/MainForm/RecentFiles/File'+inttostr(i),RecentFiles[i]);
|
|
|
|
end;
|
2010-03-06 07:06:19 -05:00
|
|
|
if MenuItemFunctionList.Checked then
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/MainForm/FunctionListShown','True')
|
2010-03-06 07:06:19 -05:00
|
|
|
else
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/MainForm/FunctionListShown','False');
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
if ConsoleVisible then
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/Console/Visible','True')
|
2010-03-07 10:57:10 -05:00
|
|
|
else
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('LastConfig/Console/Visible','false');
|
2010-03-07 10:57:10 -05:00
|
|
|
{$endif}
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('Extensions/ExtensionCount',inttostr(ExtManager.Extensions.Count));
|
|
|
|
for i := 0 to ExtManager.Extensions.Count-1 do
|
|
|
|
begin;
|
|
|
|
|
|
|
|
path :='Extensions/Extension' + inttostr(I);
|
|
|
|
SetSetting(Path + '/Path',TVirtualSimbaExtension(ExtManager.Extensions[i]).Filename);
|
|
|
|
SetSetting(Path + '/Enabled',BoolToStr(TVirtualSimbaExtension(ExtManager.Extensions[i]).Enabled,True));
|
|
|
|
end;
|
2010-02-26 20:36:33 -05:00
|
|
|
SaveToXML(SimbaSettingsFile);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
procedure TForm1.LoadExtensions;
|
|
|
|
var
|
|
|
|
extCount : integer;
|
|
|
|
function LoadExtension(Number : integer) : boolean;
|
|
|
|
var
|
|
|
|
Path : string;
|
|
|
|
ExtPath : string;
|
|
|
|
ExtEnabled : boolean;
|
|
|
|
begin;
|
|
|
|
result := false;
|
|
|
|
if (number < 0) or (number >= extCount) then
|
|
|
|
exit;
|
|
|
|
path := 'Extensions/Extension' + inttostr(number);
|
|
|
|
if SettingExtists(Path) = false then
|
|
|
|
exit;
|
|
|
|
ExtPath := LoadSettingDef(Path + '/Path','');
|
|
|
|
if ExtPath = '' then
|
|
|
|
exit;
|
|
|
|
ExtEnabled := StrToBoolDef(LoadSettingDef(Path + '/Enabled','false'),false);
|
|
|
|
if ExtManager.LoadPSExtension(ExtPath,ExtEnabled) = false then
|
|
|
|
exit;
|
|
|
|
Result := true;
|
|
|
|
end;
|
|
|
|
procedure DeleteExtension(number : integer);
|
|
|
|
var
|
|
|
|
i : integer;
|
|
|
|
path : string;
|
|
|
|
begin;
|
|
|
|
path := 'Extensions/Extension';
|
|
|
|
SettingsForm.Settings.DeleteKey(path + inttostr(number));
|
|
|
|
for i := number + 1 to extCount - 1 do
|
|
|
|
SettingsForm.Settings.RenameKey(path + inttostr(i),'Extension' + inttostr(i-1));
|
|
|
|
SetSetting('Extensions/ExtensionCount',inttostr(extCount - 1),true);
|
|
|
|
dec(extCount);
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
str,str2 : string;
|
|
|
|
i : integer;
|
|
|
|
begin
|
|
|
|
extCount := StrToIntDef(LoadSettingDef('Extensions/ExtensionCount/','0'),0);
|
|
|
|
for i := 0 to extCount - 1 do
|
|
|
|
while (i < extCount) and not LoadExtension(i) do
|
|
|
|
DeleteExtension(i);
|
|
|
|
SetSetting('Extensions/ExtensionCount',inttostr(extCount));
|
|
|
|
str := LoadSettingDef('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS));
|
|
|
|
str2 := LoadSettingDef('Settings/Extensions/FileExtension','sex');
|
|
|
|
ExtManager.LoadPSExtensionsDir(str,str2);
|
|
|
|
end;
|
|
|
|
|
2010-04-03 09:10:13 -04:00
|
|
|
procedure TForm1.AddRecentFile(const filename: string);
|
2010-02-26 20:36:33 -05:00
|
|
|
var
|
|
|
|
MaxRecentFiles : integer;
|
|
|
|
Len,i : integer;
|
|
|
|
begin
|
|
|
|
MaxRecentFiles:= StrToIntDef(LoadSettingDef('Settings/General/MaxRecentFiles','10'),10);
|
|
|
|
i := RecentFiles.IndexOf(filename);
|
|
|
|
if i <> -1 then
|
|
|
|
RecentFiles.Delete(i);
|
|
|
|
if RecentFiles.Count = MaxRecentFiles then
|
|
|
|
RecentFiles.Delete(0);
|
|
|
|
RecentFiles.Add(filename);
|
|
|
|
Len := RecentFiles.Count;
|
|
|
|
if len <> length(RecentFileItems) then //Not reached maximum yet, add those files!
|
|
|
|
begin
|
|
|
|
SetLength(RecentFileItems,len);
|
|
|
|
RecentFileItems[len-1] := TMenuItem.Create(MenuItemOpenRecent);
|
|
|
|
RecentFileItems[len-1].OnClick:=@RecentFileItemsClick;
|
|
|
|
MenuItemOpenRecent.Add(RecentFileItems[len-1]);
|
|
|
|
end;
|
|
|
|
for i := 0 to len - 1 do
|
|
|
|
RecentFileItems[len - 1-i].Caption:= ExtractFileName(RecentFiles[i]);
|
|
|
|
end;
|
|
|
|
|
2010-02-07 17:57:08 -05:00
|
|
|
procedure TForm1.InitalizeTMThread(var Thread: TMThread);
|
|
|
|
var
|
|
|
|
DbgImgInfo : TDbgImgInfo;
|
|
|
|
AppPath : string;
|
|
|
|
ScriptPath : string;
|
|
|
|
UseCPascal: String;
|
2010-04-07 08:01:26 -04:00
|
|
|
Script : string;
|
2010-03-25 08:37:52 -04:00
|
|
|
Se: TMMLSettingsSandbox;
|
2010-02-07 17:57:08 -05:00
|
|
|
loadFontsOnScriptStart: boolean;
|
2010-04-07 08:01:26 -04:00
|
|
|
Continue : boolean;
|
2010-02-07 17:57:08 -05:00
|
|
|
begin
|
2010-04-07 08:01:26 -04:00
|
|
|
Script :=CurrScript.SynEdit.Lines.Text;
|
|
|
|
if Assigned(OnScriptStart) then
|
|
|
|
begin
|
|
|
|
Continue := True;
|
|
|
|
OnScriptStart(Self,script,continue);
|
|
|
|
if not Continue then
|
|
|
|
exit;
|
|
|
|
end;
|
2010-02-07 17:57:08 -05:00
|
|
|
AppPath:= MainDir + DS;
|
|
|
|
CurrScript.ScriptErrorLine:= -1;
|
|
|
|
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
|
|
|
|
UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'False');
|
|
|
|
try
|
|
|
|
if lowercase(UseCPascal) = 'true' then
|
2010-04-05 07:56:20 -04:00
|
|
|
Thread := TCPThread.Create(True,@CurrentSyncInfo,PluginPath)
|
2010-02-07 17:57:08 -05:00
|
|
|
else
|
2010-04-05 07:56:20 -04:00
|
|
|
Thread := TPSThread.Create(True,@CurrentSyncInfo,PluginPath);
|
2010-02-07 17:57:08 -05:00
|
|
|
except
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Failed to initialise the library!');
|
2010-02-07 17:57:08 -05:00
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
{$IFNDEF TERMINALWRITELN}
|
|
|
|
Thread.SetDebug(@formWriteln);
|
2010-03-06 09:23:24 -05:00
|
|
|
Thread.SetDebugClear(@ClearDebug);
|
2010-02-07 17:57:08 -05:00
|
|
|
{$ENDIF}
|
2010-04-07 08:01:26 -04:00
|
|
|
Thread.SetScript(Script);
|
2010-02-07 17:57:08 -05:00
|
|
|
DbgImgInfo.DispSize := @DebugImgForm.DispSize;
|
|
|
|
DbgImgInfo.ShowForm := @DebugImgForm.ShowDebugImgForm;
|
|
|
|
DbgImgInfo.ToDrawBitmap:= @DebugImgForm.ToDrawBmp;
|
|
|
|
DbgImgInfo.DrawBitmap:= @DebugImgForm.DrawBitmap;
|
|
|
|
DbgImgInfo.GetDebugBitmap:= @DebugImgForm.GetDbgBmp;
|
|
|
|
DbgImgInfo.GetBitmap:= @DebugImgForm.GetDebugImage;
|
|
|
|
Thread.SetDbgImg(DbgImgInfo);
|
|
|
|
Thread.ErrorData:= @CurrScript.ErrorData;
|
|
|
|
Thread.OnError:= @CurrScript.HandleErrorData;
|
|
|
|
|
|
|
|
if CurrScript.ScriptFile <> '' then
|
2010-02-26 11:59:05 -05:00
|
|
|
ScriptPath := IncludeTrailingPathDelimiter(ExtractFileDir(CurrScript.ScriptFile));
|
2010-02-07 17:57:08 -05:00
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
if DirectoryExists(PluginPath) then
|
|
|
|
PluginsGlob.AddPath(PluginPath);
|
2010-02-07 17:57:08 -05:00
|
|
|
if not DirectoryExists(IncludePath) then
|
|
|
|
if FirstRun then
|
2010-03-07 10:57:10 -05:00
|
|
|
FormWritelnEx('Warning: The include directory specified in the Settings isn''t valid.');
|
2010-02-07 17:57:08 -05:00
|
|
|
if not DirectoryExists(fontPath) then
|
|
|
|
if FirstRun then
|
2010-03-07 10:57:10 -05:00
|
|
|
FormWritelnEx('Warning: The font directory specified in the Settings isn''t valid. Can''t load fonts now');
|
2010-04-05 07:56:20 -04:00
|
|
|
Thread.SetPaths(ScriptPath,AppPath,Includepath,PluginPath,fontPath);
|
2010-02-07 17:57:08 -05:00
|
|
|
|
2010-04-30 17:25:26 -04:00
|
|
|
if selector.haspicked then
|
|
|
|
Thread.Client.IOManager.SetTarget(Selector.LastPick);
|
2010-02-07 17:57:08 -05:00
|
|
|
|
|
|
|
loadFontsOnScriptStart := (lowercase(LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True')) = 'true');
|
|
|
|
// Copy our current fonts
|
|
|
|
if not assigned(Self.OCR_Fonts) and loadFontsOnScriptStart and DirectoryExists(fontPath) then
|
|
|
|
begin
|
|
|
|
Self.OCR_Fonts := TMOCR.Create(Thread.Client);
|
|
|
|
OCR_Fonts.InitTOCR(fontPath);
|
2010-04-04 18:35:49 -04:00
|
|
|
Thread.Client.MOCR.Fonts := OCR_Fonts.Fonts
|
2010-02-07 17:57:08 -05:00
|
|
|
end else
|
|
|
|
if assigned(Self.OCR_Fonts) and loadFontsOnScriptStart then
|
2010-04-04 18:35:49 -04:00
|
|
|
Thread.Client.MOCR.Fonts := OCR_Fonts.Fonts;
|
2010-02-07 17:57:08 -05:00
|
|
|
|
2010-03-25 08:37:52 -04:00
|
|
|
Se := TMMLSettingsSandbox.Create(SettingsForm.Settings);
|
2010-03-31 18:22:46 -04:00
|
|
|
Se.Prefix := 'Scripts/';
|
2010-03-25 08:37:52 -04:00
|
|
|
Thread.SetSettings(Se);
|
2010-04-07 08:01:26 -04:00
|
|
|
Thread.OpenConnectionEvent:=@ThreadOpenConnectionEvent;
|
|
|
|
Thread.WriteFileEvent:=@ThreadWriteFileEvent;
|
|
|
|
Thread.OpenFileEvent:=@ThreadOpenFileEvent;
|
2010-02-07 17:57:08 -05:00
|
|
|
end;
|
|
|
|
|
2010-02-13 11:56:46 -05:00
|
|
|
procedure TForm1.HandleParameters;
|
|
|
|
var
|
|
|
|
DoRun : Boolean;
|
|
|
|
ErrorMsg : string;
|
|
|
|
begin
|
|
|
|
DoRun := false;
|
2010-05-09 16:50:52 -04:00
|
|
|
<<<<<<< HEAD
|
|
|
|
=======
|
2010-05-09 07:17:06 -04:00
|
|
|
// paramcount = 1 means we got only one parameter. We assume this to be a file.
|
|
|
|
// and try to open it accordingly
|
2010-05-09 16:50:52 -04:00
|
|
|
>>>>>>> c8103490d871d7f0c46c3bbf5d9a954a2be64c97
|
2010-05-09 08:34:40 -04:00
|
|
|
if (Paramcount = 1) and not (Application.HasOption('open')) then
|
2010-02-13 11:56:46 -05:00
|
|
|
begin
|
2010-05-09 07:17:06 -04:00
|
|
|
writeln('Opening file: ' + ParamStr(1));
|
2010-02-13 11:56:46 -05:00
|
|
|
if FileExists(ParamStr(1)) then
|
2010-05-09 07:17:06 -04:00
|
|
|
begin
|
2010-02-13 11:56:46 -05:00
|
|
|
LoadScriptFile(paramstr(1));
|
2010-05-09 07:17:06 -04:00
|
|
|
end;
|
2010-02-13 11:56:46 -05:00
|
|
|
end else
|
2010-05-09 16:50:52 -04:00
|
|
|
<<<<<<< HEAD
|
2010-02-13 11:56:46 -05:00
|
|
|
begin;
|
2010-05-09 08:34:40 -04:00
|
|
|
ErrorMsg:=Application.CheckOptions('ro:',['run','open:']);
|
2010-05-09 16:50:52 -04:00
|
|
|
=======
|
2010-05-09 07:17:06 -04:00
|
|
|
// we have more parameters. Check for specific options. (-r -o, --run --open)
|
|
|
|
begin
|
|
|
|
ErrorMsg:=Application.CheckOptions('ro:',['run', 'open:']);
|
2010-05-09 16:50:52 -04:00
|
|
|
>>>>>>> c8103490d871d7f0c46c3bbf5d9a954a2be64c97
|
2010-02-13 11:56:46 -05:00
|
|
|
if ErrorMsg <> '' then
|
2010-05-09 07:17:06 -04:00
|
|
|
begin
|
|
|
|
mDebugLn('ERROR IN COMMAND LINE ARGS: ' + ErrorMSG)
|
|
|
|
end else
|
2010-02-13 11:56:46 -05:00
|
|
|
begin
|
|
|
|
if Application.HasOption('o','open') then
|
2010-05-09 07:17:06 -04:00
|
|
|
begin
|
|
|
|
writeln('Opening file: ' + Application.GetOptionValue('o','open'));
|
2010-02-13 11:56:46 -05:00
|
|
|
LoadScriptFile(Application.GetOptionValue('o','open'));
|
|
|
|
DoRun:= Application.HasOption('r','run');
|
2010-05-09 07:17:06 -04:00
|
|
|
end else
|
|
|
|
// no valid options
|
|
|
|
begin
|
|
|
|
writeln('No valid command line args are passed');
|
2010-02-13 11:56:46 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if DoRun then
|
|
|
|
Self.RunScript;
|
|
|
|
end;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure TForm1.OnSaveScript(const Filename: string);
|
|
|
|
begin
|
|
|
|
with CurrScript do
|
|
|
|
begin
|
2010-03-28 16:11:12 -04:00
|
|
|
ScriptFile:= SetDirSeparators(Filename);
|
2010-04-03 08:05:15 -04:00
|
|
|
ScriptName:= ExtractFileNameOnly(ScriptFile);
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Script name will be: ' + ScriptName);
|
2010-04-03 08:05:15 -04:00
|
|
|
FormWritelnEx('Succesfully saved: ' + ScriptFile);
|
2010-03-07 10:57:10 -05:00
|
|
|
StartText:= SynEdit.Lines.Text;
|
|
|
|
ScriptChanged := false;
|
|
|
|
SynEdit.MarkTextAsSaved;
|
|
|
|
Self.Caption:= Format(WindowTitle,[ScriptName]);
|
|
|
|
CurrTab.TabSheet.Caption:= ScriptName;
|
2010-04-03 08:05:15 -04:00
|
|
|
Self.AddRecentFile(ScriptFile);
|
2010-03-07 10:57:10 -05:00
|
|
|
StatusBar.Panels[Panel_ScriptName].Text:= ScriptName;
|
|
|
|
StatusBar.Panels[Panel_ScriptPath].text:= ScriptFile;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
procedure TForm1.ActionTabLastExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
CurrIndex : integer;
|
|
|
|
begin
|
|
|
|
CurrIndex := PageControl1.TabIndex;
|
|
|
|
if CurrIndex = 0 then
|
|
|
|
CurrIndex := Tabs.count - 1
|
|
|
|
else
|
|
|
|
Dec(CurrIndex);
|
|
|
|
PageControl1.TabIndex:= CurrIndex;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionCloseTabExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if(PageControl1.PageCount > 1)then
|
|
|
|
Self.DeleteTab(PageControl1.TabIndex,false)
|
|
|
|
else
|
|
|
|
Self.ClearScript; //DeleteTab would take care of this already, but yeah, it's neater this way.
|
|
|
|
end;
|
|
|
|
|
2010-01-31 07:29:33 -05:00
|
|
|
procedure TForm1.ActionCompileScriptExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
TempThread : TMThread;
|
|
|
|
begin
|
2010-02-07 17:57:08 -05:00
|
|
|
InitalizeTMThread(TempThread);
|
2010-01-31 07:29:33 -05:00
|
|
|
TempThread.CompileOnly:= true;
|
|
|
|
TempThread.Resume;
|
|
|
|
end;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure TForm1.ActionConsoleExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
{$ifdef mswindows}
|
|
|
|
ShowConsole(not ConsoleVisible);
|
|
|
|
{$endif}
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.ActionCopyExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.SynEdit.CopyToClipboard
|
|
|
|
else if Memo1.Focused then
|
2010-03-22 10:58:30 -04:00
|
|
|
Memo1.CopyToClipboard;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionCutExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.SynEdit.CutToClipboard
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.CutToClipboard;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionDeleteExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.SynEdit.ClearSelection
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.ClearSelection;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionExitExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.Close;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionFindNextExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DoSearch(true, false);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionFindstartExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if frmFunctionList.Focused or frmFunctionList.FunctionList.Focused or frmFunctionList.editSearchList.Focused then
|
|
|
|
begin
|
|
|
|
if frmFunctionList.editSearchList.CanFocus then
|
|
|
|
frmFunctionList.editSearchList.SetFocus;
|
|
|
|
end else
|
|
|
|
begin
|
|
|
|
SearchPanel.Visible:= true;
|
|
|
|
if LabeledEditSearch.CanFocus then
|
|
|
|
LabeledEditSearch.SetFocus;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionClearDebugExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Memo1.Clear;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionNewExecute(Sender: TObject);
|
|
|
|
begin
|
2010-02-13 11:56:46 -05:00
|
|
|
//Self.ClearScript;
|
|
|
|
Self.AddTab;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionNewTabExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.AddTab;
|
|
|
|
end;
|
|
|
|
|
2010-02-28 14:48:26 -05:00
|
|
|
procedure TForm1.ActionNormalSizeExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
SizeStr : string;
|
|
|
|
Data : TStringArray;
|
|
|
|
begin
|
|
|
|
SizeStr := LoadSettingDef('Settings/MainForm/NormalSize','739:555');
|
|
|
|
Data := Explode(':',SizeStr);
|
|
|
|
if length(Data) = 2 then
|
|
|
|
begin
|
|
|
|
Self.Width:= StrToIntDef(Data[0],739);
|
|
|
|
Self.Height:= StrToIntDef(Data[1],555);
|
|
|
|
end else
|
|
|
|
begin;
|
|
|
|
self.width := 739;
|
|
|
|
self.height := 555;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.ActionOpenExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.OpenScript;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionPasteExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.SynEdit.PasteFromClipboard
|
|
|
|
else if Memo1.Focused then
|
2010-01-28 18:34:03 -05:00
|
|
|
Memo1.PasteFromClipboard
|
|
|
|
else if LabeledEditSearch.Focused then
|
|
|
|
LabeledEditSearch.PasteFromClipboard
|
|
|
|
else if frmFunctionList.editSearchList.Focused then
|
|
|
|
frmFunctionList.editSearchList.PasteFromClipboard;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionPauseExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.PauseScript;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionRedoExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.Redo
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.Undo; //?
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionReplaceExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if(ScriptPopup.HandleAllocated)then
|
|
|
|
dlgReplace.FindText:= CurrScript.SynEdit.SelText;
|
|
|
|
dlgReplace.Execute;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionRunExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.RunScript;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionSaveAllExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
i : integer;
|
|
|
|
OldIndex : integer;
|
|
|
|
begin
|
|
|
|
OldIndex := PageControl1.TabIndex;
|
|
|
|
for i := 0 to Tabs.Count - 1 do
|
|
|
|
begin;
|
|
|
|
PageControl1.TabIndex:= i;
|
|
|
|
SaveCurrentScript;
|
|
|
|
end;
|
|
|
|
PageControl1.TabIndex:= oldindex;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionSaveAsExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.SaveCurrentScriptAs;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionSaveExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.SaveCurrentScript;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionSelectAllExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.SynEdit.SelectAll
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.SelectAll
|
|
|
|
else if LabeledEditSearch.Focused then
|
|
|
|
LabeledEditSearch.SelectAll;
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionStopExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.StopScript;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionTabNextExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
CurrIndex : integer;
|
|
|
|
begin
|
|
|
|
CurrIndex := PageControl1.TabIndex;
|
|
|
|
if CurrIndex = Tabs.count - 1 then
|
|
|
|
CurrIndex := 0
|
|
|
|
else
|
|
|
|
Inc(CurrIndex);
|
|
|
|
PageControl1.TabIndex:= CurrIndex;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionUndoExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.Undo
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.Undo;
|
|
|
|
end;
|
|
|
|
|
2010-02-05 09:50:49 -05:00
|
|
|
procedure TForm1.ChangeMouseStatus(Sender: TObject);
|
|
|
|
var
|
|
|
|
x, y: Integer;
|
|
|
|
begin
|
2010-04-11 18:02:28 -04:00
|
|
|
if Self.Manager.TargetValid = false then
|
|
|
|
self.Manager.SetDesktop;
|
2010-02-05 09:50:49 -05:00
|
|
|
Self.Manager.GetMousePos(x, y);
|
2010-02-23 12:17:50 -05:00
|
|
|
if self.Manager.ReceivedError() then
|
|
|
|
begin
|
2010-03-07 10:57:10 -05:00
|
|
|
FormWritelnEx('Our window no longer exists -> Resetting to desktop');
|
2010-02-23 12:17:50 -05:00
|
|
|
self.Manager.SetDesktop;
|
2010-02-23 12:48:55 -05:00
|
|
|
self.Manager.ResetError;
|
2010-02-23 12:17:50 -05:00
|
|
|
end;
|
2010-02-05 09:50:49 -05:00
|
|
|
StatusBar.Panels[Panel_Coords].Text := Format('(%d, %d)', [x, y]);
|
|
|
|
end;
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
procedure TForm1.CheckBoxMatchCaseClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
RefreshTab;
|
|
|
|
CurrScript.SynEdit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempDisable;
|
|
|
|
SearchString := LabeledEditSearch.Text;
|
|
|
|
DoSearch(false, true);
|
|
|
|
CurrScript.SynEdit.UseIncrementalColor:= true;
|
|
|
|
LabeledEditSearch.SetFocus;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure TForm1.CloseFindPanel;
|
|
|
|
begin
|
|
|
|
SearchPanel.Visible:= false;
|
|
|
|
if CurrScript.SynEdit.CanFocus then
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
|
|
|
end;
|
|
|
|
|
2010-04-29 13:01:20 -04:00
|
|
|
{
|
|
|
|
If we are being sent to the background; then minimize other active windows as
|
|
|
|
well.
|
|
|
|
}
|
|
|
|
procedure TForm1.doOnHide(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if DebugImgForm.Visible then
|
|
|
|
DebugImgForm.Hide;
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.StopCodeCompletion;
|
|
|
|
begin
|
2010-03-26 16:34:41 -04:00
|
|
|
CodeCompletionForm.Hide;
|
2010-01-25 08:59:44 -05:00
|
|
|
if frmFunctionList.InCodeCompletion then
|
|
|
|
with CurrScript,frmFunctionList do
|
|
|
|
begin;
|
|
|
|
editSearchList.Color:= clWhite;
|
|
|
|
if FilterTree.Focused then
|
|
|
|
begin;
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('This is currently not supported');
|
2010-01-25 08:59:44 -05:00
|
|
|
SynEdit.Lines[CompletionCaret.y - 1] := CompletionStart;
|
2010-03-06 07:06:19 -05:00
|
|
|
SynEdit.LogicalCaretXY:= Classes.point(CompletionCaret.x,CompletionCaret.y);
|
2010-01-25 08:59:44 -05:00
|
|
|
SynEdit.SelEnd:= SynEdit.SelStart;
|
|
|
|
end;
|
|
|
|
InCodeCompletion:= false;
|
|
|
|
SynEdit.SelectedColor.Style:= [];
|
|
|
|
SynEdit.SelectedColor.Foreground:= clHighlightText;
|
|
|
|
SynEdit.SelectedColor.Background:= clHighlight;
|
|
|
|
Synedit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempEnable;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-03-28 16:11:12 -04:00
|
|
|
function TForm1.FindTab(filename: string): integer;
|
|
|
|
var
|
|
|
|
i : integer;
|
|
|
|
begin
|
|
|
|
FileName := SetDirSeparators(filename);
|
|
|
|
for i := 0 to Form1.Tabs.Count - 1 do
|
|
|
|
{$ifdef MSWindows} //Case insensitive
|
|
|
|
if lowercase(TMufasaTab(Tabs[i]).ScriptFrame.ScriptFile) = lowercase(filename) then
|
|
|
|
{$else}
|
|
|
|
if TMufasaTab(Tabs[i]).ScriptFrame.ScriptFile = filename then
|
|
|
|
{$endif}
|
|
|
|
exit(i);
|
|
|
|
result := -1;
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.editSearchListExit(Sender: TObject);
|
|
|
|
begin
|
|
|
|
frmFunctionList.editSearchList.Color := clWhite;
|
|
|
|
StopCodeCompletion;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.editSearchListKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if key = vk_up then
|
|
|
|
begin
|
|
|
|
frmFunctionList.Find(True,true);
|
|
|
|
key := 0;
|
|
|
|
end else
|
|
|
|
if key = vk_down then
|
|
|
|
begin
|
|
|
|
frmFunctionList.Find(true);
|
|
|
|
key := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.editSearchListKeyPress(Sender: TObject; var Key: char);
|
|
|
|
var
|
|
|
|
linetext : string;
|
|
|
|
begin
|
|
|
|
if key = #13 then//enter
|
|
|
|
begin;
|
|
|
|
key := #0;
|
|
|
|
frmFunctionList.Find(True);
|
|
|
|
end else
|
|
|
|
if frmFunctionList.InCodeCompletion then
|
|
|
|
begin;
|
|
|
|
if key = #27 then//esc -> C'est error!
|
|
|
|
begin
|
|
|
|
key := #0;
|
|
|
|
StopCodeCompletion;
|
|
|
|
CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart;
|
2010-03-06 07:06:19 -05:00
|
|
|
CurrScript.SynEdit.LogicalCaretXY:= Classes.point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y);
|
2010-01-25 08:59:44 -05:00
|
|
|
CurrScript.SynEdit.SelEnd:= CurrScript.SynEdit.SelStart;
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
|
|
|
end else
|
|
|
|
if key in [' ',',','.','(',')'] then //on on these chars we will insert the function!
|
|
|
|
begin;
|
|
|
|
StopCodeCompletion;
|
|
|
|
linetext := CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1];
|
|
|
|
while (frmFunctionList.CompletionCaret.x <= length(linetext)) and (linetext[frmFunctionList.CompletionCaret.x] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
|
|
|
inc(frmFunctionList.CompletionCaret.x);
|
|
|
|
CurrScript.SynEdit.LogicalCaretXY:= frmFunctionList.CompletionCaret;
|
|
|
|
CurrScript.SynEdit.SelStart:= CurrScript.SynEdit.SelEnd;
|
|
|
|
CurrScript.SynEdit.ExecuteCommand(ecChar,key,nil);
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
|
|
|
key := #0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-03-03 12:56:05 -05:00
|
|
|
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
|
|
|
|
);
|
|
|
|
var
|
2010-03-04 17:55:50 -05:00
|
|
|
i : integer;
|
2010-03-03 12:56:05 -05:00
|
|
|
begin
|
|
|
|
if (length(FileNames) = 1) then
|
|
|
|
begin
|
|
|
|
LoadScriptFile(FileNames[0]); //One file saves us some work
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
if (length(FileNames) > 5) then //> 5 seems nice to me, cant imagine you want to open that many scripts on a regular base
|
2010-03-04 17:55:50 -05:00
|
|
|
case MessageDlg('Are you sure you want to open '+inttostr(length(filenames))+
|
|
|
|
' scripts?', mtConfirmation, mbYesNo, 0) of
|
|
|
|
IDNO: exit;
|
|
|
|
end;
|
2010-03-03 12:56:05 -05:00
|
|
|
{$IfDef WINDOWS}
|
|
|
|
//Fix for the really old Windows kernel bug which probably will never be fixed
|
|
|
|
for i := 1 to high(filenames) do
|
2010-03-04 17:55:50 -05:00
|
|
|
LoadScriptFile(FileNames[i],true);
|
|
|
|
LoadScriptFile(FileNames[0],true);
|
2010-03-03 12:56:05 -05:00
|
|
|
{$Else} //in this case its tolerable as Windows is the only OS with this bug
|
|
|
|
for i := 0 to high(filenames) do
|
2010-03-04 17:55:50 -05:00
|
|
|
LoadScriptFile(FileNames[i],true);
|
2010-03-03 12:56:05 -05:00
|
|
|
{$EndIf};
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode);
|
2010-02-07 10:59:03 -05:00
|
|
|
var
|
|
|
|
MethodInfo : TMethodInfo;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
if node = nil then
|
|
|
|
exit;
|
2010-03-28 16:11:12 -04:00
|
|
|
if Node.level = 0 then
|
|
|
|
StatusBar.Panels[Panel_ScriptPath].Text := 'Section: ' + Node.Text;
|
2010-03-28 14:02:57 -04:00
|
|
|
if (Node.Level > 0) and (Node.Data <> nil) then
|
2010-02-07 10:59:03 -05:00
|
|
|
begin
|
|
|
|
MethodInfo := PMethodInfo(node.Data)^;
|
|
|
|
StatusBar.Panels[Panel_ScriptPath].Text := MethodInfo.MethodStr;
|
|
|
|
end;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FunctionListEnter(Sender: TObject);
|
|
|
|
begin
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FunctionListExit(Sender: TObject);
|
|
|
|
begin
|
|
|
|
// StatusBar.Panels[2].Text:= '';
|
|
|
|
end;
|
|
|
|
|
2010-04-07 10:23:48 -04:00
|
|
|
procedure TForm1.FunctionListTimerTimer(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Self.Visible and (CurrScript <> nil) then
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
|
|
|
end;
|
|
|
|
|
2010-03-22 17:21:08 -04:00
|
|
|
procedure TForm1.MenuItemExtensionsClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ExtensionsForm.Show;
|
|
|
|
end;
|
|
|
|
|
2010-01-31 07:29:33 -05:00
|
|
|
procedure TForm1.MenuItemHandbookClick(Sender: TObject);
|
|
|
|
begin
|
2010-04-12 05:00:43 -04:00
|
|
|
OpenURL('http://wizzup.org/static/simba/doc/ps_handbook/');
|
2010-01-31 07:29:33 -05:00
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.MenuItemColourHistoryClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
MenuItemColourHistory.Checked := not ColourHistoryForm.Visible;
|
|
|
|
if MenuItemColourHistory.Checked then
|
|
|
|
ColourHistoryForm.Show
|
|
|
|
else
|
|
|
|
ColourHistoryForm.Hide;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.dlgReplaceFind(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SearchString := dlgReplace.FindText;
|
|
|
|
DoSearch(True, False);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.dlgReplaceReplace(Sender: TObject);
|
|
|
|
var
|
|
|
|
SOptions: TSynSearchOptions;
|
|
|
|
P: TPoint;
|
|
|
|
Y: Boolean;
|
|
|
|
Btns: TMsgDlgButtons;
|
|
|
|
|
|
|
|
procedure Replace;
|
|
|
|
begin
|
|
|
|
CurrScript.SynEdit.SearchReplaceEx(dlgReplace.FindText, dlgReplace.ReplaceText, SOptions + [ssoReplace], P);
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Y:= False;
|
|
|
|
SOptions:= [];
|
|
|
|
if(frMatchCase in dlgReplace.Options)then SOptions:= [ssoMatchCase];
|
|
|
|
if(frWholeWord in dlgReplace.Options)then SOptions+= [ssoWholeWord];
|
|
|
|
with CurrScript.SynEdit do
|
|
|
|
begin
|
|
|
|
Btns:= [mbYes, mbNo];
|
|
|
|
if(frReplaceAll in dlgReplace.Options)then Btns+= [mbYesToAll];
|
2010-03-06 07:06:19 -05:00
|
|
|
if(frEntireScope in dlgReplace.Options)then P:= Classes.Point(0, 0) else P:= CaretXY;
|
2010-01-25 08:59:44 -05:00
|
|
|
while SearchReplaceEx(dlgReplace.FindText, '', SOptions, P) > 0 do
|
|
|
|
begin
|
|
|
|
if(Y)then
|
|
|
|
Replace
|
|
|
|
else case MessageDlg('Replace', Format('Do you want to replace "%s" with "%s"?', [dlgReplace.FindText, dlgReplace.ReplaceText]), mtConfirmation, Btns, 0) of
|
|
|
|
mrYes: Replace;
|
|
|
|
mrYesToAll: begin
|
|
|
|
Replace;
|
|
|
|
Y:= True;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if(not(frReplaceAll in dlgReplace.Options))then exit;
|
|
|
|
P:= CaretXY;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.EditSearchChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SearchString :=LabeledEditSearch.Text;
|
|
|
|
DoSearch(false, true);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|
|
|
var
|
|
|
|
i : integer;
|
|
|
|
begin
|
2010-02-26 20:36:33 -05:00
|
|
|
Self.SaveFormSettings;
|
2010-01-25 08:59:44 -05:00
|
|
|
for i := Tabs.Count - 1 downto 0 do
|
|
|
|
if not DeleteTab(i,true) then
|
|
|
|
begin;
|
|
|
|
CloseAction := caNone;
|
2010-03-25 11:09:38 -04:00
|
|
|
exit;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
2010-04-07 10:23:48 -04:00
|
|
|
FunctionListTimer.Enabled:= false;
|
2010-03-25 11:09:38 -04:00
|
|
|
FreeAndNil(ExtManager);
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
2010-03-26 19:28:36 -04:00
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
procedure CCFillCore;
|
|
|
|
var
|
|
|
|
t: TMThread;
|
|
|
|
a: TPSScriptExtension;
|
|
|
|
b: TStringList;
|
|
|
|
ms: TMemoryStream;
|
|
|
|
begin
|
|
|
|
if form1.UpdatingFonts then
|
2010-03-26 19:28:36 -04:00
|
|
|
begin
|
2010-03-29 17:01:54 -04:00
|
|
|
mDebugLn('Updating the fonts, thus waiting a bit till we init the OCR.');
|
|
|
|
while form1.UpdatingFonts do
|
|
|
|
begin
|
|
|
|
if GetCurrentThreadId = MainThreadID then
|
|
|
|
Application.ProcessMessages;
|
|
|
|
sleep(25);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
form1.InitalizeTMThread(t);
|
|
|
|
KillThread(t.ThreadID);
|
|
|
|
if (t is TPSThread) then
|
|
|
|
try
|
|
|
|
a := TPSScriptExtension.Create(form1);
|
|
|
|
b := TStringList.Create;
|
|
|
|
ms := TMemoryStream.Create;
|
2010-03-26 19:28:36 -04:00
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
try
|
|
|
|
with TPSThread(t).PSScript do
|
|
|
|
begin
|
|
|
|
a.OnCompile := OnCompile;
|
|
|
|
a.OnCompImport := OnCompImport;
|
|
|
|
a.OnExecImport := OnExecImport;
|
2010-04-25 17:11:48 -04:00
|
|
|
a.Defines.Assign(Defines);
|
2010-03-29 17:01:54 -04:00
|
|
|
end;
|
|
|
|
a.GetValueDefs(b);
|
2010-03-28 05:38:06 -04:00
|
|
|
|
2010-04-25 17:11:48 -04:00
|
|
|
CoreDefines.AddStrings(a.Defines);
|
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
SetLength(CoreBuffer, 1);
|
|
|
|
CoreBuffer[0] := TCodeInsight.Create;
|
|
|
|
with CoreBuffer[0] do
|
|
|
|
begin
|
|
|
|
OnMessage := @form1.OnCCMessage;
|
|
|
|
b.SaveToStream(ms);
|
|
|
|
Run(ms, nil, -1, True);
|
2010-04-25 17:11:48 -04:00
|
|
|
FileName := '"PSCORE"';
|
2010-03-26 19:28:36 -04:00
|
|
|
end;
|
|
|
|
finally
|
2010-03-29 17:01:54 -04:00
|
|
|
b.Free;
|
|
|
|
a.Free;
|
2010-03-26 19:28:36 -04:00
|
|
|
end;
|
2010-03-29 17:01:54 -04:00
|
|
|
finally
|
|
|
|
//KillThread(t.ThreadID);
|
|
|
|
t.Free;
|
2010-03-26 19:28:36 -04:00
|
|
|
end;
|
2010-03-29 17:01:54 -04:00
|
|
|
end;
|
2010-03-26 19:28:36 -04:00
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
|
|
|
var
|
|
|
|
FillThread : TProcThread;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
2010-04-14 12:12:06 -04:00
|
|
|
self.BeginFormUpdate;
|
2010-01-25 08:59:44 -05:00
|
|
|
Randomize;
|
2010-02-26 13:25:42 -05:00
|
|
|
DecimalSeparator := '.';
|
2010-02-07 10:59:03 -05:00
|
|
|
MainDir:= ExtractFileDir(Application.ExeName);
|
2010-02-26 20:36:33 -05:00
|
|
|
RecentFiles := TStringList.Create;
|
2010-02-13 11:56:46 -05:00
|
|
|
SimbaSettingsFile := MainDir + DS + 'settings.xml';
|
2010-03-26 16:34:41 -04:00
|
|
|
|
|
|
|
//AutoCompletionStart := Point(-1, -1);
|
|
|
|
CodeCompletionForm := TAutoCompletePopup.Create(Self);
|
|
|
|
CodeCompletionForm.InsertProc := @OnCompleteCode;
|
|
|
|
|
2010-03-31 14:23:39 -04:00
|
|
|
ParamHint := TParamHint.Create(self);
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef MSWindows}
|
2010-03-22 10:58:30 -04:00
|
|
|
ConsoleVisible := True;
|
|
|
|
PrevWndProc := Windows.WNDPROC(GetWindowLong(self.handle,GWL_WNDPROC));
|
|
|
|
SetWindowLong(Self.Handle,GWL_WNDPROC,PtrInt(@WndCallback));
|
|
|
|
if not RegisterHotkey(Self.Handle,0,MOD_CONTROL or MOD_ALT,VK_S) then
|
|
|
|
mDebugLn('Unable to register ctrl + alt + s as global hotkey');
|
2010-03-07 10:57:10 -05:00
|
|
|
{$else}
|
|
|
|
TT_Console.Visible:= false;
|
|
|
|
{$endif}
|
2010-03-22 10:58:30 -04:00
|
|
|
InitmDebug;
|
2010-04-07 08:01:26 -04:00
|
|
|
|
|
|
|
Self.OnScriptStart:= @ScriptStartEvent;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
FillThread := TProcThread.Create;
|
2010-03-29 17:01:54 -04:00
|
|
|
FillThread.FreeOnTerminate:= True;
|
|
|
|
FillThread.NormalProc:= @CCFillCore;
|
|
|
|
UpdateTimer.OnTimer:= @UpdateTimerCheck;
|
|
|
|
Application.CreateForm(TSimbaUpdateForm, SimbaUpdateForm);
|
2010-02-13 11:56:46 -05:00
|
|
|
if FileExists(SimbaSettingsFile) then
|
2010-02-26 20:36:33 -05:00
|
|
|
begin
|
|
|
|
Application.CreateForm(TSettingsForm,SettingsForm);
|
|
|
|
Self.LoadFormSettings;
|
2010-03-29 17:01:54 -04:00
|
|
|
end else
|
|
|
|
begin
|
2010-02-07 10:59:03 -05:00
|
|
|
Application.CreateForm(TSettingsForm,SettingsForm);
|
|
|
|
Self.CreateDefaultEnvironment;
|
2010-03-29 17:01:54 -04:00
|
|
|
FillThread.StartWait:= 250;
|
2010-02-07 10:59:03 -05:00
|
|
|
end;
|
2010-03-29 17:01:54 -04:00
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
//Show close buttons @ tabs
|
|
|
|
PageControl1.Options:=PageControl1.Options+[nboShowCloseButtons];
|
|
|
|
PageControl1.OnCloseTabClicked:=ActionCloseTab.OnExecute;
|
|
|
|
Tabs := TList.Create;
|
|
|
|
AddTab;//Give it alteast 1 tab ;-).
|
|
|
|
Manager := TIOManager.Create; //No need to load plugins for the Global manager
|
|
|
|
Picker := TMColorPicker.Create(Manager);
|
2010-04-07 08:01:26 -04:00
|
|
|
Picker.OnPick:=@PickerPick;
|
2010-01-25 08:59:44 -05:00
|
|
|
Selector := TMWindowSelector.Create(Manager);
|
|
|
|
{ For writeln }
|
|
|
|
SetLength(DebugStream, 0);
|
|
|
|
DebugCriticalSection := syncobjs.TCriticalSection.Create;
|
|
|
|
{$ifdef mswindows}
|
|
|
|
DebugTimer.Enabled:= false;
|
|
|
|
{$endif}
|
|
|
|
Application.QueueAsyncCall(@RefreshTabSender,0);
|
|
|
|
{$ifdef mswindows}
|
|
|
|
if FileExists(Application.ExeName+'_old_') then
|
|
|
|
begin
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('We still have an out-dated exe file in the dir, lets remove!');
|
|
|
|
mDebugLn(format('Sucesfully deleted the file? %s',[BoolToStr(DeleteFile(PChar(Application.ExeName + '_old_')),true)]));
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
2010-03-07 10:57:10 -05:00
|
|
|
SetConsoleCtrlHandler(@ConsoleHandler,true);
|
2010-01-25 08:59:44 -05:00
|
|
|
{$endif}
|
|
|
|
frmFunctionList.OnEndDock:= @frmFunctionList.FrameEndDock;
|
|
|
|
FirstRun := true;//Our next run is the first run.
|
2010-02-13 11:56:46 -05:00
|
|
|
HandleParameters;
|
2010-03-07 10:57:10 -05:00
|
|
|
TT_Update.Visible:= false;
|
2010-03-26 19:28:36 -04:00
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
//Fill the codeinsight buffer
|
|
|
|
FillThread.Resume;
|
2010-04-05 07:56:20 -04:00
|
|
|
//Load the extensions
|
|
|
|
LoadExtensions;
|
2010-04-14 12:12:06 -04:00
|
|
|
self.EndFormUpdate;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FormDestroy(Sender: TObject);
|
|
|
|
var
|
|
|
|
i : integer;
|
|
|
|
begin
|
|
|
|
for i := Tabs.Count - 1 downto 0 do
|
|
|
|
TMufasaTab(Tabs[i]).Free;
|
2010-02-26 20:36:33 -05:00
|
|
|
for i := 0 to high(RecentFileItems) do
|
|
|
|
RecentFileItems[i].Free;
|
2010-03-25 11:09:38 -04:00
|
|
|
if ExtManager <> nil then
|
|
|
|
ExtManager.free;
|
2010-01-25 08:59:44 -05:00
|
|
|
Tabs.free;
|
|
|
|
Selector.Free;
|
|
|
|
Picker.Free;
|
|
|
|
Manager.Free;
|
|
|
|
PluginsGlob.Free;
|
|
|
|
SetLength(DebugStream, 0);
|
2010-02-26 20:36:33 -05:00
|
|
|
RecentFiles.Free;
|
2010-01-25 08:59:44 -05:00
|
|
|
DebugCriticalSection.Free;
|
2010-03-31 14:23:39 -04:00
|
|
|
ParamHint.Free;
|
2010-03-22 10:58:30 -04:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
if not UnRegisterHotkey(Self.Handle,0) then
|
|
|
|
mDebugLn('Unable to unregister ctrl + alt + s as global hotkey');
|
|
|
|
{$endif}
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FormShortCuts(var Msg: TLMKey; var Handled: Boolean);
|
|
|
|
begin
|
|
|
|
SetEditActions;
|
|
|
|
Handled := ActionList.IsShortCut(Msg);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure TForm1.LabeledEditSearchEnter(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SearchStart := CurrScript.SynEdit.LogicalCaretXY;
|
|
|
|
with CurrScript.SynEdit do
|
|
|
|
begin
|
|
|
|
UseIncrementalColor:= true;
|
|
|
|
MarkupByClass[TSynEditMarkupHighlightAllCaret].TempDisable
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.LabeledEditSearchExit(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if not CheckBoxMatchCase.MouseEntered then
|
|
|
|
RefreshTab;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.LabeledEditSearchKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if (ssCtrl in Shift) and (key = vk_f) then
|
|
|
|
begin;
|
|
|
|
LabeledEditSearch.SelectAll;
|
|
|
|
end else
|
|
|
|
if key = VK_ESCAPE then
|
|
|
|
begin
|
|
|
|
CloseFindPanel;
|
|
|
|
key := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.LabeledEditSearchKeyPress(Sender: TObject; var Key: char);
|
|
|
|
begin
|
|
|
|
if key = #13 then
|
|
|
|
begin;
|
|
|
|
SearchString:= LabeledEditSearch.Text;
|
|
|
|
DoSearch(true, true);
|
|
|
|
key := #0;
|
|
|
|
// LabeledEditSearch.SelStart:= Length(LabeledEditSearch.Text);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuEditClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SetEditActions;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemAboutClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
AboutForm.ShowModal;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemCloseTabsClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.CloseTabs;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemDebugImageClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
MenuItemDebugImage.Checked := not DebugImgForm.Visible;
|
|
|
|
if MenuItemDebugImage.Checked then
|
|
|
|
DebugImgForm.Show
|
|
|
|
else
|
|
|
|
DebugImgForm.Hide;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemExportHTMLClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
SynExporterHTML : TSynExporterHTML;
|
|
|
|
begin;
|
|
|
|
SynExporterHTML := TSynExporterHTML.Create(nil);
|
2010-04-05 07:56:20 -04:00
|
|
|
SynExporterHTML.Highlighter := CurrHighlighter;
|
2010-01-25 08:59:44 -05:00
|
|
|
SynExporterHTML.ExportAsText:= True;
|
|
|
|
with TSaveDialog.Create(nil) do
|
|
|
|
try
|
|
|
|
Filter:= 'HTML Files (*.html;*.htm)|*.html;*.htm|All files(*.*)|*.*';
|
|
|
|
Options:= [ofOverwritePrompt,ofEnableSizing];
|
|
|
|
DefaultExt:= 'html';
|
|
|
|
if Execute then
|
|
|
|
begin
|
|
|
|
if CurrScript.ScriptName <> '' then
|
|
|
|
SynExporterHTML.Title:= 'Simba - ' + CurrScript.ScriptName
|
|
|
|
else
|
|
|
|
SynExporterHTML.Title:= 'Cogat - Untitled';
|
|
|
|
SynExporterHTML.ExportAll(CurrScript.SynEdit.Lines);
|
|
|
|
SynExporterHTML.SaveToFile(FileName);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
free;
|
|
|
|
SynExporterHTML.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure formWritelnEx(S: String);
|
|
|
|
begin
|
|
|
|
Form1.Memo1.Lines.Add(s);
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
function GetMethodName( Decl : string; PlusNextChar : boolean) : string;
|
|
|
|
var
|
|
|
|
I : integer;
|
|
|
|
ii : integer;
|
|
|
|
begin;
|
|
|
|
I := pos(' ',Decl) + 1;
|
|
|
|
for ii := i to Length(decl) do
|
|
|
|
begin;
|
|
|
|
if (Decl[ii] = '(') or (Decl[ii] = ';') then
|
|
|
|
begin;
|
|
|
|
if PlusNextChar then
|
|
|
|
result := result + decl[ii];
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
if (Decl[ii] = ' ') or (Decl[ii] = ':') then
|
|
|
|
begin;
|
|
|
|
if PlusNextChar then
|
|
|
|
result := result + ' ';
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
result := result + decl[ii];
|
|
|
|
end;
|
|
|
|
//We made it out of the loop.. This is a method without ';' we might wanne add that!
|
|
|
|
if PlusNextChar then
|
|
|
|
result := result + ';';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuitemFillFunctionListClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Methods : TExpMethodArr;
|
|
|
|
LastSection : string;
|
|
|
|
Sections : TStringList;
|
2010-01-28 18:34:03 -05:00
|
|
|
Nodes : array of TTreeNode;
|
2010-01-25 08:59:44 -05:00
|
|
|
i : integer;
|
|
|
|
Index : integer;
|
|
|
|
TempNode : TTreeNode;
|
|
|
|
Temp2Node : TTreeNode;
|
|
|
|
Tree : TTreeView;
|
|
|
|
begin
|
2010-03-02 16:27:49 -05:00
|
|
|
SetLength(nodes,0);
|
2010-04-14 12:12:06 -04:00
|
|
|
frmFunctionList.FunctionList.BeginUpdate;
|
2010-01-25 08:59:44 -05:00
|
|
|
if frmFunctionList.FunctionList.Items.Count = 0 then
|
|
|
|
begin;
|
2010-01-25 12:38:43 -05:00
|
|
|
Methods := TMThread.GetExportedMethods;
|
2010-01-25 08:59:44 -05:00
|
|
|
Tree := frmFunctionList.FunctionList;
|
|
|
|
Tree.Items.Clear;
|
|
|
|
Sections := TStringList.Create;
|
|
|
|
LastSection := '';
|
|
|
|
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script');
|
2010-03-28 14:02:57 -04:00
|
|
|
frmFunctionList.IncludesNode := Tree.Items.Add(nil,'Includes');
|
2010-01-25 08:59:44 -05:00
|
|
|
for i := 0 to high(Methods) do
|
|
|
|
begin;
|
|
|
|
if Methods[i].Section <> LastSection then
|
|
|
|
begin;
|
|
|
|
LastSection := Methods[i].Section;
|
|
|
|
Index := Sections.IndexOf(LastSection);
|
|
|
|
if Index <> -1 then
|
2010-01-28 18:34:03 -05:00
|
|
|
TempNode := Nodes[index]
|
2010-01-25 08:59:44 -05:00
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempNode := Tree.Items.Add(nil,LastSection);
|
|
|
|
Sections.Add(LastSection);
|
2010-01-28 18:34:03 -05:00
|
|
|
setlength(nodes,length(nodes)+1);
|
|
|
|
nodes[high(nodes)] := tempNode;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false));
|
2010-02-07 10:59:03 -05:00
|
|
|
Temp2Node.Data := GetMem(SizeOf(TMethodInfo));
|
2010-03-29 12:24:21 -04:00
|
|
|
FillChar(PMethodInfo(Temp2Node.Data)^,SizeOf(TMethodInfo),0);
|
2010-02-07 10:59:03 -05:00
|
|
|
with PMethodInfo(Temp2Node.Data)^ do
|
|
|
|
begin
|
|
|
|
MethodStr:= strnew(PChar(Methods[i].FuncDecl));
|
|
|
|
BeginPos:= -1;
|
|
|
|
end;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
Sections.free;
|
|
|
|
end;
|
2010-04-14 12:12:06 -04:00
|
|
|
frmFunctionList.FunctionList.EndUpdate;
|
2010-03-06 07:06:19 -05:00
|
|
|
if CurrScript <> nil then
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemHideClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Self.Visible = false then
|
|
|
|
MenuItemShowClick(sender)
|
|
|
|
else
|
2010-04-21 11:10:40 -04:00
|
|
|
Self.Hide;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemReportBugClick(Sender: TObject);
|
|
|
|
begin
|
2010-02-11 19:15:48 -05:00
|
|
|
OpenURL('http://mufasa.villavu.com/mantis/bug_report_page.php');
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
2010-03-06 07:06:19 -05:00
|
|
|
procedure TForm1.MenuItemSettingsButtonClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SettingsForm.ShowModal;
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.MenuItemShowClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.Show;
|
|
|
|
Self.WindowState := wsNormal;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemTabCloseClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DeleteTab(PopupTab,false);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemTabCloseOthersClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
CloseTabs(PopupTab);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemFunctionListClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FunctionListShown(not MenuItemFunctionList.Checked);
|
|
|
|
end;
|
|
|
|
|
2010-04-15 18:30:19 -04:00
|
|
|
procedure TForm1.MTrayIconClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
self.Show;
|
|
|
|
if Self.CanFocus then
|
|
|
|
self.SetFocus;
|
|
|
|
end;
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
function TForm1.GetSimbaNews: String;
|
2010-02-21 12:13:29 -05:00
|
|
|
var
|
2010-03-29 17:01:54 -04:00
|
|
|
t: TDownloadThread;
|
2010-02-21 12:13:29 -05:00
|
|
|
begin
|
2010-04-18 11:14:19 -04:00
|
|
|
t := TDownloadThread.Create(LoadSettingDef('Settings/News/URL', 'http://simba.villavu.com/bin/news'),
|
|
|
|
@Result);
|
2010-02-21 12:13:29 -05:00
|
|
|
t.Resume;
|
|
|
|
while not t.done do
|
|
|
|
begin
|
|
|
|
Application.ProcessMessages;
|
|
|
|
Sleep(50);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
procedure TForm1.SetExtPath(const AValue: string);
|
|
|
|
begin
|
|
|
|
SetSetting('Settings/Extensions/Path',AValue,true);
|
|
|
|
end;
|
|
|
|
|
2010-02-21 12:13:29 -05:00
|
|
|
procedure TForm1.NewsTimerTimer(Sender: TObject);
|
|
|
|
var
|
|
|
|
s: String;
|
2010-02-21 14:36:35 -05:00
|
|
|
News : TStringList; {Need it for correct EOL stuff}
|
2010-02-21 12:13:29 -05:00
|
|
|
begin
|
|
|
|
NewsTimer.Enabled:=False;
|
|
|
|
s := GetSimbaNews;
|
2010-02-21 14:36:35 -05:00
|
|
|
News := TStringList.Create;
|
|
|
|
News.Text:= s;
|
|
|
|
Memo1.Lines.AddStrings(News);
|
2010-03-07 10:57:10 -05:00
|
|
|
Memo1.Lines.add('');
|
2010-02-21 14:36:35 -05:00
|
|
|
News.free;
|
2010-02-21 12:13:29 -05:00
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.OnLinePSScript(Sender: TObject);
|
|
|
|
begin
|
|
|
|
{$IFDEF ProcessMessages}
|
|
|
|
Application.ProcessMessages; //Don't think that this is neccesary though
|
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure TForm1.ButtonPickClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
c, x, y: Integer;
|
|
|
|
cobj: TColourPickerObject;
|
|
|
|
begin
|
|
|
|
Picker.Pick(c, x, y);
|
2010-03-06 07:06:19 -05:00
|
|
|
cobj := TColourPickerObject.Create(c, Classes.Point(x,y), '');
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
if lowercase(LoadSettingDef('Settings/ColourPicker/ShowHistoryOnPick', 'True')) = 'true' then
|
|
|
|
begin
|
|
|
|
ColourHistoryForm.AddColObj(cobj, true);
|
|
|
|
ColourHistoryForm.Show;
|
|
|
|
end;
|
2010-03-07 10:57:10 -05:00
|
|
|
FormWritelnEx('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TForm1.ButtonSelectorDown(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
|
|
|
Manager.SetTarget(Selector.Drag);
|
2010-03-07 10:57:10 -05:00
|
|
|
FormWritelnEx('New window: ' + IntToStr(Selector.LastPick));
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1Change(Sender: TObject);
|
|
|
|
begin
|
|
|
|
RefreshTab();
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ButtonTrayClick(Sender: TObject);
|
2010-03-18 19:48:50 -04:00
|
|
|
begin
|
2010-03-30 13:58:41 -04:00
|
|
|
self.hide;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean
|
|
|
|
);
|
|
|
|
begin
|
|
|
|
LastTab:= PageControl1.TabIndex;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
|
var Handled: Boolean);
|
|
|
|
begin
|
|
|
|
PopupTab := PageControl1.TabIndexAtClientPos(MousePos);
|
|
|
|
if PopupTab = -1 then
|
|
|
|
begin
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('We couldn''t find which tab you clicked on, closing the popup');
|
2010-01-25 08:59:44 -05:00
|
|
|
Handled := true;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1DragDrop(Sender, Source: TObject; X, Y: Integer);
|
|
|
|
var
|
|
|
|
NewPos : integer;
|
|
|
|
OldPos : integer;
|
|
|
|
begin
|
|
|
|
if sender <> PageControl1 then
|
|
|
|
exit;
|
2010-03-06 07:06:19 -05:00
|
|
|
NewPos := PageControl1.TabIndexAtClientPos(Classes.Point(x,y));
|
2010-01-25 08:59:44 -05:00
|
|
|
OldPos := PageControl1.TabIndex;
|
|
|
|
if (NewPos <> OldPos) and (NewPos <> -1) then
|
|
|
|
begin;
|
|
|
|
Tabs.Move(OldPos,NewPos);
|
|
|
|
PageControl1.Pages[OldPos].TabIndex:= NewPos;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1DragOver(Sender, Source: TObject; X, Y: Integer;
|
|
|
|
State: TDragState; var Accept: Boolean);
|
|
|
|
var
|
|
|
|
Pos: Integer;
|
|
|
|
begin
|
2010-03-06 07:06:19 -05:00
|
|
|
Pos := PageControl1.TabIndexAtClientPos(Classes.Point(x,y));
|
2010-01-25 08:59:44 -05:00
|
|
|
Accept := (Pos <> PageControl1.TabIndex) and (Pos <> -1);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1MouseDown(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
|
|
|
if(Button = mbLeft)then
|
|
|
|
begin
|
|
|
|
{$ifdef linux}
|
|
|
|
PageControl1.TabIndex := PageControl1.TabIndexAtClientPos(Point(x,y));
|
|
|
|
{$endif}
|
|
|
|
PageControl1.BeginDrag(false, 10);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
|
|
|
if(Button = mbMiddle) and (not(PageControl1.Dragging))then
|
2010-03-06 07:06:19 -05:00
|
|
|
if(PageControl1.TabIndexAtClientPos(Classes.Point(x,y)) <> -1)then
|
|
|
|
DeleteTab(PageControl1.TabIndexAtClientPos(Classes.Point(x,y)), False);
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure TForm1.PickerPick(Sender: TObject; const Colour, colourx,
|
|
|
|
coloury: integer);
|
|
|
|
var
|
|
|
|
Args : TVariantArray;
|
|
|
|
begin
|
|
|
|
SetLength(args,3);
|
|
|
|
Args[0] := Colour;
|
|
|
|
Args[1] := Colourx;
|
|
|
|
Args[2] := Coloury;
|
|
|
|
ExtManager.HandleHook(EventHooks[SExt_OnColourPick].HookName,Args);
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.PopupItemFindClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SearchString := CurrScript.SynEdit.SelText;
|
|
|
|
ActionFindNextExecute(ScriptPopup);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.GetScriptState: TScriptState;
|
|
|
|
begin
|
|
|
|
result := CurrScript.FScriptState;
|
|
|
|
end;
|
|
|
|
|
2010-03-31 15:40:53 -04:00
|
|
|
function TForm1.GetShowHintAuto: boolean;
|
|
|
|
begin
|
|
|
|
Result := LowerCase(LoadSettingDef('Settings/CodeHints/ShowAutomatically','True')) = 'true';
|
|
|
|
end;
|
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
procedure TForm1.SetFontPath(const AValue: String);
|
|
|
|
begin
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('Settings/Fonts/Path',AValue,true);
|
2010-03-29 17:01:54 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.GetFontPath: String;
|
|
|
|
begin
|
|
|
|
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+'Fonts' + DS)));
|
|
|
|
end;
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
function TForm1.GetExtPath: string;
|
|
|
|
begin
|
|
|
|
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Extensions/Path', ExpandFileName(MainDir+DS+'Extensions' + DS)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.GetHighlighter: TSynCustomHighlighter;
|
|
|
|
begin
|
|
|
|
if lowercase(LoadSettingDef('Settings/SourceEditor/LazColors','True')) = 'true' then
|
|
|
|
result := LazHighlighter
|
|
|
|
else
|
|
|
|
result := SCARHighlighter;
|
|
|
|
end;
|
|
|
|
|
2010-03-27 09:10:16 -04:00
|
|
|
function TForm1.GetIncludePath: String;
|
|
|
|
begin
|
|
|
|
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS)));
|
|
|
|
end;
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
function TForm1.GetPluginPath: string;
|
|
|
|
begin
|
|
|
|
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+DS+'Plugins' + DS)));
|
|
|
|
end;
|
|
|
|
|
2010-03-27 09:10:16 -04:00
|
|
|
procedure TForm1.SetIncludePath(const AValue: String);
|
|
|
|
begin
|
2010-03-31 18:22:46 -04:00
|
|
|
SetSetting('Settings/Includes/Path',AValue,true);
|
2010-03-27 09:10:16 -04:00
|
|
|
end;
|
|
|
|
|
2010-04-05 07:56:20 -04:00
|
|
|
procedure TForm1.SetPluginPath(const AValue: string);
|
|
|
|
begin
|
|
|
|
SetSetting('Settings/Plugins/Path',AValue,true);
|
|
|
|
end;
|
|
|
|
|
2010-04-16 10:09:01 -04:00
|
|
|
procedure TForm1.SetScriptPath(const AValue: string);
|
|
|
|
begin
|
|
|
|
SetSetting('Settings/Scripts/Path',AValue,True);
|
|
|
|
end;
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.SetScriptState(const State: TScriptState);
|
|
|
|
begin
|
|
|
|
CurrScript.FScriptState:= State;
|
|
|
|
with Self.StatusBar.panels[Panel_State] do
|
|
|
|
case state of
|
|
|
|
ss_Running : begin Text := 'Running'; TB_Run.Enabled:= False; {$ifdef MSWindows}TB_Pause.Enabled:= True; {$endif}
|
|
|
|
TB_Stop.ImageIndex := Image_Stop; TB_Stop.Enabled:= True;
|
|
|
|
TrayPlay.Checked := True; TrayPlay.Enabled := False; {$ifdef MSWindows}TrayPause.Checked := false; TrayPause.Enabled := True;{$endif}
|
|
|
|
TrayStop.Enabled:= True; TrayStop.Checked:= False;
|
|
|
|
end;
|
|
|
|
ss_Paused : begin Text := 'Paused'; TB_Run.Enabled:= True; {$ifdef MSWindows}TB_Pause.Enabled:= True; {$endif}
|
|
|
|
TB_Stop.ImageIndex := Image_Stop; TB_Stop.Enabled:= True;
|
|
|
|
TrayPlay.Checked := false; TrayPlay.Enabled := True; {$ifdef MSWindows}TrayPause.Checked := True; TrayPause.Enabled := True;{$endif}
|
|
|
|
TrayStop.Enabled:= True; TrayStop.Checked:= False;
|
|
|
|
end;
|
|
|
|
ss_Stopping: begin Text := 'Stopping';TB_Run.Enabled:= False; TB_Pause.Enabled:= False; TB_Stop.Enabled:= True;
|
|
|
|
TB_Stop.ImageIndex := Image_Terminate;
|
|
|
|
TrayPlay.Checked := False; TrayPlay.Enabled := False; {$ifdef MSWindows}TrayPause.Checked := false; TrayPause.Enabled := False;{$endif}
|
|
|
|
TrayStop.Enabled:= True; TrayStop.Checked:= True;
|
|
|
|
end;
|
|
|
|
ss_None : begin Text := 'Done'; TB_Run.Enabled:= True; TB_Pause.Enabled:= False; TB_Stop.Enabled:= False;
|
|
|
|
TB_Stop.ImageIndex := Image_Stop;
|
|
|
|
TrayPlay.Checked := false; TrayPlay.Enabled := True; {$ifdef MSWindows}TrayPause.Checked := false; TrayPause.Enabled := False;{$endif}
|
|
|
|
TrayStop.Enabled:= false; TrayStop.Checked:= False;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-03 08:05:15 -04:00
|
|
|
function TForm1.LoadSettingDef(const Key,Def: string): string;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
2010-03-31 18:22:46 -04:00
|
|
|
result := SettingsForm.Settings.GetKeyValueDefLoad(Key,def,SimbaSettingsFile);
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
2010-04-03 08:05:15 -04:00
|
|
|
function TForm1.CreateSetting(const Key,Value: string): string;
|
2010-02-07 10:59:03 -05:00
|
|
|
begin
|
2010-03-31 18:22:46 -04:00
|
|
|
result := SettingsForm.Settings.GetKeyValueDef(Key,value);
|
2010-02-07 10:59:03 -05:00
|
|
|
end;
|
2010-03-29 17:01:54 -04:00
|
|
|
|
2010-04-03 08:05:15 -04:00
|
|
|
procedure TForm1.SetSetting(const key,Value: string; save : boolean);
|
2010-03-29 17:01:54 -04:00
|
|
|
begin
|
2010-03-31 18:22:46 -04:00
|
|
|
//Creates the setting if needed
|
|
|
|
SettingsForm.Settings.SetKeyValue(key,value);
|
|
|
|
if save then
|
2010-03-29 17:01:54 -04:00
|
|
|
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
|
2010-03-31 18:22:46 -04:00
|
|
|
end;
|
|
|
|
|
2010-04-03 08:05:15 -04:00
|
|
|
function TForm1.SettingExtists(const key: string): boolean;
|
2010-03-31 18:22:46 -04:00
|
|
|
begin
|
|
|
|
result :=SettingsForm.Settings.KeyExists(key);
|
2010-03-29 17:01:54 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FontUpdate;
|
2010-04-16 10:03:26 -04:00
|
|
|
procedure Idler;
|
|
|
|
begin
|
|
|
|
Application.ProcessMessages;
|
|
|
|
Sleep(25);
|
|
|
|
end;
|
|
|
|
|
2010-03-29 17:01:54 -04:00
|
|
|
var
|
|
|
|
CurrVersion : integer;
|
|
|
|
LatestVersion : integer;
|
|
|
|
FontDownload : TDownloadThread;
|
|
|
|
Stream : TStringStream;
|
2010-04-16 10:03:26 -04:00
|
|
|
UnTarrer : TUntarThread;
|
2010-04-18 11:14:19 -04:00
|
|
|
Fonts : string;
|
2010-04-16 10:03:26 -04:00
|
|
|
Decompress : TDecompressThread;
|
2010-03-29 17:01:54 -04:00
|
|
|
begin
|
|
|
|
if UpdatingFonts then
|
|
|
|
exit;
|
|
|
|
UpdatingFonts := True;
|
|
|
|
CurrVersion := StrToIntDef(LoadSettingDef('Settings/Fonts/Version','-1'),-1);
|
|
|
|
LatestVersion := SimbaUpdateForm.GetLatestFontVersion;
|
|
|
|
if LatestVersion > CurrVersion then
|
|
|
|
begin;
|
|
|
|
formWriteln(format('New fonts available. Current version: %d. Latest version: %d',[CurrVersion,LatestVersion]));
|
2010-04-18 11:14:19 -04:00
|
|
|
FontDownload := TDownloadThread.Create(LoadSettingDef('Settings/Fonts/UpdateLink',FontURL + 'Fonts.tar.bz2'),
|
|
|
|
@Fonts);
|
2010-03-29 17:01:54 -04:00
|
|
|
FontDownload.resume;
|
|
|
|
while FontDownload.Done = false do
|
2010-04-16 10:03:26 -04:00
|
|
|
Idler;
|
2010-04-18 11:14:19 -04:00
|
|
|
//Fontdownload is freed now
|
|
|
|
Stream := TStringStream.Create(Fonts);
|
2010-03-29 17:01:54 -04:00
|
|
|
try
|
2010-04-16 10:03:26 -04:00
|
|
|
Decompress := TDecompressThread.Create(Stream);
|
|
|
|
Decompress.Resume;
|
|
|
|
while Decompress.Finished = false do
|
|
|
|
Idler;
|
|
|
|
if Decompress.Result <> nil then
|
2010-03-29 17:01:54 -04:00
|
|
|
begin;
|
2010-04-16 10:03:26 -04:00
|
|
|
UnTarrer := TUntarThread.Create(Decompress.Result,FontPath,True);
|
|
|
|
UnTarrer.Resume;
|
|
|
|
while UnTarrer.Finished = false do
|
|
|
|
Idler;
|
|
|
|
if UnTarrer.Result then
|
|
|
|
begin;
|
|
|
|
FormWriteln('Succesfully installed the new fonts!');
|
|
|
|
SetSetting('Settings/Fonts/Version',IntToStr(LatestVersion),true);
|
|
|
|
if Assigned(self.OCR_Fonts) then
|
|
|
|
self.OCR_Fonts.Free;
|
|
|
|
Self.OCR_Fonts := TMOCR.Create(nil);
|
|
|
|
OCR_Fonts.InitTOCR(fontPath);
|
|
|
|
end;
|
|
|
|
UnTarrer.Free;
|
|
|
|
Decompress.Result.Free;
|
2010-03-29 17:01:54 -04:00
|
|
|
end;
|
2010-04-16 10:03:26 -04:00
|
|
|
Decompress.free;
|
2010-03-29 17:01:54 -04:00
|
|
|
finally
|
|
|
|
Stream.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
UpdatingFonts := False;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 08:01:26 -04:00
|
|
|
procedure TForm1.ScriptStartEvent(Sender: TObject; var Script: string;
|
|
|
|
var Continue: boolean);
|
|
|
|
begin
|
|
|
|
ScriptStartData.Sender:=Sender;
|
|
|
|
ScriptStartData.Script:= @Script;
|
|
|
|
ScriptStartData.Continue:= @Continue;
|
|
|
|
TThread.Synchronize(nil,@HandleScriptStartData);
|
|
|
|
end;
|
|
|
|
|
2010-03-31 15:40:53 -04:00
|
|
|
procedure TForm1.SetShowHintAuto(const AValue: boolean);
|
|
|
|
begin
|
|
|
|
SetSetting('Settings/CodeHints/ShowAutomatically',Booltostr(AValue,true));
|
|
|
|
end;
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
{$ifdef mswindows}
|
2010-03-22 10:58:30 -04:00
|
|
|
function GetConsoleWindow: HWND; stdcall; external kernel32 name 'GetConsoleWindow';
|
|
|
|
|
2010-03-07 10:57:10 -05:00
|
|
|
procedure TForm1.ShowConsole(ShowIt: boolean);
|
2010-03-22 10:58:30 -04:00
|
|
|
var
|
|
|
|
ProcessId : DWOrd;
|
2010-03-07 10:57:10 -05:00
|
|
|
begin
|
|
|
|
if ShowIt = ConsoleVisible then
|
|
|
|
Exit;
|
2010-03-22 10:58:30 -04:00
|
|
|
//Check if the console is ours (if it's not, do not hide it!!
|
|
|
|
GetWindowThreadProcessId(GetConsoleWindow,ProcessId);
|
|
|
|
if ProcessId = GetCurrentProcessId then
|
2010-03-07 10:57:10 -05:00
|
|
|
begin
|
2010-03-22 10:58:30 -04:00
|
|
|
if showit then
|
|
|
|
ShowWindow(GetConsoleWindow,SW_SHOWNA)
|
|
|
|
else
|
|
|
|
ShowWindow(GetConsoleWindow,sw_hide);
|
|
|
|
ConsoleVisible:= ShowIt;
|
2010-03-07 10:57:10 -05:00
|
|
|
end else
|
2010-03-22 10:58:30 -04:00
|
|
|
Writeln('You cannot hide the window, since its not created by Simba');
|
2010-03-07 10:57:10 -05:00
|
|
|
end;
|
|
|
|
{$endif}
|
|
|
|
|
2010-01-25 08:59:44 -05:00
|
|
|
procedure TForm1.FunctionListShown(ShowIt: boolean);
|
|
|
|
begin
|
|
|
|
with MenuItemFunctionList, frmFunctionList do
|
|
|
|
begin
|
|
|
|
Checked := ShowIt;
|
|
|
|
if(Checked)then
|
|
|
|
begin
|
|
|
|
if FunctionList.Items.Count = 0 then
|
|
|
|
MenuitemFillFunctionListClick(nil);
|
|
|
|
FrameEndDock(frmFunctionList,frmFunctionList.Parent,0,0);//Set the label correctly
|
|
|
|
if(frmFunctionList.Parent is TPanel)then
|
|
|
|
begin
|
|
|
|
SplitterFunctionList.Show;
|
|
|
|
frmFunctionList.Show;
|
|
|
|
end else frmFunctionList.Parent.Show;
|
|
|
|
if Self.Visible then
|
|
|
|
if editSearchList.CanFocus then
|
|
|
|
editSearchList.SetFocus;
|
|
|
|
//Lets load up this Script tree!
|
2010-03-06 07:06:19 -05:00
|
|
|
if CurrScript <> nil then
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.text);
|
2010-01-25 08:59:44 -05:00
|
|
|
end else begin
|
|
|
|
if(frmFunctionList.Parent is TPanel)then
|
|
|
|
frmFunctionList.Hide
|
|
|
|
else
|
|
|
|
frmFunctionList.Parent.Hide;
|
|
|
|
SplitterFunctionList.Hide;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TForm1.SafeCallThread;
|
2010-01-25 16:37:33 -05:00
|
|
|
var
|
|
|
|
thread: TMThread;
|
2010-04-11 15:42:42 -04:00
|
|
|
LocalCopy : TSyncInfo;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
2010-04-11 15:42:42 -04:00
|
|
|
LocalCopy := CurrentSyncInfo;
|
|
|
|
mDebugLn('Executing : ' + LocalCopy.MethodName);
|
|
|
|
thread:= TMThread(LocalCopy.OldThread);
|
2010-01-25 16:37:33 -05:00
|
|
|
mmlpsthread.CurrThread:= thread;
|
|
|
|
try
|
|
|
|
if thread is TPSThread then
|
|
|
|
begin
|
|
|
|
with TPSThread(thread).PSScript do
|
|
|
|
begin
|
|
|
|
OnLine:=@OnLinePSScript;
|
2010-04-11 15:42:42 -04:00
|
|
|
LocalCopy.Res^:= Exec.RunProcPVar(LocalCopy.V^,Exec.GetProc(LocalCopy.MethodName));
|
2010-01-25 16:37:33 -05:00
|
|
|
Online := nil;
|
|
|
|
end;
|
|
|
|
end else
|
|
|
|
begin
|
|
|
|
raise Exception.Create('ThreadSafeCall not implemented on this client');
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
mmlpsthread.CurrThread:= nil;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.OpenScript: boolean;
|
2010-02-13 11:56:46 -05:00
|
|
|
var
|
|
|
|
OpenInNewTab : boolean;
|
2010-01-25 16:37:33 -05:00
|
|
|
begin
|
2010-01-25 08:59:44 -05:00
|
|
|
Result := False;
|
2010-02-13 11:56:46 -05:00
|
|
|
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true');
|
|
|
|
if not OpenInNewTab then
|
|
|
|
if CanExitOrOpen = false then
|
|
|
|
Exit;
|
2010-01-25 08:59:44 -05:00
|
|
|
with TOpenDialog.Create(nil) do
|
|
|
|
try
|
2010-04-05 07:56:20 -04:00
|
|
|
Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+
|
|
|
|
'|Any files|*.*';
|
2010-01-25 08:59:44 -05:00
|
|
|
if Execute then
|
2010-02-13 11:56:46 -05:00
|
|
|
if FileExists(filename) then
|
|
|
|
result := LoadScriptFile(filename);
|
2010-01-25 08:59:44 -05:00
|
|
|
finally
|
|
|
|
Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-03-28 16:11:12 -04:00
|
|
|
function TForm1.LoadScriptFile(filename: string; AlwaysOpenInNewTab: boolean; CheckOtherTabs : boolean
|
2010-03-04 17:55:50 -05:00
|
|
|
): boolean;
|
2010-02-13 11:56:46 -05:00
|
|
|
var
|
|
|
|
OpenInNewTab : boolean;
|
2010-03-28 16:11:12 -04:00
|
|
|
CheckTabsFirst : boolean;
|
|
|
|
Tab : integer;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
2010-03-04 17:55:50 -05:00
|
|
|
if AlwaysOpenInNewTab then
|
|
|
|
OpenInNewTab := true
|
|
|
|
else
|
|
|
|
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true');
|
2010-03-28 16:11:12 -04:00
|
|
|
if CheckOtherTabs then
|
|
|
|
CheckTabsFirst := True
|
|
|
|
else
|
|
|
|
CheckTabsFirst := (Lowercase(LoadSettingDef('Settings/Tabs/CheckTabsBeforeOpen','True')) = 'true');
|
2010-01-25 08:59:44 -05:00
|
|
|
if FileExists(FileName) then
|
|
|
|
begin;
|
2010-03-28 16:11:12 -04:00
|
|
|
if CheckTabsFirst then
|
|
|
|
begin;
|
|
|
|
Tab := FindTab(filename);
|
|
|
|
if tab <> -1 then
|
|
|
|
begin
|
|
|
|
TMufasaTab(Tabs[tab]).ScriptFrame.MakeActiveScriptFrame;
|
|
|
|
exit(true);
|
|
|
|
end;
|
|
|
|
end;
|
2010-02-13 11:56:46 -05:00
|
|
|
if OpenInNewTab and (CurrScript.SynEdit.Text <> CurrScript.ScriptDefault) then //Add la tab!
|
|
|
|
self.addtab;
|
2010-01-25 08:59:44 -05:00
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
filename := SetDirSeparators(filename);
|
|
|
|
SynEdit.Lines.LoadFromFile(FileName);
|
|
|
|
StartText := SynEdit.Lines.text;
|
|
|
|
ScriptName:= ExtractFileNameOnly(filename);
|
2010-03-07 10:57:10 -05:00
|
|
|
mDebugLn('Script name will be: ' + ScriptName);
|
2010-04-07 10:23:48 -04:00
|
|
|
ScriptFile:= FileName;
|
2010-01-25 08:59:44 -05:00
|
|
|
ScriptChanged := false;
|
2010-02-26 20:36:33 -05:00
|
|
|
AddRecentFile(filename);
|
2010-01-25 08:59:44 -05:00
|
|
|
RefreshTab();
|
|
|
|
Result := True;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.SaveCurrentScript: boolean;
|
|
|
|
begin
|
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
Result := (ScriptFile <> '');
|
|
|
|
if Result then
|
2010-03-13 07:17:04 -05:00
|
|
|
begin
|
|
|
|
try
|
|
|
|
SynEdit.Lines.SaveToFile(ScriptFile);
|
|
|
|
except
|
|
|
|
mDebugLn('Cannot save the file. Try specifying a different location.');
|
|
|
|
result := SaveCurrentScriptAs;
|
|
|
|
exit;
|
|
|
|
end;
|
2010-03-07 10:57:10 -05:00
|
|
|
OnSaveScript(scriptfile);
|
2010-01-25 08:59:44 -05:00
|
|
|
end
|
|
|
|
else
|
|
|
|
result := SaveCurrentScriptAs;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.SaveCurrentScriptAs: boolean;
|
2010-03-07 10:57:10 -05:00
|
|
|
var
|
|
|
|
ScriptFile : string;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
2010-03-07 10:57:10 -05:00
|
|
|
Result := false;
|
|
|
|
with TSaveDialog.Create(nil) do
|
|
|
|
try
|
2010-04-05 07:56:20 -04:00
|
|
|
filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt;*.' +
|
|
|
|
LoadSettingDef('Settings/Extensions/FileExtension','sex')+
|
|
|
|
'|Any files|*.*';
|
2010-03-07 10:57:10 -05:00
|
|
|
if Execute then
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
2010-03-07 10:57:10 -05:00
|
|
|
if ExtractFileExt(FileName) = '' then
|
|
|
|
begin;
|
2010-04-05 07:56:20 -04:00
|
|
|
ScriptFile := FileName + '.simba';
|
2010-03-07 10:57:10 -05:00
|
|
|
end else
|
|
|
|
ScriptFile := FileName;
|
|
|
|
CurrScript.SynEdit.Lines.SaveToFile(ScriptFile);
|
|
|
|
OnSaveScript(scriptfile);
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
2010-03-07 10:57:10 -05:00
|
|
|
finally
|
|
|
|
free;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.CanExitOrOpen: boolean;
|
|
|
|
begin;
|
|
|
|
Self.Enabled := False;//We HAVE to answer the popup
|
|
|
|
Result := True;
|
|
|
|
if ScriptState <> ss_None then
|
|
|
|
begin
|
|
|
|
if ScriptState <> ss_Stopping then
|
|
|
|
begin
|
|
|
|
result := False;
|
|
|
|
case MessageDlg('Script is still running', 'Do you want to stop the script?',
|
|
|
|
mtConfirmation, mbYesNoCancel, 0) of
|
|
|
|
mrYes: StopScript;
|
|
|
|
end;
|
|
|
|
end else
|
|
|
|
case MessageDlg('Script is stopping.', 'Do you want to terminate the script?',
|
|
|
|
mtConfirmation, mbYesNoCancel, 0) of
|
|
|
|
mrNo, mrCancel: Result := false;
|
|
|
|
mrYes: StopScript;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if Result and (CurrScript.StartText <> CurrScript.SynEdit.Lines.text) then
|
|
|
|
begin
|
|
|
|
case MessageDlg('Script has been modified.', 'Do you want to save the script?',
|
|
|
|
mtConfirmation, mbYesNoCancel, 0) of
|
|
|
|
mrCancel : Result := False;
|
|
|
|
mrYes : Result := SaveCurrentScript;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
Self.Enabled := True;
|
|
|
|
if Self.CanFocus then
|
|
|
|
Self.SetFocus;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.ClearScript: boolean;
|
|
|
|
begin
|
2010-03-02 16:27:49 -05:00
|
|
|
result := false;
|
2010-01-25 08:59:44 -05:00
|
|
|
if CanExitOrOpen then
|
|
|
|
begin;
|
2010-03-02 16:27:49 -05:00
|
|
|
result := true;
|
2010-01-25 08:59:44 -05:00
|
|
|
CurrTab.Clear;
|
|
|
|
RefreshTab();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TMufasaTab }
|
|
|
|
|
|
|
|
procedure TMufasaTab.Clear;
|
|
|
|
begin
|
|
|
|
ScriptFrame.Free;
|
|
|
|
ScriptFrame := TScriptFrame.Create(Tabsheet);
|
|
|
|
ScriptFrame.Parent := Tabsheet;
|
|
|
|
ScriptFrame.Align:= alClient;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TMufasaTab.Create(Page: TPageControl);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
PageCtrl := Page;
|
|
|
|
Tabsheet := TTabSheet.Create(Page);
|
|
|
|
Tabsheet.PageControl := Page;
|
|
|
|
ScriptFrame := TScriptFrame.Create(Tabsheet);
|
|
|
|
ScriptFrame.Parent := Tabsheet;
|
|
|
|
ScriptFrame.Align := alClient;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TMufasaTab.Destroy;
|
|
|
|
begin
|
|
|
|
ScriptFrame.Free;
|
|
|
|
TabSheet.Free;
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
2010-04-07 08:44:55 -04:00
|
|
|
{$R *.lfm}
|
2010-01-25 08:59:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
end.
|