2009-10-12 11:04:52 -04:00
|
|
|
{
|
|
|
|
This file is part of the Mufasa Macro Library (MML)
|
2009-10-12 13:47:46 -04:00
|
|
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
2009-10-12 11:04:52 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
unit TestUnit;
|
|
|
|
|
2009-10-20 15:48:18 -04:00
|
|
|
{$Undef ProcessMessages} //Define this for processmessages in ThreadSafeCall
|
2009-09-04 00:26:56 -04:00
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2009-11-02 06:07:41 -05:00
|
|
|
{$ifdef linux}cthreads,{$endif}Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2009-09-25 15:29:03 -04:00
|
|
|
StdCtrls, Menus, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, SynMemo,
|
2009-09-22 16:55:15 -04:00
|
|
|
//Client,
|
|
|
|
MufasaTypes,
|
2009-11-07 07:44:09 -05:00
|
|
|
mmlpsthread,synedittypes,
|
2009-09-22 19:58:14 -04:00
|
|
|
window, // for the comp picker and selector
|
2009-11-03 12:23:34 -05:00
|
|
|
colourpicker, framescript, windowselector, lcltype, ActnList, StdActns,
|
2010-01-03 09:50:26 -05:00
|
|
|
SynExportHTML,
|
2009-11-03 12:23:34 -05:00
|
|
|
SynEditKeyCmds, SynEditHighlighter, SynEditMarkupSpecialLine,SynEditMarkupHighAll,
|
2009-12-24 06:04:53 -05:00
|
|
|
SynEditMiscClasses, LMessages, Buttons, PairSplitter,about, framefunctionlist,
|
2010-01-07 14:29:03 -05:00
|
|
|
ocr, updateform, simbasettings;
|
2009-09-04 00:26:56 -04:00
|
|
|
|
2010-01-07 19:34:58 -05:00
|
|
|
const
|
|
|
|
SimbaVersion = 386;
|
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
type
|
2009-10-31 17:44:13 -04:00
|
|
|
|
|
|
|
{ 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
|
2009-09-04 00:26:56 -04:00
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
2009-11-12 16:20:29 -05:00
|
|
|
ActionExit: TAction;
|
2009-11-07 23:45:26 -05:00
|
|
|
ActionReplace: TAction;
|
2009-11-07 07:44:09 -05:00
|
|
|
ActionFindNext: TAction;
|
2009-11-07 00:27:39 -05:00
|
|
|
ActionRedo: TAction;
|
|
|
|
ActionUndo: TAction;
|
|
|
|
ActionSelectAll: TAction;
|
|
|
|
ActionDelete: TAction;
|
|
|
|
ActionPaste: TAction;
|
|
|
|
ActionCopy: TAction;
|
|
|
|
ActionCut: TAction;
|
2009-11-04 15:05:35 -05:00
|
|
|
ActionFindStart: TAction;
|
2009-11-01 12:23:16 -05:00
|
|
|
ActionClearDebug: TAction;
|
2009-11-01 08:56:54 -05:00
|
|
|
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;
|
2009-11-07 07:44:09 -05:00
|
|
|
CheckBoxMatchCase: TCheckBox;
|
2009-12-24 03:18:24 -05:00
|
|
|
frmFunctionList: TFunctionListFrame;
|
2009-11-03 12:23:34 -05:00
|
|
|
LabeledEditSearch: TLabeledEdit;
|
2009-10-09 18:17:35 -04:00
|
|
|
Memo1: TMemo;
|
2009-10-17 13:57:09 -04:00
|
|
|
MenuFile: TMenuItem;
|
|
|
|
MenuEdit: TMenuItem;
|
2009-11-12 16:20:29 -05:00
|
|
|
MenuHelp: TMenuItem;
|
2009-12-24 11:21:31 -05:00
|
|
|
MenuExtra: TMenuItem;
|
2010-01-07 15:25:10 -05:00
|
|
|
MenuViewSettings: TMenuItem;
|
2010-01-03 09:50:26 -05:00
|
|
|
MenuItemExportHTML: TMenuItem;
|
|
|
|
MenuItemDivider9: TMenuItem;
|
2010-01-02 20:36:54 -05:00
|
|
|
UpdateTimer: TTimer;
|
|
|
|
ToolButton3: TToolButton;
|
|
|
|
UpdateButton: TToolButton;
|
2009-12-31 17:37:09 -05:00
|
|
|
UpdateMenuButton: TMenuItem;
|
2009-12-24 11:21:31 -05:00
|
|
|
MenuitemFillFunctionList: TMenuItem;
|
2009-12-23 20:20:17 -05:00
|
|
|
MenuItemFunctionList: TMenuItem;
|
2009-12-20 15:11:11 -05:00
|
|
|
MenuItemHide: TMenuItem;
|
2009-11-29 14:23:25 -05:00
|
|
|
MenuItemDebugImage: TMenuItem;
|
2009-11-12 16:20:29 -05:00
|
|
|
MenuItemAbout: TMenuItem;
|
|
|
|
MenuItemMainExit: TMenuItem;
|
|
|
|
MenuItemDivider6: TMenuItem;
|
2009-11-07 23:45:26 -05:00
|
|
|
PopupItemReplace: TMenuItem;
|
|
|
|
MenuItemReplace: TMenuItem;
|
|
|
|
dlgReplace: TReplaceDialog;
|
2009-11-12 16:20:29 -05:00
|
|
|
MenuItemColourHistory: TMenuItem;
|
|
|
|
MenuView: TMenuItem;
|
2009-11-07 07:44:09 -05:00
|
|
|
MenuItemFindNext: TMenuItem;
|
2009-11-07 00:27:39 -05:00
|
|
|
PopupItemDelete: TMenuItem;
|
|
|
|
MenuItemDelete: TMenuItem;
|
|
|
|
MenuItemDivider5: TMenuItem;
|
|
|
|
MenuItemSelectAll: TMenuItem;
|
|
|
|
PopupItemSelectAll: TMenuItem;
|
|
|
|
PopupItemDivider2: TMenuItem;
|
|
|
|
PopupItemPaste: TMenuItem;
|
|
|
|
PopupItemCopy: TMenuItem;
|
|
|
|
PopupItemCut: TMenuItem;
|
|
|
|
PopupItemDivider1: TMenuItem;
|
|
|
|
PopupItemRedo: TMenuItem;
|
|
|
|
PopupItemUndo: TMenuItem;
|
2009-11-07 15:26:26 -05:00
|
|
|
PopupItemDivider3: TMenuItem;
|
|
|
|
PopupItemFind: TMenuItem;
|
2009-11-03 12:23:34 -05:00
|
|
|
MenuItemFind: TMenuItem;
|
|
|
|
MenuItemDivider4: TMenuItem;
|
2009-11-01 23:10:32 -05:00
|
|
|
MenuItemDivider3: TMenuItem;
|
|
|
|
MenuItemCopy: TMenuItem;
|
2009-11-01 08:56:54 -05:00
|
|
|
MenuItemSaveAll: TMenuItem;
|
|
|
|
MenuItemTabCloseOthers: TMenuItem;
|
|
|
|
MenuItemTabAdd: TMenuItem;
|
|
|
|
MenuItemTabClose: TMenuItem;
|
|
|
|
MenuItemCloseTabs: TMenuItem;
|
|
|
|
MenuItemCloseTab: TMenuItem;
|
|
|
|
MenuItemNewTab: TMenuItem;
|
|
|
|
MenuItemDivider2: TMenuItem;
|
|
|
|
MenuItemDivider: TMenuItem;
|
2009-11-03 12:23:34 -05:00
|
|
|
PageControl1: TPageControl;
|
2009-11-07 00:27:39 -05:00
|
|
|
ScriptPopup: TPopupMenu;
|
2009-11-03 12:23:34 -05:00
|
|
|
SearchPanel: TPanel;
|
|
|
|
ScriptPanel: TPanel;
|
2009-11-07 07:44:09 -05:00
|
|
|
SpeedButtonSearch: TSpeedButton;
|
2010-01-03 14:27:09 -05:00
|
|
|
SplitterFunctionList: TSplitter;
|
2009-11-01 08:56:54 -05:00
|
|
|
TabPopup: TPopupMenu;
|
|
|
|
TB_SaveAll: TToolButton;
|
2009-11-04 17:41:06 -05:00
|
|
|
DebugTimer: TTimer;
|
2009-11-01 08:56:54 -05:00
|
|
|
TrayDivider: TMenuItem;
|
2009-10-31 19:31:51 -04:00
|
|
|
TrayPlay: TMenuItem;
|
|
|
|
TrayStop: TMenuItem;
|
|
|
|
TrayPause: TMenuItem;
|
2009-10-24 12:00:10 -04:00
|
|
|
MenuItemPause: TMenuItem;
|
|
|
|
MenuItemStop: TMenuItem;
|
2009-10-24 11:37:00 -04:00
|
|
|
MenuItemShow: TMenuItem;
|
|
|
|
MenuItemExit: TMenuItem;
|
2009-10-24 10:01:21 -04:00
|
|
|
MenuItemCut: TMenuItem;
|
|
|
|
MenuItemPaste: TMenuItem;
|
2009-10-17 13:57:09 -04:00
|
|
|
MenuItemNew: TMenuItem;
|
|
|
|
MenuItemSaveAs: TMenuItem;
|
|
|
|
MenuItemOpen: TMenuItem;
|
|
|
|
MenuItemRedo: TMenuItem;
|
|
|
|
MenuItemUndo: TMenuItem;
|
|
|
|
MenuItemSave: TMenuItem;
|
2009-09-22 16:55:15 -04:00
|
|
|
Mufasa_Image_List: TImageList;
|
2009-09-19 22:08:02 -04:00
|
|
|
MainMenu1: TMainMenu;
|
|
|
|
MenuItemScript: TMenuItem;
|
|
|
|
MenuItemRun: TMenuItem;
|
2009-10-25 07:01:28 -04:00
|
|
|
PanelMemo: TPanel;
|
|
|
|
SplitterMemoSynedit: TSplitter;
|
2009-10-24 11:37:00 -04:00
|
|
|
TrayPopup: TPopupMenu;
|
2009-10-17 13:57:09 -04:00
|
|
|
StatusBar: TStatusBar;
|
2009-09-22 16:55:15 -04:00
|
|
|
ToolBar1: TToolBar;
|
|
|
|
TB_Run: TToolButton;
|
|
|
|
TB_Pause: TToolButton;
|
|
|
|
TB_Stop: TToolButton;
|
|
|
|
ToolButton1: TToolButton;
|
|
|
|
TB_ReloadPlugins: TToolButton;
|
2009-09-25 15:29:03 -04:00
|
|
|
TB_Tray: TToolButton;
|
2009-09-22 16:55:15 -04:00
|
|
|
TB_NewTab: TToolButton;
|
|
|
|
TB_CloseTab: TToolButton;
|
2009-10-24 10:01:21 -04:00
|
|
|
TB_New: TToolButton;
|
|
|
|
ToolButton2: TToolButton;
|
|
|
|
TB_Open: TToolButton;
|
2009-10-25 07:01:28 -04:00
|
|
|
TB_Save: TToolButton;
|
2009-09-22 16:55:15 -04:00
|
|
|
ToolButton4: TToolButton;
|
|
|
|
TB_ClearDebug: TToolButton;
|
|
|
|
TB_PickColour: TToolButton;
|
|
|
|
TB_SelectClient: TToolButton;
|
|
|
|
ToolButton8: TToolButton;
|
2009-09-25 15:29:03 -04:00
|
|
|
MTrayIcon: TTrayIcon;
|
2009-11-01 12:23:16 -05:00
|
|
|
procedure ActionClearDebugExecute(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure ActionCloseTabExecute(Sender: TObject);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure ActionCopyExecute(Sender: TObject);
|
|
|
|
procedure ActionCutExecute(Sender: TObject);
|
|
|
|
procedure ActionDeleteExecute(Sender: TObject);
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure ActionExitExecute(Sender: TObject);
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure ActionFindNextExecute(Sender: TObject);
|
2009-11-04 15:05:35 -05:00
|
|
|
procedure ActionFindstartExecute(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure ActionNewExecute(Sender: TObject);
|
|
|
|
procedure ActionNewTabExecute(Sender: TObject);
|
|
|
|
procedure ActionOpenExecute(Sender: TObject);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure ActionPasteExecute(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure ActionPauseExecute(Sender: TObject);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure ActionRedoExecute(Sender: TObject);
|
2009-11-07 23:45:26 -05:00
|
|
|
procedure ActionReplaceExecute(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure ActionRunExecute(Sender: TObject);
|
|
|
|
procedure ActionSaveAllExecute(Sender: TObject);
|
|
|
|
procedure ActionSaveAsExecute(Sender: TObject);
|
|
|
|
procedure ActionSaveExecute(Sender: TObject);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure ActionSelectAllExecute(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure ActionStopExecute(Sender: TObject);
|
|
|
|
procedure ActionTabLastExecute(Sender: TObject);
|
|
|
|
procedure ActionTabNextExecute(Sender: TObject);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure ActionUndoExecute(Sender: TObject);
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure CheckBoxMatchCaseClick(Sender: TObject);
|
|
|
|
procedure CloseFindPanel;
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure editSearchListExit(Sender: TObject);
|
2010-01-03 14:27:09 -05:00
|
|
|
procedure editSearchListKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure editSearchListKeyPress(Sender: TObject; var Key: char);
|
|
|
|
procedure FunctionListChange(Sender: TObject; Node: TTreeNode);
|
2009-12-26 10:45:05 -05:00
|
|
|
procedure FunctionListEnter(Sender: TObject);
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure FunctionListExit(Sender: TObject);
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure MenuItemColourHistoryClick(Sender: TObject);
|
2009-11-07 23:45:26 -05:00
|
|
|
procedure dlgReplaceFind(Sender: TObject);
|
|
|
|
procedure dlgReplaceReplace(Sender: TObject);
|
2009-11-03 12:23:34 -05:00
|
|
|
procedure EditSearchChange(Sender: TObject);
|
2009-10-17 13:57:09 -04:00
|
|
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
2009-09-12 14:50:10 -04:00
|
|
|
procedure FormCreate(Sender: TObject);
|
2009-09-13 19:56:15 -04:00
|
|
|
procedure FormDestroy(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure FormShortCuts(var Msg: TLMKey; var Handled: Boolean);
|
2009-11-04 15:05:35 -05:00
|
|
|
procedure LabeledEditSearchEnter(Sender: TObject);
|
|
|
|
procedure LabeledEditSearchExit(Sender: TObject);
|
|
|
|
procedure LabeledEditSearchKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
|
|
|
procedure LabeledEditSearchKeyPress(Sender: TObject; var Key: char);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure MenuEditClick(Sender: TObject);
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure MenuItemAboutClick(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure MenuItemCloseTabsClick(Sender: TObject);
|
2009-11-29 14:23:25 -05:00
|
|
|
procedure MenuItemDebugImageClick(Sender: TObject);
|
2010-01-03 09:50:26 -05:00
|
|
|
procedure MenuItemExportHTMLClick(Sender: TObject);
|
2009-12-24 11:21:31 -05:00
|
|
|
procedure MenuitemFillFunctionListClick(Sender: TObject);
|
2009-12-20 15:11:11 -05:00
|
|
|
procedure MenuItemHideClick(Sender: TObject);
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure MenuItemShowClick(Sender: TObject);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure MenuItemTabCloseClick(Sender: TObject);
|
|
|
|
procedure MenuItemTabCloseOthersClick(Sender: TObject);
|
2009-12-23 20:20:17 -05:00
|
|
|
procedure MenuItemFunctionListClick(Sender: TObject);
|
2010-01-07 15:25:10 -05:00
|
|
|
procedure MenuViewSettingsClick(Sender: TObject);
|
2009-10-18 16:11:47 -04:00
|
|
|
procedure OnLinePSScript(Sender: TObject);
|
2009-10-24 10:01:21 -04:00
|
|
|
procedure ButtonPickClick(Sender: TObject);
|
|
|
|
procedure ButtonSelectorDown(Sender: TObject; Button: TMouseButton;
|
2009-09-23 16:18:33 -04:00
|
|
|
Shift: TShiftState; X, Y: Integer);
|
2009-09-25 15:29:03 -04:00
|
|
|
procedure NoTray(Sender: TObject);
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure PageControl1Change(Sender: TObject);
|
2009-10-24 10:01:21 -04:00
|
|
|
procedure ButtonTrayClick(Sender: TObject);
|
2009-11-05 14:44:10 -05:00
|
|
|
procedure PageControl1Changing(Sender: TObject; var AllowChange: Boolean);
|
2009-11-01 08:56:54 -05:00
|
|
|
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);
|
2009-12-22 01:10:58 -05:00
|
|
|
procedure PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
2009-11-04 17:41:06 -05:00
|
|
|
procedure ProcessDebugStream(Sender: TObject);
|
2009-12-22 19:33:32 -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);
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure ScriptPopupPopup(Sender: TObject);
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure SpeedButtonSearchClick(Sender: TObject);
|
2010-01-03 14:27:09 -05:00
|
|
|
procedure SplitterFunctionListCanResize(Sender: TObject; var NewSize: Integer;
|
2009-12-23 20:20:17 -05:00
|
|
|
var Accept: Boolean);
|
2010-01-02 20:36:54 -05:00
|
|
|
procedure UpdateButtonClick(Sender: TObject);
|
2009-12-31 17:37:09 -05:00
|
|
|
procedure UpdateMenuButtonClick(Sender: TObject);
|
2010-01-02 20:36:54 -05:00
|
|
|
procedure UpdateTimerCheck(Sender: TObject);
|
2009-09-04 00:26:56 -04:00
|
|
|
private
|
2009-11-01 08:56:54 -05:00
|
|
|
PopupTab : integer;
|
2009-11-04 15:05:35 -05:00
|
|
|
SearchStart : TPoint;
|
2009-11-05 14:44:10 -05:00
|
|
|
LastTab : integer;
|
2009-10-31 17:44:13 -04:00
|
|
|
function GetScriptState: TScriptState;
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure SetScriptState(const State: TScriptState);
|
2009-09-04 00:26:56 -04:00
|
|
|
public
|
2009-11-04 17:41:06 -05:00
|
|
|
DebugStream: String;
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
CurrScript : TScriptFrame; //The current scriptframe
|
|
|
|
CurrTab : TMufasaTab; //The current TMufasaTab
|
|
|
|
Tabs : TList;
|
2009-09-22 16:55:15 -04:00
|
|
|
Window: TMWindow;
|
2009-12-24 06:04:53 -05:00
|
|
|
OCR_Fonts: TMOCR;
|
2009-09-22 19:58:14 -04:00
|
|
|
Picker: TMColorPicker;
|
2009-09-23 16:18:33 -04:00
|
|
|
Selector: TMWindowSelector;
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure FunctionListShown( ShowIt : boolean);
|
2009-10-31 17:44:13 -04:00
|
|
|
property ScriptState : TScriptState read GetScriptState write SetScriptState;
|
2009-10-18 16:11:47 -04:00
|
|
|
procedure SafeCallThread;
|
2009-10-17 13:57:09 -04:00
|
|
|
function OpenScript : boolean;
|
|
|
|
function SaveCurrentScript : boolean;
|
|
|
|
function SaveCurrentScriptAs : boolean;
|
|
|
|
function CanExitOrOpen : boolean;
|
|
|
|
function ClearScript : boolean;
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure RunScript;
|
|
|
|
procedure PauseScript;
|
|
|
|
procedure StopScript;
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure AddTab;
|
|
|
|
function DeleteTab( TabIndex : integer; CloseLast : boolean) : boolean;
|
|
|
|
procedure ClearTab( TabIndex : integer);
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure CloseTabs( Exclude : integer);overload;//-1 for none
|
|
|
|
procedure CloseTabs;overload;
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure SetEditActions;
|
2009-11-07 15:26:26 -05:00
|
|
|
procedure DoSearch(Str: String; Next : boolean; HighlightAll : boolean);
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure RefreshTab;//Refreshes all the form items that depend on the Script (Panels, title etc.)
|
2009-12-27 19:08:02 -05:00
|
|
|
procedure RefreshTabSender(sender : PtrInt);
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
2009-11-04 17:41:06 -05:00
|
|
|
|
|
|
|
procedure formWriteln( S : String);
|
2009-12-24 20:34:14 -05:00
|
|
|
function GetMethodName( Decl : string; PlusNextChar : boolean) : string;
|
2009-11-04 17:41:06 -05:00
|
|
|
|
2009-10-17 13:57:09 -04:00
|
|
|
const
|
2009-11-13 20:22:06 -05:00
|
|
|
// 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.
|
2009-10-24 11:37:00 -04:00
|
|
|
Panel_State = 0;
|
|
|
|
Panel_ScriptName = 1;
|
|
|
|
Panel_ScriptPath = 2;
|
|
|
|
Image_Stop = 7;
|
|
|
|
Image_Terminate = 19;
|
2009-09-04 00:26:56 -04:00
|
|
|
var
|
2009-09-22 18:28:10 -04:00
|
|
|
Form1: TForm1;
|
2009-10-20 15:48:18 -04:00
|
|
|
MainDir : string;
|
2009-10-18 16:11:47 -04:00
|
|
|
CurrentSyncInfo : TSyncInfo;//We need this for SafeCallThread
|
2009-09-04 00:26:56 -04:00
|
|
|
|
|
|
|
implementation
|
2009-09-09 03:08:58 -04:00
|
|
|
uses
|
2009-11-04 17:41:06 -05:00
|
|
|
lclintf,plugins,
|
2009-11-29 14:23:25 -05:00
|
|
|
syncobjs, // for the critical sections
|
|
|
|
debugimage,
|
|
|
|
bitmaps,
|
2009-12-22 19:33:32 -05:00
|
|
|
colourhistory,
|
2009-12-24 20:34:14 -05:00
|
|
|
simpleanalyzer,
|
2009-12-22 19:33:32 -05:00
|
|
|
math;
|
2009-09-04 00:26:56 -04:00
|
|
|
|
2009-11-04 17:41:06 -05:00
|
|
|
//{$ifdef mswindows}
|
|
|
|
|
|
|
|
var
|
|
|
|
DebugCriticalSection: syncobjs.TCriticalSection;
|
|
|
|
|
|
|
|
procedure TForm1.ProcessDebugStream(Sender: TObject);
|
|
|
|
|
|
|
|
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;
|
2009-10-25 07:01:28 -04:00
|
|
|
end;
|
2009-11-04 17:41:06 -05:00
|
|
|
|
2009-12-22 19:33:32 -05:00
|
|
|
procedure TForm1.ScriptPanelDockDrop(Sender: TObject; Source: TDragDockObject;
|
|
|
|
X, Y: Integer);
|
2009-11-07 00:27:39 -05:00
|
|
|
begin
|
2009-12-22 19:33:32 -05:00
|
|
|
if(X <= (ScriptPanel.Width div 2))then
|
|
|
|
begin
|
2009-12-24 03:18:24 -05:00
|
|
|
frmFunctionList.Align := alLeft;
|
2009-12-22 19:33:32 -05:00
|
|
|
PageControl1.Align := alRight;
|
2010-01-03 14:27:09 -05:00
|
|
|
SplitterFunctionList.ResizeAnchor := akLeft;
|
|
|
|
SplitterFunctionList.Align := alLeft;
|
|
|
|
SplitterFunctionList.Left := frmFunctionList.Left + frmFunctionList.Width;
|
2009-12-22 19:33:32 -05:00
|
|
|
end else begin
|
2009-12-24 03:18:24 -05:00
|
|
|
frmFunctionList.Align := alRight;
|
2009-12-22 19:33:32 -05:00
|
|
|
PageControl1.Align := alLeft;
|
2010-01-03 14:27:09 -05:00
|
|
|
SplitterFunctionList.ResizeAnchor := akRight;
|
|
|
|
SplitterFunctionList.Align := alRight;
|
|
|
|
SplitterFunctionList.Left := frmFunctionList.Left;
|
2009-12-22 19:33:32 -05:00
|
|
|
end;
|
|
|
|
PageControl1.Width := ScriptPanel.Width - (Source.DockRect.Right - Source.DockRect.Left);
|
2009-12-24 03:18:24 -05:00
|
|
|
frmFunctionList.Width := ScriptPanel.Width - PageControl1.Width;
|
2009-12-22 19:33:32 -05:00
|
|
|
PageControl1.Align := alClient;
|
2010-01-03 14:27:09 -05:00
|
|
|
SplitterFunctionList.Show;
|
2009-11-07 07:44:09 -05:00
|
|
|
end;
|
|
|
|
|
2009-12-22 19:33:32 -05:00
|
|
|
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
|
2009-12-24 03:18:24 -05:00
|
|
|
Accept := frmFunctionList.DragKind = dkDock;
|
2009-12-22 19:33:32 -05:00
|
|
|
if(Accept)then
|
|
|
|
begin
|
|
|
|
P := ScriptPanel.ClientToScreen(Point(0, 0));
|
|
|
|
if(X <= (ScriptPanel.Width div 2))then
|
2009-12-24 03:18:24 -05:00
|
|
|
Source.DockRect := Rect(P.x, P.y, min(P.x + frmFunctionList.Width, P.x + (ScriptPanel.Width div 2)), P.y + ScriptPanel.Height)
|
2009-12-22 19:33:32 -05:00
|
|
|
else
|
2009-12-24 03:18:24 -05:00
|
|
|
Source.DockRect := Rect(max(P.x + ScriptPanel.Width - frmFunctionList.Width, P.x + (ScriptPanel.Width div 2)), P.y, P.x + ScriptPanel.Width, P.y + ScriptPanel.Height);
|
2009-12-22 19:33:32 -05:00
|
|
|
end;
|
|
|
|
end;
|
2009-11-07 07:44:09 -05:00
|
|
|
|
2009-12-22 19:33:32 -05:00
|
|
|
procedure TForm1.ScriptPopupPopup(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SetEditActions;
|
|
|
|
end;
|
2009-11-07 07:44:09 -05:00
|
|
|
|
|
|
|
procedure TForm1.SpeedButtonSearchClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
CloseFindPanel;
|
2009-11-07 00:27:39 -05:00
|
|
|
end;
|
|
|
|
|
2010-01-03 14:27:09 -05:00
|
|
|
procedure TForm1.SplitterFunctionListCanResize(Sender: TObject; var NewSize: Integer;
|
2009-12-23 20:20:17 -05:00
|
|
|
var Accept: Boolean);
|
|
|
|
begin
|
|
|
|
if(NewSize > ScriptPanel.Width div 2)then
|
2010-01-07 18:14:48 -05:00
|
|
|
NewSize := ScriptPanel.Width div 2;
|
2009-12-23 20:20:17 -05:00
|
|
|
end;
|
|
|
|
|
2010-01-02 20:36:54 -05:00
|
|
|
procedure TForm1.UpdateButtonClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SimbaUpdateForm.Show;
|
|
|
|
UpdateButton.Visible:=False;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.UpdateTimerCheck(Sender: TObject);
|
2010-01-07 18:14:48 -05:00
|
|
|
var
|
|
|
|
chk: String;
|
|
|
|
time:integer;
|
2010-01-02 20:36:54 -05:00
|
|
|
begin
|
2010-01-07 18:14:48 -05:00
|
|
|
|
|
|
|
chk := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists(
|
|
|
|
'Settings/Updater/CheckForUpdates',
|
|
|
|
'True', SimbaSettingsFile
|
|
|
|
);
|
|
|
|
|
|
|
|
if chk <> 'True' then
|
|
|
|
Exit;
|
|
|
|
|
2010-01-02 20:36:54 -05:00
|
|
|
if SimbaUpdateForm.CanUpdate then
|
2010-01-03 08:47:40 -05:00
|
|
|
begin;
|
2010-01-02 20:36:54 -05:00
|
|
|
UpdateButton.Visible:=True;
|
2010-01-03 08:47:40 -05:00
|
|
|
formWriteln('A new update of Simba is available!');
|
|
|
|
end;
|
2010-01-07 18:14:48 -05:00
|
|
|
|
|
|
|
time := StrToIntDef(SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists(
|
|
|
|
'Settings/Updater/CheckEveryXMinutes',
|
|
|
|
'30', SimbaSettingsFile
|
|
|
|
), 30);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateTimer.Interval:= time {mins} * 60 {secs} * 1000 {ms};//Every half hour
|
2010-01-02 20:36:54 -05:00
|
|
|
end;
|
|
|
|
|
2009-12-31 17:37:09 -05:00
|
|
|
procedure TForm1.UpdateMenuButtonClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SimbaUpdateForm.Show; { I don't see why Modal }
|
|
|
|
end;
|
|
|
|
|
2009-11-04 17:41:06 -05:00
|
|
|
procedure formWriteln( S : String);
|
|
|
|
begin
|
2009-11-05 14:44:10 -05:00
|
|
|
writeln('formWriteln: ' + s);
|
2009-11-04 17:41:06 -05:00
|
|
|
DebugCriticalSection.Enter;
|
|
|
|
try
|
2009-11-05 12:03:44 -05:00
|
|
|
{$ifdef MSWindows}
|
|
|
|
//Ha, we cán acces the debugmemo
|
|
|
|
Form1.Memo1.Lines.Add(s);
|
|
|
|
{$else}
|
|
|
|
s := s + MEOL;
|
2009-11-04 17:41:06 -05:00
|
|
|
Form1.DebugStream:= Form1.DebugStream + s;
|
2009-11-05 12:03:44 -05:00
|
|
|
{$endif}
|
2009-11-04 17:41:06 -05:00
|
|
|
finally
|
|
|
|
DebugCriticalSection.Leave;
|
|
|
|
end;
|
|
|
|
//Form1.Memo1.Lines.Add(s);
|
|
|
|
end;
|
|
|
|
|
|
|
|
//{$ENDIF}
|
2009-09-04 00:26:56 -04:00
|
|
|
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure TForm1.RunScript;
|
2009-11-29 14:23:25 -05:00
|
|
|
var
|
|
|
|
DbgImgInfo : TDbgImgInfo;
|
2010-01-07 14:29:03 -05:00
|
|
|
fontPath: String;
|
|
|
|
saveAfterSetting: Boolean = false;
|
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
if ScriptState = ss_Paused then
|
|
|
|
begin;
|
|
|
|
ScriptThread.Resume;
|
|
|
|
ScriptState := ss_Running;
|
|
|
|
Exit;
|
|
|
|
end else
|
|
|
|
if ScriptState <> ss_None then
|
|
|
|
begin;
|
|
|
|
Writeln('The script hasn''t stopped yet, so we cannot start a new one.');
|
|
|
|
exit;
|
|
|
|
end;
|
2009-10-31 19:31:51 -04:00
|
|
|
ScriptErrorLine:= -1;
|
2009-10-31 17:44:13 -04:00
|
|
|
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
|
|
|
|
ScriptThread := TMMLPSThread.Create(True,@CurrentSyncInfo);
|
2009-11-04 18:02:37 -05:00
|
|
|
{$IFNDEF TERMINALWRITELN}
|
2009-11-04 17:41:06 -05:00
|
|
|
ScriptThread.SetDebug(@formWriteln);
|
2009-11-04 18:02:37 -05:00
|
|
|
{$ENDIF}
|
2009-11-06 19:50:02 -05:00
|
|
|
ScriptThread.SetPSScript(CurrScript.SynEdit.Lines.Text);
|
2009-11-29 14:23:25 -05:00
|
|
|
DbgImgInfo.DispSize := @DebugImgForm.DispSize;
|
|
|
|
DbgImgInfo.ShowForm := @DebugImgForm.ShowDebugImgForm;
|
|
|
|
DbgImgInfo.ToDrawBitmap:= @DebugImgForm.ToDrawBmp;
|
|
|
|
DbgImgInfo.DrawBitmap:= @DebugImgForm.DrawBitmap;
|
2009-12-25 18:56:25 -05:00
|
|
|
DbgImgInfo.GetDebugBitmap:= @DebugImgForm.GetDbgBmp;
|
|
|
|
DbgImgInfo.GetBitmap:= @DebugImgForm.GetDebugImage;
|
2009-11-29 14:23:25 -05:00
|
|
|
ScriptThread.SetDbgImg(DbgImgInfo);
|
2009-11-06 19:50:02 -05:00
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
ScriptThread.OnError:=@ErrorThread;
|
|
|
|
if ScriptFile <> '' then
|
|
|
|
ScriptThread.SetPaths( ExtractFileDir(ScriptFile) + DS,IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)))
|
|
|
|
else
|
|
|
|
ScriptThread.SetPaths('', IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)));
|
|
|
|
|
|
|
|
// This doesn't actually set the Client's MWindow to the passed window, it
|
|
|
|
// only copies the current set window handle.
|
|
|
|
ScriptThread.Client.MWindow.SetWindow(Self.Window);
|
|
|
|
|
2010-01-02 22:45:02 -05:00
|
|
|
|
2009-12-24 06:04:53 -05:00
|
|
|
// Copy our current fonts
|
|
|
|
if not assigned(Self.OCR_Fonts) then
|
|
|
|
begin
|
2010-01-07 18:14:48 -05:00
|
|
|
Self.OCR_Fonts := TMOCR.Create(ScriptThread.Client);
|
|
|
|
|
|
|
|
fontPath := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists(
|
|
|
|
'Settings/Fonts/Path',
|
|
|
|
IncludeTrailingPathDelimiter(ExpandFileName(MainDir
|
|
|
|
+DS + '..' + DS + '..' + ds)) + 'Fonts' + DS,
|
|
|
|
SimbaSettingsFile
|
|
|
|
);
|
2010-01-07 14:29:03 -05:00
|
|
|
|
|
|
|
if DirectoryExists(fontPath) then
|
|
|
|
begin
|
|
|
|
OCR_Fonts.InitTOCR(fontPath);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
writeln('Warning: The Font directory in the Settings is not valid. Changing to default.');
|
|
|
|
OCR_Fonts.InitTOCR(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS);
|
|
|
|
end;
|
2009-12-24 06:04:53 -05:00
|
|
|
end;
|
|
|
|
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
|
|
|
|
ScriptState:= ss_Running;
|
|
|
|
//Lets run it!
|
2009-10-24 11:37:00 -04:00
|
|
|
ScriptThread.Resume;
|
|
|
|
end;
|
|
|
|
end;
|
2009-09-28 22:12:29 -04:00
|
|
|
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure TForm1.PauseScript;
|
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
with CurrScript do
|
2009-10-24 11:37:00 -04:00
|
|
|
begin;
|
2009-10-31 17:44:13 -04:00
|
|
|
if ScriptState = ss_Running then
|
|
|
|
begin;
|
|
|
|
{$ifdef MSWindows}
|
|
|
|
ScriptThread.Suspended:= True;
|
|
|
|
ScriptState:= ss_Paused;
|
|
|
|
{$else}
|
|
|
|
Writeln('Linux users are screwed, no pause button for u!');
|
|
|
|
{$endif}
|
|
|
|
end else if ScriptState = ss_Paused then
|
|
|
|
begin;
|
|
|
|
ScriptThread.Resume;
|
|
|
|
ScriptState := ss_Running;
|
|
|
|
end;
|
2009-10-24 11:37:00 -04:00
|
|
|
end;
|
|
|
|
end;
|
2009-09-28 22:12:29 -04:00
|
|
|
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure TForm1.StopScript;
|
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
with CurrScript do
|
|
|
|
begin;
|
|
|
|
case ScriptState of
|
|
|
|
ss_Stopping:
|
|
|
|
begin //Terminate the thread the tough way.
|
|
|
|
writeln('Terminating the Scriptthread');
|
2009-11-01 10:04:03 -05:00
|
|
|
Writeln('Exit code terminate: ' +inttostr(KillThread(ScriptThread.Handle)));
|
2009-11-02 05:18:35 -05:00
|
|
|
WaitForThreadTerminate(ScriptThread.Handle, 0);
|
2009-10-31 17:44:13 -04:00
|
|
|
ScriptThread.Free;
|
|
|
|
ScriptState := ss_None;
|
|
|
|
end;
|
|
|
|
ss_Running:
|
|
|
|
begin
|
|
|
|
ScriptThread.PSScript.Stop;
|
|
|
|
ScriptState := ss_Stopping;
|
|
|
|
end;
|
|
|
|
ss_Paused:
|
|
|
|
begin
|
|
|
|
ScriptThread.Resume;
|
|
|
|
ScriptThread.PSScript.Stop;
|
|
|
|
ScriptState:= ss_Stopping;
|
|
|
|
end;
|
|
|
|
end;
|
2009-10-24 11:37:00 -04:00
|
|
|
end;
|
2009-09-19 22:08:02 -04:00
|
|
|
end;
|
2009-09-12 02:24:59 -04:00
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure TForm1.AddTab;
|
|
|
|
var
|
|
|
|
Tab : TMufasaTab;
|
|
|
|
begin;
|
|
|
|
Tab := TMufasaTab.Create(Self.PageControl1);
|
|
|
|
Tabs.Add(Tab);
|
2009-11-04 10:56:28 -05:00
|
|
|
Tab.TabSheet.ImageIndex:= 8;
|
2009-11-01 08:56:54 -05:00
|
|
|
// Tab.TabSheet.OnContextPopup:= @TabPopup;
|
2009-10-31 17:44:13 -04:00
|
|
|
PageControl1.TabIndex:= Tabs.Count - 1;
|
|
|
|
RefreshTab;
|
2009-11-01 08:56:54 -05:00
|
|
|
if tabs.count > 1 then
|
|
|
|
begin;
|
|
|
|
TB_SaveAll.Enabled:= True;
|
|
|
|
MenuItemSaveAll.Enabled:= True;
|
|
|
|
end;
|
2009-10-31 17:44:13 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.DeleteTab(TabIndex: integer; CloseLast : boolean) : boolean;
|
|
|
|
var
|
|
|
|
Tab : TMufasaTab;
|
2009-11-01 08:56:54 -05:00
|
|
|
OldIndex : integer;//So that we can switch back, if needed.
|
2009-10-24 10:01:21 -04:00
|
|
|
begin
|
2009-11-01 08:56:54 -05:00
|
|
|
OldIndex := PageControl1.TabIndex;
|
2009-11-05 14:44:10 -05:00
|
|
|
if TabIndex = OldIndex then //We are closing the 'current' tab, lets go back in history
|
|
|
|
OldIndex := LastTab;
|
2009-10-31 17:44:13 -04:00
|
|
|
PageControl1.TabIndex:= TabIndex;
|
|
|
|
//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);
|
2009-11-01 08:56:54 -05:00
|
|
|
if OldIndex > TabIndex then
|
|
|
|
PageControl1.TabIndex := OldIndex - 1
|
|
|
|
else if OldIndex < TabIndex then
|
2009-12-25 10:40:14 -05:00
|
|
|
PageControl1.TabIndex := OldIndex;
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
if tabs.count <= 1 then
|
|
|
|
begin;
|
|
|
|
TB_SaveAll.Enabled:= false;
|
|
|
|
MenuItemSaveAll.Enabled:= false;
|
2009-10-31 17:44:13 -04:00
|
|
|
end;
|
2009-11-05 12:03:44 -05:00
|
|
|
RefreshTab;
|
2009-10-24 10:01:21 -04:00
|
|
|
end;
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure TForm1.ClearTab(TabIndex: integer);
|
2009-10-24 10:01:21 -04:00
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
TMufasaTab(Tabs[TabIndex]).Clear;
|
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.CloseTabs(Exclude: integer);
|
|
|
|
var
|
|
|
|
I : integer;
|
|
|
|
begin
|
|
|
|
for i := tabs.count - 1 downto 0 do
|
|
|
|
if i <> exclude then
|
2009-11-01 23:10:32 -05:00
|
|
|
if not DeleteTab(i,false) then
|
|
|
|
exit;
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.CloseTabs;
|
|
|
|
begin
|
|
|
|
CloseTabs(-1);
|
|
|
|
end;
|
|
|
|
|
2009-11-07 07:44:09 -05:00
|
|
|
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;
|
|
|
|
end;
|
|
|
|
|
2009-11-07 23:45:26 -05:00
|
|
|
var
|
|
|
|
S: String;
|
|
|
|
B: Boolean;
|
2009-11-07 07:44:09 -05:00
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
2009-11-07 15:26:26 -05:00
|
|
|
begin
|
2009-11-07 07:44:09 -05:00
|
|
|
with CurrScript.SynEdit do
|
2009-11-07 15:26:26 -05:00
|
|
|
begin
|
|
|
|
EditActions(CanUndo,CanRedo,SelText <> '',SelText <> '',CanPaste,SelText <> '');
|
2009-11-07 23:45:26 -05:00
|
|
|
B:= SelText <> '';
|
|
|
|
PopupItemFind.Enabled:= B;
|
|
|
|
PopupItemReplace.Enabled:= B;
|
|
|
|
if(B)then
|
2009-11-07 15:26:26 -05:00
|
|
|
begin
|
2009-11-12 16:20:29 -05:00
|
|
|
if(Length(SelText) > 13)then
|
|
|
|
S:= Format('"%s"', [Copy(SelText, 1, 10) + '...'])
|
2009-11-07 15:26:26 -05:00
|
|
|
else
|
2009-11-07 23:45:26 -05:00
|
|
|
S:= Format('"%s"', [SelText]);
|
|
|
|
PopupItemFind.Caption:= 'Find next: ' + S;
|
2009-11-12 16:20:29 -05:00
|
|
|
PopupItemReplace.Caption:= 'Replace: ' + S;
|
2009-11-07 15:26:26 -05:00
|
|
|
end;
|
|
|
|
end
|
|
|
|
end
|
2009-11-07 07:44:09 -05:00
|
|
|
else if Memo1.Focused then
|
|
|
|
with Memo1 do
|
|
|
|
EditActions(CanUndo,False,SelText <>'',SelText <> '',True,SelText <> '')
|
|
|
|
else
|
|
|
|
EditActions(false,false,false,false,false,false);
|
|
|
|
end;
|
|
|
|
|
2009-11-07 15:26:26 -05:00
|
|
|
procedure TForm1.DoSearch(Str: String; Next: boolean; HighlightAll : boolean);
|
2009-11-04 15:05:35 -05:00
|
|
|
var
|
|
|
|
Res : integer;
|
|
|
|
CurrPos : TPoint;
|
2009-11-07 07:44:09 -05:00
|
|
|
SearchOptions : TSynSearchOptions;
|
2009-11-04 15:05:35 -05:00
|
|
|
begin
|
2009-11-07 07:44:09 -05:00
|
|
|
SearchOptions:= [];
|
|
|
|
if CheckBoxMatchCase.Checked then
|
|
|
|
SearchOptions := [ssoMatchCase];
|
2009-11-07 15:26:26 -05:00
|
|
|
if Str = '' then
|
2009-11-04 15:05:35 -05:00
|
|
|
begin
|
|
|
|
res := -1;
|
|
|
|
CurrScript.Synedit.SetHighlightSearch('',[]);
|
|
|
|
// CurrScript.SynEdit.SelectionMode:=
|
|
|
|
// CurrScript.SynEdit.CaretXY := CurrScript.SynEdit.CaretXY;
|
|
|
|
CurrScript.SynEdit.LogicalCaretXY := SearchStart;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2009-11-07 15:26:26 -05:00
|
|
|
Writeln('Searching: ' + Str);
|
2009-11-04 15:05:35 -05:00
|
|
|
if next then
|
|
|
|
CurrPos := CurrScript.SynEdit.LogicalCaretXY
|
|
|
|
else
|
|
|
|
CurrPos := SearchStart;
|
2009-11-07 15:26:26 -05:00
|
|
|
Res := CurrScript.SynEdit.SearchReplaceEx(Str,'',SearchOptions,CurrPos);
|
2009-11-04 15:05:35 -05:00
|
|
|
if res = 0 then
|
|
|
|
begin
|
2009-11-07 15:26:26 -05:00
|
|
|
res := CurrScript.SynEdit.SearchReplaceEx(Str,'',SearchOptions,Point(0,0));
|
2009-11-04 15:05:35 -05:00
|
|
|
if res > 0 then
|
|
|
|
begin;
|
|
|
|
Writeln('End of document reached');
|
|
|
|
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
|
2009-11-07 23:45:26 -05:00
|
|
|
begin
|
|
|
|
HighlightAllColor.Background:= clYellow;
|
2009-11-07 07:44:09 -05:00
|
|
|
if HighlightAll then
|
2009-11-07 15:26:26 -05:00
|
|
|
SetHighlightSearch(Str,[])
|
2009-11-07 07:44:09 -05:00
|
|
|
else
|
|
|
|
SetHighlightSearch('',[]);
|
2009-11-07 23:45:26 -05:00
|
|
|
end;
|
2009-11-04 15:05:35 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure TForm1.RefreshTab;
|
|
|
|
var
|
|
|
|
Tab : TMufasaTab;
|
|
|
|
Script : TScriptFrame;
|
|
|
|
NewTab : integer;
|
|
|
|
begin
|
2009-11-05 12:03:44 -05:00
|
|
|
if tabs.Count < 1 then
|
|
|
|
begin;
|
|
|
|
Writeln('Cannot refresh tab, since there are no tabs.');
|
|
|
|
exit;
|
|
|
|
end;
|
2009-10-31 17:44:13 -04:00
|
|
|
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;
|
|
|
|
Self.Caption := Format(WindowTitle,[Script.ScriptName]);
|
|
|
|
Tab.TabSheet.Caption:= 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
|
2009-10-31 19:31:51 -04:00
|
|
|
if Self.Showing then
|
2009-11-01 08:56:54 -05:00
|
|
|
if Tab.TabSheet.TabIndex = Self.PageControl1.TabIndex then
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
2009-12-26 11:43:06 -05:00
|
|
|
editSearchListExit(self);//To set the highlighting back to normal;
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
2009-11-04 15:05:35 -05:00
|
|
|
with CurrScript.SynEdit do
|
|
|
|
begin
|
|
|
|
SetHighlightSearch('',[]);
|
|
|
|
UseIncrementalColor:= false;
|
|
|
|
MarkupByClass[TSynEditMarkupHighlightAllCaret].TempEnable;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
LabeledEditSearch.SelLength:= 0;
|
|
|
|
LabeledEditSearch.Color:= clWindow;
|
|
|
|
LabeledEditSearch.Font.Color:= clWindowText;
|
2009-11-07 07:44:09 -05:00
|
|
|
//Set tha edit buttons right
|
|
|
|
SetEditActions;
|
2009-10-24 10:01:21 -04:00
|
|
|
end;
|
|
|
|
|
2009-12-27 19:08:02 -05:00
|
|
|
procedure TForm1.RefreshTabSender(sender: PtrInt);
|
2009-12-26 11:43:06 -05:00
|
|
|
begin
|
|
|
|
RefreshTab;
|
|
|
|
end;
|
|
|
|
|
2009-10-24 10:01:21 -04:00
|
|
|
|
2009-11-01 08:56:54 -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
|
2009-11-01 23:10:32 -05:00
|
|
|
if(PageControl1.PageCount > 1)then
|
|
|
|
Self.DeleteTab(PageControl1.TabIndex,false)
|
|
|
|
else
|
2009-11-02 04:25:49 -05:00
|
|
|
Self.ClearScript; //DeleteTab would take care of this already, but yeah, it's neater this way.
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure TForm1.ActionCopyExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
2009-11-07 15:26:26 -05:00
|
|
|
CurrScript.SynEdit.CopyToClipboard
|
2009-11-07 00:27:39 -05:00
|
|
|
else if Memo1.Focused then
|
2010-01-03 14:27:09 -05:00
|
|
|
Memo1.CopyToClipboard
|
|
|
|
else
|
|
|
|
Writeln(Sender.ToString);
|
2009-11-07 00:27:39 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionCutExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
2009-11-07 15:26:26 -05:00
|
|
|
CurrScript.SynEdit.CutToClipboard
|
2009-11-07 00:27:39 -05:00
|
|
|
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;
|
|
|
|
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure TForm1.ActionExitExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.Close;
|
|
|
|
end;
|
|
|
|
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure TForm1.ActionFindNextExecute(Sender: TObject);
|
|
|
|
begin
|
2009-11-07 15:26:26 -05:00
|
|
|
if(ScriptPopup.HandleAllocated)then
|
|
|
|
DoSearch(CurrScript.SynEdit.SelText, true, false)
|
|
|
|
else
|
|
|
|
DoSearch(LabeledEditSearch.Text, true, false);
|
2009-11-07 07:44:09 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-04 15:05:35 -05:00
|
|
|
procedure TForm1.ActionFindstartExecute(Sender: TObject);
|
|
|
|
begin
|
2009-12-24 20:34:14 -05:00
|
|
|
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;
|
2009-11-04 15:05:35 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-01 12:23:16 -05:00
|
|
|
procedure TForm1.ActionClearDebugExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Memo1.Clear;
|
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.ActionNewExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.ClearScript;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionNewTabExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.AddTab;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ActionOpenExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.OpenScript;
|
|
|
|
end;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure TForm1.ActionPasteExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
2009-11-07 15:26:26 -05:00
|
|
|
CurrScript.SynEdit.PasteFromClipboard
|
2009-11-07 00:27:39 -05:00
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.PasteFromClipboard;
|
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.ActionPauseExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.PauseScript;
|
|
|
|
end;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure TForm1.ActionRedoExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.Redo
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.Undo; //?
|
|
|
|
end;
|
|
|
|
|
2009-11-07 23:45:26 -05:00
|
|
|
procedure TForm1.ActionReplaceExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if(ScriptPopup.HandleAllocated)then
|
|
|
|
dlgReplace.FindText:= CurrScript.SynEdit.SelText;
|
|
|
|
dlgReplace.Execute;
|
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
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;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure TForm1.ActionSelectAllExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.SynEdit.SelectAll
|
|
|
|
else if Memo1.Focused then
|
2009-11-07 07:44:09 -05:00
|
|
|
Memo1.SelectAll
|
|
|
|
else if LabeledEditSearch.Focused then
|
|
|
|
LabeledEditSearch.SelectAll;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.ActionStopExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.StopScript;
|
2009-10-31 17:44:13 -04:00
|
|
|
end;
|
2009-10-24 10:01:21 -04:00
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.ActionTabNextExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
CurrIndex : integer;
|
2009-10-31 17:44:13 -04:00
|
|
|
begin
|
2009-11-01 08:56:54 -05:00
|
|
|
CurrIndex := PageControl1.TabIndex;
|
|
|
|
if CurrIndex = Tabs.count - 1 then
|
|
|
|
CurrIndex := 0
|
|
|
|
else
|
|
|
|
Inc(CurrIndex);
|
|
|
|
PageControl1.TabIndex:= CurrIndex;
|
2009-10-24 10:01:21 -04:00
|
|
|
end;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure TForm1.ActionUndoExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
|
|
|
|
CurrScript.Undo
|
|
|
|
else if Memo1.Focused then
|
|
|
|
Memo1.Undo;
|
|
|
|
end;
|
|
|
|
|
2009-11-08 10:15:48 -05:00
|
|
|
|
|
|
|
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure TForm1.CheckBoxMatchCaseClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
RefreshTab;
|
2009-11-08 10:15:48 -05:00
|
|
|
CurrScript.SynEdit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempDisable;
|
2009-11-07 15:26:26 -05:00
|
|
|
DoSearch(LabeledEditSearch.Text, false, true);
|
2009-11-07 07:44:09 -05:00
|
|
|
CurrScript.SynEdit.UseIncrementalColor:= true;
|
2009-11-08 10:15:48 -05:00
|
|
|
LabeledEditSearch.SetFocus;
|
2009-11-07 07:44:09 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-08 10:15:48 -05:00
|
|
|
|
|
|
|
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure TForm1.CloseFindPanel;
|
|
|
|
begin
|
|
|
|
SearchPanel.Visible:= false;
|
|
|
|
if CurrScript.SynEdit.CanFocus then
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
|
|
|
end;
|
|
|
|
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure TForm1.editSearchListExit(Sender: TObject);
|
|
|
|
begin
|
|
|
|
frmFunctionList.editSearchList.Color := clWhite;
|
|
|
|
if frmFunctionList.InCodeCompletion then
|
|
|
|
begin;
|
2010-01-03 14:27:09 -05:00
|
|
|
if frmFunctionList.FilterTree.Focused then
|
|
|
|
begin;
|
|
|
|
Writeln('This is currently not supported');
|
|
|
|
CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart;
|
|
|
|
CurrScript.SynEdit.LogicalCaretXY:= point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y);
|
|
|
|
CurrScript.SynEdit.SelEnd:= CurrScript.SynEdit.SelStart;
|
|
|
|
end;
|
2009-12-24 20:34:14 -05:00
|
|
|
frmFunctionList.InCodeCompletion:= false;
|
|
|
|
CurrScript.SynEdit.SelectedColor.Style:= [];
|
|
|
|
CurrScript.SynEdit.SelectedColor.Foreground:= clHighlightText;
|
|
|
|
CurrScript.SynEdit.SelectedColor.Background:= clHighlight;
|
2009-12-26 11:43:06 -05:00
|
|
|
CurrScript.Synedit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempEnable;
|
2009-12-24 20:34:14 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-01-03 14:27:09 -05:00
|
|
|
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;
|
|
|
|
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure TForm1.editSearchListKeyPress(Sender: TObject; var Key: char);
|
|
|
|
var
|
|
|
|
linetext : string;
|
|
|
|
begin
|
|
|
|
if key = #13 then//enter
|
|
|
|
begin;
|
|
|
|
key := #0;
|
|
|
|
frmFunctionList.Find(True);
|
2010-01-03 14:27:09 -05:00
|
|
|
//See OnKeyUp
|
|
|
|
{ end else if key = Chr(VK_UP) then //Up, go one up!
|
|
|
|
begin;
|
|
|
|
Writeln('hai');
|
|
|
|
frmFunctionList.Find(false,true);}
|
2009-12-26 07:44:40 -05:00
|
|
|
end else
|
|
|
|
if frmFunctionList.InCodeCompletion then
|
2009-12-24 20:34:14 -05:00
|
|
|
begin;
|
2009-12-26 07:44:40 -05:00
|
|
|
if key = #27 then//esc -> C'est error!
|
|
|
|
begin
|
|
|
|
key := #0;
|
|
|
|
CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart;
|
|
|
|
frmFunctionList.editSearchList.OnExit(sender);
|
|
|
|
CurrScript.SynEdit.LogicalCaretXY:= point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y);
|
|
|
|
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;
|
|
|
|
linetext := CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1];
|
|
|
|
frmFunctionList.editSearchList.OnExit(sender);
|
|
|
|
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;
|
2009-12-24 20:34:14 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode);
|
|
|
|
begin
|
2009-12-26 10:45:05 -05:00
|
|
|
if node = nil then
|
|
|
|
exit;
|
2009-12-24 20:34:14 -05:00
|
|
|
if Node.Level > 0 then
|
|
|
|
StatusBar.Panels[2].Text := PChar(Node.Data);
|
2009-12-26 10:45:05 -05:00
|
|
|
if Node.level = 0 then
|
|
|
|
StatusBar.Panels[2].Text := 'Section: ' + Node.Text;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FunctionListEnter(Sender: TObject);
|
|
|
|
begin
|
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
2009-12-24 20:34:14 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FunctionListExit(Sender: TObject);
|
|
|
|
begin
|
|
|
|
StatusBar.Panels[2].Text:= '';
|
|
|
|
end;
|
|
|
|
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure TForm1.MenuItemColourHistoryClick(Sender: TObject);
|
2009-11-07 10:40:45 -05:00
|
|
|
begin
|
2009-11-12 16:20:29 -05:00
|
|
|
MenuItemColourHistory.Checked := not ColourHistoryForm.Visible;
|
|
|
|
if MenuItemColourHistory.Checked then
|
2009-11-07 10:40:45 -05:00
|
|
|
ColourHistoryForm.Show
|
|
|
|
else
|
|
|
|
ColourHistoryForm.Hide;
|
|
|
|
end;
|
|
|
|
|
2009-11-07 23:45:26 -05:00
|
|
|
procedure TForm1.dlgReplaceFind(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DoSearch(dlgReplace.FindText, True, False);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.dlgReplaceReplace(Sender: TObject);
|
|
|
|
var
|
2009-11-08 14:09:45 -05:00
|
|
|
SOptions: TSynSearchOptions;
|
|
|
|
P: TPoint;
|
|
|
|
Y: Boolean;
|
|
|
|
Btns: TMsgDlgButtons;
|
|
|
|
|
|
|
|
procedure Replace;
|
|
|
|
begin
|
|
|
|
CurrScript.SynEdit.SearchReplaceEx(dlgReplace.FindText, dlgReplace.ReplaceText, SOptions + [ssoReplace], P);
|
|
|
|
end;
|
|
|
|
|
2009-11-07 23:45:26 -05:00
|
|
|
begin
|
2009-11-08 14:09:45 -05:00
|
|
|
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];
|
|
|
|
if(frEntireScope in dlgReplace.Options)then P:= Point(0, 0) else P:= CaretXY;
|
|
|
|
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;
|
2009-11-07 23:45:26 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-03 12:23:34 -05:00
|
|
|
procedure TForm1.EditSearchChange(Sender: TObject);
|
|
|
|
begin
|
2009-11-07 15:26:26 -05:00
|
|
|
DoSearch(LabeledEditSearch.Text, false, true);
|
2009-11-03 12:23:34 -05:00
|
|
|
end;
|
|
|
|
|
2009-10-17 13:57:09 -04:00
|
|
|
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
2009-10-31 17:44:13 -04:00
|
|
|
var
|
|
|
|
i : integer;
|
2009-10-17 13:57:09 -04:00
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
for i := Tabs.Count - 1 downto 0 do
|
|
|
|
if not DeleteTab(i,true) then
|
|
|
|
begin;
|
|
|
|
CloseAction := caNone;
|
|
|
|
exit
|
|
|
|
end;
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
|
2009-09-12 14:50:10 -04:00
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
|
|
|
begin
|
2009-11-29 14:23:25 -05:00
|
|
|
Randomize;
|
2009-11-04 15:19:13 -05:00
|
|
|
//Show close buttons @ tabs
|
|
|
|
PageControl1.Options:=PageControl1.Options+[nboShowCloseButtons];
|
2009-11-04 15:25:56 -05:00
|
|
|
PageControl1.OnCloseTabClicked:=ActionCloseTab.OnExecute;
|
2009-10-31 17:44:13 -04:00
|
|
|
Tabs := TList.Create;
|
|
|
|
AddTab;//Give it alteast 1 tab ;-).
|
2009-12-26 11:20:46 -05:00
|
|
|
FunctionListShown(True); //Show this function list bitch!
|
2009-09-22 16:55:15 -04:00
|
|
|
Window := TMWindow.Create;
|
2009-09-22 19:58:14 -04:00
|
|
|
Picker := TMColorPicker.Create(Window);
|
2009-09-23 16:18:33 -04:00
|
|
|
Selector := TMWindowSelector.Create(Window);
|
2009-09-13 19:56:15 -04:00
|
|
|
MainDir:= ExtractFileDir(Application.ExeName);
|
|
|
|
PluginsGlob := TMPlugins.Create;
|
|
|
|
PluginsGlob.PluginDirs.Add(ExpandFileName(MainDir + DS + '..' + DS + '..'+ DS + 'Plugins'+ DS));
|
2009-11-04 17:41:06 -05:00
|
|
|
|
|
|
|
{ For writeln }
|
|
|
|
SetLength(DebugStream, 0);
|
|
|
|
DebugCriticalSection := syncobjs.TCriticalSection.Create;
|
2009-11-05 12:03:44 -05:00
|
|
|
{$ifdef mswindows}
|
|
|
|
DebugTimer.Enabled:= false;
|
|
|
|
{$endif}
|
2009-12-26 11:43:06 -05:00
|
|
|
Application.QueueAsyncCall(@RefreshTabSender,0);
|
2010-01-03 08:47:40 -05:00
|
|
|
{$ifdef mswindows}
|
|
|
|
if FileExists(Application.ExeName+'_old_') then
|
|
|
|
begin
|
|
|
|
Writeln('We still have an out-dated exe file in the dir, lets remove!');
|
|
|
|
Writeln(format('Sucesfully deleted the file? %s',[BoolToStr(DeleteFile(Application.ExeName + '_old_'),true)]));
|
|
|
|
end;
|
|
|
|
{$endif}
|
2010-01-03 14:27:09 -05:00
|
|
|
frmFunctionList.OnEndDock:= @frmFunctionList.FrameEndDock;
|
2009-11-07 07:44:09 -05:00
|
|
|
// Ed
|
2009-09-13 19:56:15 -04:00
|
|
|
end;
|
2009-09-12 14:50:10 -04:00
|
|
|
|
2009-09-13 19:56:15 -04:00
|
|
|
procedure TForm1.FormDestroy(Sender: TObject);
|
2009-10-31 17:44:13 -04:00
|
|
|
var
|
|
|
|
i : integer;
|
2009-09-13 19:56:15 -04:00
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
for i := Tabs.Count - 1 downto 0 do
|
|
|
|
TMufasaTab(Tabs[i]).Free;
|
|
|
|
Tabs.free;
|
2009-09-23 16:18:33 -04:00
|
|
|
Selector.Free;
|
2009-09-22 19:58:14 -04:00
|
|
|
Picker.Free;
|
2009-09-22 16:55:15 -04:00
|
|
|
Window.Free;
|
2009-09-13 19:56:15 -04:00
|
|
|
PluginsGlob.Free;
|
2009-11-04 17:41:06 -05:00
|
|
|
|
|
|
|
SetLength(DebugStream, 0);
|
|
|
|
DebugCriticalSection.Free;
|
2009-09-12 14:50:10 -04:00
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.FormShortCuts(var Msg: TLMKey; var Handled: Boolean);
|
|
|
|
begin
|
2009-11-12 16:20:29 -05:00
|
|
|
SetEditActions;
|
2009-11-01 08:56:54 -05:00
|
|
|
Handled := ActionList.IsShortCut(Msg);
|
|
|
|
{ ShiftState := MsgKeyDataToShiftState(Message.KeyData);
|
|
|
|
ShortCut := KeyToShortCut(Message.CharCode, ShiftState);}
|
|
|
|
end;
|
|
|
|
|
2009-11-12 16:20:29 -05:00
|
|
|
|
|
|
|
|
2009-11-04 15:05:35 -05:00
|
|
|
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
|
2009-11-07 07:44:09 -05:00
|
|
|
if not CheckBoxMatchCase.MouseEntered then
|
|
|
|
RefreshTab;
|
2009-11-04 15:05:35 -05:00
|
|
|
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
|
2009-11-07 07:44:09 -05:00
|
|
|
CloseFindPanel;
|
2009-11-05 12:03:44 -05:00
|
|
|
key := 0;
|
2009-11-04 15:05:35 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.LabeledEditSearchKeyPress(Sender: TObject; var Key: char);
|
|
|
|
begin
|
|
|
|
if key = #13 then
|
|
|
|
begin;
|
2009-11-07 15:26:26 -05:00
|
|
|
DoSearch(LabeledEditSearch.Text, true, true);
|
2009-11-05 12:03:44 -05:00
|
|
|
key := #0;
|
2009-11-04 15:05:35 -05:00
|
|
|
// LabeledEditSearch.SelStart:= Length(LabeledEditSearch.Text);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-11-07 00:27:39 -05:00
|
|
|
procedure TForm1.MenuEditClick(Sender: TObject);
|
2009-11-01 23:10:32 -05:00
|
|
|
begin
|
2009-11-07 07:44:09 -05:00
|
|
|
SetEditActions;
|
2009-11-01 23:10:32 -05:00
|
|
|
end;
|
|
|
|
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure TForm1.MenuItemAboutClick(Sender: TObject);
|
2009-10-24 10:01:21 -04:00
|
|
|
begin
|
2009-11-12 16:20:29 -05:00
|
|
|
AboutForm.ShowModal;
|
2009-10-24 10:01:21 -04:00
|
|
|
end;
|
|
|
|
|
2009-11-12 16:20:29 -05:00
|
|
|
procedure TForm1.MenuItemCloseTabsClick(Sender: TObject);
|
2009-10-24 11:37:00 -04:00
|
|
|
begin
|
2009-11-12 16:20:29 -05:00
|
|
|
Self.CloseTabs;
|
2009-10-24 11:37:00 -04:00
|
|
|
end;
|
|
|
|
|
2009-11-29 14:23:25 -05:00
|
|
|
procedure TForm1.MenuItemDebugImageClick(Sender: TObject);
|
|
|
|
begin
|
2009-11-30 10:55:14 -05:00
|
|
|
MenuItemDebugImage.Checked := not DebugImgForm.Visible;
|
|
|
|
if MenuItemDebugImage.Checked then
|
|
|
|
DebugImgForm.Show
|
|
|
|
else
|
|
|
|
DebugImgForm.Hide;
|
2009-11-29 14:23:25 -05:00
|
|
|
end;
|
|
|
|
|
2010-01-03 09:50:26 -05:00
|
|
|
procedure TForm1.MenuItemExportHTMLClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
SynExporterHTML : TSynExporterHTML;
|
|
|
|
begin;
|
|
|
|
SynExporterHTML := TSynExporterHTML.Create(nil);
|
|
|
|
SynExporterHTML.Highlighter := CurrScript.SynFreePascalSyn1;
|
|
|
|
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;
|
|
|
|
|
2009-12-24 11:21:31 -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;
|
2009-12-24 20:34:14 -05:00
|
|
|
if (Decl[ii] = ' ') or (Decl[ii] = ':') then
|
|
|
|
begin;
|
|
|
|
if PlusNextChar then
|
|
|
|
result := result + ' ';
|
|
|
|
exit;
|
|
|
|
end;
|
2009-12-24 11:21:31 -05:00
|
|
|
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;
|
|
|
|
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure TForm1.MenuitemFillFunctionListClick(Sender: TObject);
|
2009-12-24 11:21:31 -05:00
|
|
|
var
|
|
|
|
Methods : TExpMethodArr;
|
|
|
|
LastSection : string;
|
|
|
|
Sections : TStringList;
|
|
|
|
i : integer;
|
|
|
|
Index : integer;
|
|
|
|
TempNode : TTreeNode;
|
2009-12-24 12:38:16 -05:00
|
|
|
Temp2Node : TTreeNode;
|
2009-12-24 11:21:31 -05:00
|
|
|
Tree : TTreeView;
|
|
|
|
begin
|
|
|
|
Methods := TMMLPSThread.GetExportedMethods;
|
|
|
|
Tree := frmFunctionList.FunctionList;
|
|
|
|
Tree.Items.Clear;
|
|
|
|
Sections := TStringList.Create;
|
|
|
|
LastSection := '';
|
2009-12-26 10:45:05 -05:00
|
|
|
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script');
|
2009-12-24 11:21:31 -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
|
|
|
|
TempNode := Tree.Items.Item[index]
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempNode := Tree.Items.Add(nil,LastSection);
|
|
|
|
Sections.Add(LastSection);
|
|
|
|
end;
|
|
|
|
end;
|
2009-12-24 12:38:16 -05:00
|
|
|
Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false));
|
2009-12-24 20:34:14 -05:00
|
|
|
Temp2Node.Data:= strnew(PChar(Methods[i].FuncDecl));
|
2009-12-24 11:21:31 -05:00
|
|
|
end;
|
2009-12-26 10:45:05 -05:00
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
2009-12-24 11:21:31 -05:00
|
|
|
end;
|
|
|
|
|
2009-12-20 15:11:11 -05:00
|
|
|
procedure TForm1.MenuItemHideClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Self.Visible = false then
|
|
|
|
MenuItemShowClick(sender)
|
|
|
|
else
|
|
|
|
Self.hide;
|
|
|
|
end;
|
|
|
|
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure TForm1.MenuItemShowClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Self.Show;
|
2009-10-31 19:31:51 -04:00
|
|
|
Self.WindowState := wsNormal;
|
2009-10-24 11:37:00 -04:00
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.MenuItemTabCloseClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DeleteTab(PopupTab,false);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.MenuItemTabCloseOthersClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
CloseTabs(PopupTab);
|
|
|
|
end;
|
|
|
|
|
2009-12-23 20:20:17 -05:00
|
|
|
procedure TForm1.MenuItemFunctionListClick(Sender: TObject);
|
|
|
|
begin
|
2009-12-24 20:34:14 -05:00
|
|
|
FunctionListShown(not MenuItemFunctionList.Checked);
|
2009-12-23 20:20:17 -05:00
|
|
|
end;
|
|
|
|
|
2010-01-07 15:25:10 -05:00
|
|
|
procedure TForm1.MenuViewSettingsClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SettingsForm.ShowModal;
|
|
|
|
end;
|
|
|
|
|
2009-10-18 16:11:47 -04:00
|
|
|
procedure TForm1.OnLinePSScript(Sender: TObject);
|
|
|
|
begin
|
|
|
|
//Writeln('We just completed a line!!');
|
|
|
|
{$IFDEF ProcessMessages}
|
|
|
|
Application.ProcessMessages; //Don't think that this is neccesary though
|
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
|
2009-10-17 13:57:09 -04:00
|
|
|
|
2009-10-24 10:01:21 -04:00
|
|
|
procedure TForm1.ButtonPickClick(Sender: TObject);
|
2009-09-22 19:58:14 -04:00
|
|
|
var
|
|
|
|
c, x, y: Integer;
|
2009-11-07 10:40:45 -05:00
|
|
|
cobj: TColourPickerObject;
|
2009-09-22 19:58:14 -04:00
|
|
|
begin
|
|
|
|
Picker.Pick(c, x, y);
|
2009-11-09 09:22:29 -05:00
|
|
|
cobj := TColourPickerObject.Create(c, Point(x,y), '');
|
2009-11-07 10:40:45 -05:00
|
|
|
|
2009-11-09 09:22:29 -05:00
|
|
|
ColourHistoryForm.AddColObj(cobj, true);
|
2009-11-07 10:40:45 -05:00
|
|
|
ColourHistoryForm.Show;
|
2009-11-07 11:55:28 -05:00
|
|
|
formWriteln('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
|
2009-09-22 19:58:14 -04:00
|
|
|
end;
|
|
|
|
|
2009-10-24 10:01:21 -04:00
|
|
|
|
|
|
|
procedure TForm1.ButtonSelectorDown(Sender: TObject; Button: TMouseButton;
|
2009-09-23 16:18:33 -04:00
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
2009-09-23 17:56:51 -04:00
|
|
|
Window.SetTarget(Selector.Drag {$ifdef MSWINDOWS},w_window{$endif});
|
2009-09-23 18:01:19 -04:00
|
|
|
writeln('New window: ' + IntToStr(Window.{$ifdef MSWindows}TargetHandle{$else}CurWindow{$ENDIF}));
|
2009-09-23 16:18:33 -04:00
|
|
|
end;
|
|
|
|
|
2009-09-25 15:29:03 -04:00
|
|
|
procedure TForm1.NoTray(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Not Form1.IsVisible then
|
2009-11-01 08:56:54 -05:00
|
|
|
Self.MenuItemShowClick(Sender)
|
2009-09-25 15:29:03 -04:00
|
|
|
else
|
|
|
|
Form1.Hide;
|
|
|
|
end;
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure TForm1.PageControl1Change(Sender: TObject);
|
2009-10-24 11:37:00 -04:00
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
RefreshTab();
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
|
2009-10-24 10:01:21 -04:00
|
|
|
procedure TForm1.ButtonTrayClick(Sender: TObject);
|
2009-09-25 15:29:03 -04:00
|
|
|
begin
|
|
|
|
Form1.Hide;
|
|
|
|
end;
|
|
|
|
|
2009-11-05 14:44:10 -05:00
|
|
|
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean
|
|
|
|
);
|
|
|
|
begin
|
|
|
|
LastTab:= PageControl1.TabIndex;
|
|
|
|
end;
|
|
|
|
|
2009-11-01 08:56:54 -05:00
|
|
|
procedure TForm1.PageControl1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
|
var Handled: Boolean);
|
|
|
|
begin
|
|
|
|
PopupTab := PageControl1.TabIndexAtClientPos(MousePos);
|
2009-11-01 10:04:03 -05:00
|
|
|
if PopupTab = -1 then
|
|
|
|
begin
|
|
|
|
Writeln('We couldn''t find which tab you clicked on, closing the popup');
|
|
|
|
Handled := true;
|
|
|
|
end;
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1DragDrop(Sender, Source: TObject; X, Y: Integer);
|
|
|
|
var
|
|
|
|
NewPos : integer;
|
|
|
|
OldPos : integer;
|
|
|
|
begin
|
|
|
|
if sender <> PageControl1 then
|
|
|
|
exit;
|
|
|
|
NewPos := PageControl1.TabIndexAtClientPos(Point(x,y));
|
|
|
|
OldPos := PageControl1.TabIndex;
|
2009-11-01 10:04:03 -05:00
|
|
|
if (NewPos <> OldPos) and (NewPos <> -1) then
|
2009-11-01 08:56:54 -05:00
|
|
|
begin;
|
|
|
|
Tabs.Move(OldPos,NewPos);
|
2009-11-01 10:04:03 -05:00
|
|
|
PageControl1.Pages[OldPos].TabIndex:= NewPos;
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1DragOver(Sender, Source: TObject; X, Y: Integer;
|
|
|
|
State: TDragState; var Accept: Boolean);
|
2009-12-22 01:10:58 -05:00
|
|
|
var
|
|
|
|
Pos: Integer;
|
2009-11-01 08:56:54 -05:00
|
|
|
begin
|
2009-12-22 01:10:58 -05:00
|
|
|
Pos := PageControl1.TabIndexAtClientPos(Point(x,y));
|
2009-12-22 03:57:10 -05:00
|
|
|
Accept := (Pos <> PageControl1.TabIndex) and (Pos <> -1);
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.PageControl1MouseDown(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
2009-12-22 01:10:58 -05:00
|
|
|
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
|
|
|
|
if(PageControl1.TabIndexAtClientPos(Point(x,y)) <> -1)then
|
|
|
|
DeleteTab(PageControl1.TabIndexAtClientPos(Point(x,y)), False);
|
2009-11-01 08:56:54 -05:00
|
|
|
end;
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
function TForm1.GetScriptState: TScriptState;
|
|
|
|
begin
|
|
|
|
result := CurrScript.FScriptState;
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
|
2009-10-24 11:37:00 -04:00
|
|
|
procedure TForm1.SetScriptState(const State: TScriptState);
|
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
CurrScript.FScriptState:= State;
|
2009-10-24 11:37:00 -04:00
|
|
|
with Self.StatusBar.panels[Panel_State] do
|
2009-10-31 17:44:13 -04:00
|
|
|
case state of
|
2009-10-31 19:31:51 -04:00
|
|
|
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;
|
2009-10-24 11:37:00 -04:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-12-24 20:34:14 -05:00
|
|
|
procedure TForm1.FunctionListShown(ShowIt: boolean);
|
|
|
|
var
|
|
|
|
Node : TTreeNode;
|
|
|
|
tmpNode : TTreeNode;
|
|
|
|
Tree : TTreeView;
|
|
|
|
Analyzer : TScriptAnalyzer;
|
|
|
|
I,ii : integer;
|
|
|
|
begin
|
|
|
|
with MenuItemFunctionList, frmFunctionList do
|
|
|
|
begin
|
|
|
|
Checked := ShowIt;
|
|
|
|
if(Checked)then
|
|
|
|
begin
|
|
|
|
if FunctionList.Items.Count = 0 then
|
|
|
|
MenuitemFillFunctionListClick(nil);
|
2010-01-03 14:27:09 -05:00
|
|
|
FrameEndDock(frmFunctionList,frmFunctionList.Parent,0,0);//Set the label correctly
|
2009-12-24 20:34:14 -05:00
|
|
|
if(frmFunctionList.Parent is TPanel)then
|
|
|
|
begin
|
2010-01-03 14:27:09 -05:00
|
|
|
SplitterFunctionList.Show;
|
2009-12-24 20:34:14 -05:00
|
|
|
frmFunctionList.Show;
|
|
|
|
end else frmFunctionList.Parent.Show;
|
2009-12-26 11:20:46 -05:00
|
|
|
if Self.Visible then
|
|
|
|
if editSearchList.CanFocus then
|
|
|
|
editSearchList.SetFocus;
|
2009-12-24 20:34:14 -05:00
|
|
|
//Lets load up this Script tree!
|
2009-12-26 10:45:05 -05:00
|
|
|
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.text);
|
2009-12-24 20:34:14 -05:00
|
|
|
end else begin
|
|
|
|
if(frmFunctionList.Parent is TPanel)then
|
|
|
|
frmFunctionList.Hide
|
|
|
|
else
|
|
|
|
frmFunctionList.Parent.Hide;
|
2010-01-03 14:27:09 -05:00
|
|
|
SplitterFunctionList.Hide;
|
2009-12-24 20:34:14 -05:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-10-24 10:01:21 -04:00
|
|
|
|
2009-10-18 16:11:47 -04:00
|
|
|
procedure TForm1.SafeCallThread;
|
|
|
|
begin
|
|
|
|
Writeln('Executing : ' + CurrentSyncInfo.MethodName);
|
|
|
|
mmlpsthread.CurrThread := TMMLPSTHREAD(CurrentSyncInfo.OldThread);
|
|
|
|
with CurrentSyncInfo.PSScript do
|
|
|
|
begin;
|
|
|
|
OnLine:=@OnLinePSScript;
|
|
|
|
CurrentSyncInfo.Res:= Exec.RunProcPVar(CurrentSyncInfo.V,Exec.GetProc(CurrentSyncInfo.MethodName));
|
|
|
|
Online := nil;
|
|
|
|
end;
|
|
|
|
mmlpsthread.CurrThread := nil;
|
|
|
|
end;
|
|
|
|
|
2009-10-17 13:57:09 -04:00
|
|
|
function TForm1.OpenScript: boolean;
|
|
|
|
begin;
|
|
|
|
Result := False;
|
|
|
|
if CanExitOrOpen = false then
|
|
|
|
Exit;
|
|
|
|
with TOpenDialog.Create(nil) do
|
|
|
|
try
|
|
|
|
Filter:= 'Mufasa Files|*.cogat;*.mufa;*.txt|Any files|*.*';
|
|
|
|
if Execute then
|
|
|
|
if FileExists(FileName) then
|
|
|
|
begin;
|
2009-10-31 17:44:13 -04:00
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
SynEdit.Lines.LoadFromFile(FileName);
|
|
|
|
StartText := SynEdit.Lines.text;
|
|
|
|
ScriptName:= ExtractFileNameOnly(FileName);
|
|
|
|
WriteLn('Script name will be: ' + ScriptName);
|
|
|
|
ScriptFile:= FileName;
|
|
|
|
ScriptChanged := false;
|
|
|
|
RefreshTab();
|
|
|
|
Result := True;
|
|
|
|
end;
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
finally
|
|
|
|
Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.SaveCurrentScript: boolean;
|
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
Result := (ScriptFile <> '');
|
|
|
|
if Result then
|
|
|
|
begin;
|
|
|
|
ScriptChanged := false;
|
|
|
|
SynEdit.Lines.SaveToFile(ScriptFile);
|
|
|
|
StartText:= SynEdit.Lines.Text;
|
|
|
|
SynEdit.MarkTextAsSaved;
|
|
|
|
Self.Caption:= Format(WindowTitle,[ScriptName]);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
result := SaveCurrentScriptAs;
|
|
|
|
end;
|
2009-11-08 10:15:48 -05:00
|
|
|
RefreshTab;
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.SaveCurrentScriptAs: boolean;
|
|
|
|
begin
|
2009-10-31 17:44:13 -04:00
|
|
|
with CurrScript do
|
|
|
|
begin;
|
|
|
|
Result := false;
|
|
|
|
with TSaveDialog.Create(nil) do
|
|
|
|
try
|
|
|
|
Filter:= 'Mufasa files|*.cogat;*.mufa;*.pas;*.txt|Any Files|*.*';
|
|
|
|
if Execute then
|
2009-10-17 13:57:09 -04:00
|
|
|
begin;
|
2009-10-31 17:44:13 -04:00
|
|
|
if ExtractFileExt(FileName) = '' then
|
|
|
|
begin;
|
|
|
|
ScriptFile := FileName + '.mufa';
|
|
|
|
end else
|
|
|
|
ScriptFile := FileName;
|
|
|
|
SynEdit.Lines.SaveToFile(ScriptFile);
|
|
|
|
ScriptName:= ExtractFileNameOnly(ScriptFile);
|
|
|
|
WriteLn('Script name will be: ' + ScriptName);
|
|
|
|
RefreshTab();
|
|
|
|
Result := True;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
Free;
|
|
|
|
end;
|
|
|
|
if result then
|
|
|
|
begin;
|
|
|
|
Writeln('Succesfully saved: ' + ScriptFile);
|
|
|
|
StartText:= SynEdit.Lines.Text;
|
|
|
|
SynEdit.MarkTextAsSaved;
|
|
|
|
ScriptChanged := false;
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.CanExitOrOpen: boolean;
|
|
|
|
var
|
|
|
|
I : integer;
|
|
|
|
begin;
|
2009-10-30 16:21:44 -04:00
|
|
|
Self.Enabled := False;//We HAVE to answer the popup
|
2009-10-17 13:57:09 -04:00
|
|
|
Result := True;
|
2009-10-31 17:44:13 -04:00
|
|
|
if ScriptState <> ss_None then
|
|
|
|
begin
|
|
|
|
if ScriptState <> ss_Stopping then
|
|
|
|
begin
|
|
|
|
result := False;
|
|
|
|
Case MessageBox(0,pchar('Do you want to stop the script?'), Pchar('Script is still running.'),
|
|
|
|
MB_YESNOCANCEL or MB_ICONQUESTION) of
|
|
|
|
IDYES : StopScript;
|
|
|
|
end;
|
|
|
|
end else
|
|
|
|
Case MessageBox(0,pchar('Do you want to terminate the script?'), Pchar('Script is stopping.'),
|
|
|
|
MB_YESNOCANCEL or MB_ICONQUESTION) of
|
|
|
|
IDNO,IDCancel: Result := false;
|
|
|
|
IDYES : StopScript;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if Result and (CurrScript.StartText <> CurrScript.SynEdit.Lines.text) then
|
2009-10-17 13:57:09 -04:00
|
|
|
Case MessageBox(0,pchar('Do you want to save the script?'), Pchar('Script has been modified.'),
|
|
|
|
MB_YESNOCANCEL or MB_ICONQUESTION) of
|
|
|
|
IDCANCEL : Result := False;
|
|
|
|
IDYES : Result := SaveCurrentScript;
|
|
|
|
end;
|
2009-10-30 16:21:44 -04:00
|
|
|
Self.Enabled := True;
|
2009-11-07 07:44:09 -05:00
|
|
|
if Self.CanFocus then
|
|
|
|
Self.SetFocus;
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TForm1.ClearScript: boolean;
|
|
|
|
begin
|
|
|
|
if CanExitOrOpen then
|
|
|
|
begin;
|
2009-10-31 17:44:13 -04:00
|
|
|
CurrTab.Clear;
|
|
|
|
RefreshTab();
|
2009-10-17 13:57:09 -04:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-09-19 22:08:02 -04:00
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
{ 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;
|
2009-12-22 03:57:10 -05:00
|
|
|
ScriptFrame.Align := alClient;
|
2009-10-31 17:44:13 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TMufasaTab.Destroy;
|
|
|
|
begin
|
|
|
|
ScriptFrame.Free;
|
|
|
|
TabSheet.Free;
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
initialization
|
|
|
|
{$I testunit.lrs}
|
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
end.
|
|
|
|
|