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;
|
|
|
|
|
2010-01-13 14:20:46 -05:00
|
|
|
{$undef EditButtons}
|
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-17 21:47:56 -05:00
|
|
|
SynExportHTML, SynEditKeyCmds, SynEditHighlighter, SynEditMarkupSpecialLine,
|
|
|
|
SynEditMarkupHighAll, SynEditMiscClasses, LMessages, Buttons, PairSplitter,
|
|
|
|
ColorBox, about, framefunctionlist, ocr, updateform, simbasettings;
|
2009-09-04 00:26:56 -04:00
|
|
|
|
2010-01-07 19:34:58 -05:00
|
|
|
const
|
2010-01-18 17:30:29 -05:00
|
|
|
SimbaVersion = 429;
|
2010-01-07 19:34:58 -05:00
|
|
|
|
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;
|
More GUI changes
I started to work on a Bug Report form, but came to the conclusion, have no way of posting the information.
Wizzup, could you please post on the new thread about how to post to Mantis if you know?
I wrote up some new code for a new internets.pas currently in (newinternets.pas, whooda thunk?)
Its good, just needs some crucial things like physically openning the connections and closing them.
I added PostHTTP stuff, and need more ideas, I worked through Indy and found the right things so.. yeah!
Oh, and I added some more icons to the MainMenu from famfam.
Just to reiterate, the new AboutForm is a template, and the Image is copyrighted and will have to change.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@406 3f818213-9676-44b0-a9b4-5e4c4e03d09d
2010-01-13 00:11:11 -05:00
|
|
|
MainMenu: TMainMenu;
|
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;
|
More GUI changes
I started to work on a Bug Report form, but came to the conclusion, have no way of posting the information.
Wizzup, could you please post on the new thread about how to post to Mantis if you know?
I wrote up some new code for a new internets.pas currently in (newinternets.pas, whooda thunk?)
Its good, just needs some crucial things like physically openning the connections and closing them.
I added PostHTTP stuff, and need more ideas, I worked through Indy and found the right things so.. yeah!
Oh, and I added some more icons to the MainMenu from famfam.
Just to reiterate, the new AboutForm is a template, and the Image is copyrighted and will have to change.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@406 3f818213-9676-44b0-a9b4-5e4c4e03d09d
2010-01-13 00:11:11 -05:00
|
|
|
MenuItemAbout: TMenuItem;
|
|
|
|
MenuItemReportBug: 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-12 13:07:47 -05:00
|
|
|
TT_Cut: TToolButton;
|
|
|
|
TT_Copy: TToolButton;
|
|
|
|
TT_Paste: TToolButton;
|
|
|
|
ToolButton9: TToolButton;
|
2010-01-02 20:36:54 -05:00
|
|
|
UpdateTimer: TTimer;
|
|
|
|
ToolButton3: TToolButton;
|
2010-01-12 13:07:47 -05:00
|
|
|
TT_Update: 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
|
|
|
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);
|
More GUI changes
I started to work on a Bug Report form, but came to the conclusion, have no way of posting the information.
Wizzup, could you please post on the new thread about how to post to Mantis if you know?
I wrote up some new code for a new internets.pas currently in (newinternets.pas, whooda thunk?)
Its good, just needs some crucial things like physically openning the connections and closing them.
I added PostHTTP stuff, and need more ideas, I worked through Indy and found the right things so.. yeah!
Oh, and I added some more icons to the MainMenu from famfam.
Just to reiterate, the new AboutForm is a template, and the Image is copyrighted and will have to change.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@406 3f818213-9676-44b0-a9b4-5e4c4e03d09d
2010-01-13 00:11:11 -05:00
|
|
|
procedure MenuItemReportBugClick(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);
|
2010-01-12 10:56:42 -05:00
|
|
|
procedure PopupItemFindClick(Sender: TObject);
|
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-12 13:07:47 -05:00
|
|
|
procedure TrayPopupPopup(Sender: TObject);
|
|
|
|
procedure TT_UpdateClick(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;
|
2010-01-10 17:01:33 -05:00
|
|
|
FirstRun : boolean;//Only show the warnings the first run (path not existing one's)
|
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);
|
2010-01-12 13:07:47 -05:00
|
|
|
function LoadSettingDef(Key : string; Def : string) : string;
|
2009-09-04 00:26:56 -04:00
|
|
|
public
|
2009-11-04 17:41:06 -05:00
|
|
|
DebugStream: String;
|
2010-01-12 10:56:42 -05:00
|
|
|
SearchString : 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;
|
2010-01-17 20:25:02 -05:00
|
|
|
function LoadScriptFile(filename : string) : boolean;
|
2009-10-17 13:57:09 -04:00
|
|
|
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;
|
2010-01-14 13:34:17 -05:00
|
|
|
procedure StopCodeCompletion;
|
2010-01-12 13:07:47 -05:00
|
|
|
function DeleteTab( TabIndex : integer; CloseLast : boolean; Silent : boolean = false) : boolean;
|
2009-10-31 17:44:13 -04:00
|
|
|
procedure ClearTab( TabIndex : integer);
|
2010-01-12 13:07:47 -05:00
|
|
|
procedure CloseTabs(Exclude: integer = -1; Silent : boolean = false); //-1 for no exclusion
|
2009-11-07 07:44:09 -05:00
|
|
|
procedure SetEditActions;
|
2010-01-12 10:56:42 -05:00
|
|
|
procedure DoSearch(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-12 13:07:47 -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);
|
2010-01-02 20:36:54 -05:00
|
|
|
begin
|
2010-01-11 12:04:18 -05:00
|
|
|
SimbaUpdateForm.ShowModal;
|
2010-01-12 13:07:47 -05:00
|
|
|
TT_Update.Visible:=False;
|
2010-01-02 20:36:54 -05:00
|
|
|
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
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
chk := LoadSettingDef('Settings/Updater/CheckForUpdates','True');
|
2010-01-07 18:14:48 -05:00
|
|
|
|
|
|
|
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-12 13:07:47 -05:00
|
|
|
TT_Update.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
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
time := StrToIntDef(LoadSettingDef('Settings/Updater/CheckEveryXMinutes','30'),30);
|
2010-01-07 18:14:48 -05:00
|
|
|
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
|
2010-01-11 12:04:18 -05:00
|
|
|
SimbaUpdateForm.ShowModal;
|
2009-12-31 17:37:09 -05:00
|
|
|
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;
|
2010-01-10 17:01:33 -05:00
|
|
|
includePath : string;
|
|
|
|
AppPath : string;
|
|
|
|
pluginspath: string;
|
|
|
|
ScriptPath : string;
|
2010-01-10 09:34:23 -05:00
|
|
|
loadFontsOnScriptStart: String;
|
2010-01-07 14:29:03 -05:00
|
|
|
|
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);
|
2010-01-18 17:30:29 -05:00
|
|
|
ScriptThread.DebugMemo := Self.Memo1;
|
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);
|
2010-01-17 20:25:02 -05:00
|
|
|
ScriptThread.ErrorData:= @ErrorData;
|
|
|
|
ScriptThread.OnError:= @HandleErrorData;
|
2010-01-10 17:01:33 -05:00
|
|
|
|
2009-10-31 17:44:13 -04:00
|
|
|
if ScriptFile <> '' then
|
2010-01-10 17:01:33 -05:00
|
|
|
ScriptPath := ExtractFileDir(ScriptFile);
|
|
|
|
AppPath:= MainDir + DS;
|
2010-01-12 13:07:47 -05:00
|
|
|
includePath:= LoadSettingDef('Settings/Includes/Path',
|
|
|
|
IncludeTrailingPathDelimiter(ExpandFileName(MainDir+
|
|
|
|
DS + '..' + DS + '..' + ds)) + 'Includes' + DS);
|
|
|
|
fontPath := LoadSettingDef('Settings/Fonts/Path',
|
|
|
|
IncludeTrailingPathDelimiter(ExpandFileName(MainDir+
|
|
|
|
DS + '..' + DS + '..' + ds)) + 'Fonts' + DS);
|
|
|
|
|
|
|
|
PluginsPath := LoadSettingDef('Settings/Plugins/Path',
|
|
|
|
ExpandFileName(MainDir + DS + '..' + DS + '..'+ DS + 'Plugins'+ DS));
|
2010-01-10 17:01:33 -05:00
|
|
|
if not DirectoryExists(PluginsPath) and not assigned(PluginsGlob) then
|
|
|
|
begin
|
|
|
|
if FirstRun then
|
|
|
|
Writeln('Warning: The plugins directory specified in Settings isn''t valid. Not loading Plugins now.');
|
|
|
|
end else if not Assigned(PluginsGlob) then
|
|
|
|
begin
|
|
|
|
PluginsGlob := TMPlugins.Create;
|
|
|
|
PluginsGlob.PluginDirs.Add(PluginsPath);
|
|
|
|
end;
|
|
|
|
if not DirectoryExists(IncludePath) then
|
|
|
|
if FirstRun then
|
|
|
|
Writeln('Warning: The include directory specified in the Settings isn''t valid.');
|
|
|
|
if not DirectoryExists(fontPath) then
|
|
|
|
if FirstRun then
|
|
|
|
Writeln('Warning: The font directory specified in the Settings isn''t valid. Can''t load fonts now');
|
|
|
|
ScriptThread.SetPaths(ScriptPath,AppPath,Includepath,PluginsPath,fontPath);
|
2009-10-31 17:44:13 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
loadFontsOnScriptStart := LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True');
|
2009-12-24 06:04:53 -05:00
|
|
|
// Copy our current fonts
|
2010-01-10 17:01:33 -05:00
|
|
|
if not assigned(Self.OCR_Fonts) and (lowercase(loadFontsOnScriptStart) = 'true') and DirectoryExists(fontPath) then
|
2009-12-24 06:04:53 -05:00
|
|
|
begin
|
2010-01-07 18:14:48 -05:00
|
|
|
Self.OCR_Fonts := TMOCR.Create(ScriptThread.Client);
|
2010-01-10 09:34:23 -05:00
|
|
|
if DirectoryExists(fontPath) then
|
|
|
|
begin
|
|
|
|
OCR_Fonts.InitTOCR(fontPath);
|
2010-01-10 17:01:33 -05:00
|
|
|
end;{
|
2010-01-10 09:34:23 -05:00
|
|
|
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);
|
2010-01-10 17:01:33 -05:00
|
|
|
end; }
|
2009-12-24 06:04:53 -05:00
|
|
|
|
2010-01-10 09:34:23 -05:00
|
|
|
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
|
|
|
end else
|
|
|
|
if assigned(Self.OCR_Fonts) and (lowercase(loadFontsOnScriptStart) = 'true') then
|
|
|
|
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
2009-10-31 17:44:13 -04:00
|
|
|
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
|
|
|
|
ScriptState:= ss_Running;
|
2010-01-10 17:01:33 -05:00
|
|
|
FirstRun := false;
|
2009-10-31 17:44:13 -04:00
|
|
|
//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;
|
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
function TForm1.DeleteTab(TabIndex: integer; CloseLast : boolean; Silent : boolean = false) : boolean;
|
2009-10-31 17:44:13 -04:00
|
|
|
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
|
2010-01-12 13:07:47 -05:00
|
|
|
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;
|
2009-10-31 17:44:13 -04:00
|
|
|
//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);
|
2010-01-12 13:07:47 -05:00
|
|
|
if not Silent then
|
|
|
|
begin;
|
|
|
|
if OldIndex > TabIndex then
|
|
|
|
PageControl1.TabIndex := OldIndex - 1
|
|
|
|
else if OldIndex < TabIndex then
|
|
|
|
PageControl1.TabIndex := OldIndex;
|
|
|
|
end;
|
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;
|
2010-01-12 13:07:47 -05:00
|
|
|
if not silent then
|
|
|
|
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;
|
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
procedure TForm1.CloseTabs(Exclude: integer = -1; Silent : boolean = false);
|
2009-11-01 08:56:54 -05:00
|
|
|
var
|
|
|
|
I : integer;
|
|
|
|
begin
|
|
|
|
for i := tabs.count - 1 downto 0 do
|
|
|
|
if i <> exclude then
|
2010-01-12 13:07:47 -05:00
|
|
|
if not DeleteTab(i,false,silent) then
|
2009-11-01 23:10:32 -05:00
|
|
|
exit;
|
2009-11-01 08:56:54 -05:00
|
|
|
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;
|
2010-01-13 14:20:46 -05:00
|
|
|
{$ifdef UpdateEditButtons}
|
2010-01-12 13:07:47 -05:00
|
|
|
TT_Cut.Enabled:= Cut;
|
|
|
|
TT_Paste.Enabled:=Paste;
|
|
|
|
TT_Copy.enabled := Copy;
|
2010-01-13 14:20:46 -05:00
|
|
|
{$endif}
|
2009-11-07 07:44:09 -05:00
|
|
|
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 <> '');
|
2010-01-12 13:07:47 -05:00
|
|
|
// B:= SelText <> '';
|
|
|
|
B := SelAvail;
|
2009-11-07 23:45:26 -05:00
|
|
|
PopupItemFind.Enabled:= B;
|
|
|
|
PopupItemReplace.Enabled:= B;
|
|
|
|
if(B)then
|
2009-11-07 15:26:26 -05:00
|
|
|
begin
|
2010-01-12 13:07:47 -05:00
|
|
|
s := SelText;
|
|
|
|
if(Length(S) > 13)then
|
|
|
|
S:= Format('"%s"', [Copy(S, 1, 10) + '...'])
|
2009-11-07 15:26:26 -05:00
|
|
|
else
|
2010-01-12 13:07:47 -05:00
|
|
|
S:= Format('"%s"', [S]);
|
2009-11-07 23:45:26 -05:00
|
|
|
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;
|
|
|
|
|
2010-01-12 10:56:42 -05:00
|
|
|
procedure TForm1.DoSearch(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];
|
2010-01-12 10:56:42 -05:00
|
|
|
if SearchString = '' 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
|
2010-01-12 10:56:42 -05:00
|
|
|
Writeln('Searching: ' + SearchString);
|
2009-11-04 15:05:35 -05:00
|
|
|
if next then
|
|
|
|
CurrPos := CurrScript.SynEdit.LogicalCaretXY
|
|
|
|
else
|
|
|
|
CurrPos := SearchStart;
|
2010-01-12 10:56:42 -05:00
|
|
|
Res := CurrScript.SynEdit.SearchReplaceEx(SearchString,'',SearchOptions,CurrPos);
|
2009-11-04 15:05:35 -05:00
|
|
|
if res = 0 then
|
|
|
|
begin
|
2010-01-12 10:56:42 -05:00
|
|
|
res := CurrScript.SynEdit.SearchReplaceEx(SearchString,'',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
|
2010-01-12 10:56:42 -05:00
|
|
|
SetHighlightSearch(SearchString,[])
|
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;
|
|
|
|
Tab.TabSheet.Caption:= Script.ScriptName;
|
2010-01-14 13:34:17 -05:00
|
|
|
Self.Caption := Format(WindowTitle,[Script.ScriptName]);
|
2009-10-31 17:44:13 -04:00
|
|
|
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;
|
2010-01-14 13:34:17 -05:00
|
|
|
StopCodeCompletion;//To set the highlighting back to normal;
|
2009-12-26 11:43:06 -05:00
|
|
|
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
|
2010-01-13 17:35:20 -05:00
|
|
|
{ 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
|
2010-01-12 10:56:42 -05:00
|
|
|
DoSearch(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;
|
2010-01-12 10:56:42 -05:00
|
|
|
SearchString := LabeledEditSearch.Text;
|
|
|
|
DoSearch(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;
|
2010-01-17 21:47:56 -05:00
|
|
|
|
2010-01-14 13:34:17 -05:00
|
|
|
procedure TForm1.StopCodeCompletion;
|
2009-12-24 20:34:14 -05:00
|
|
|
begin
|
|
|
|
if frmFunctionList.InCodeCompletion then
|
2010-01-14 13:34:17 -05:00
|
|
|
with CurrScript,frmFunctionList do
|
2010-01-03 14:27:09 -05:00
|
|
|
begin;
|
2010-01-14 13:34:17 -05:00
|
|
|
editSearchList.Color:= clWhite;
|
|
|
|
if FilterTree.Focused then
|
|
|
|
begin;
|
|
|
|
Writeln('This is currently not supported');
|
|
|
|
SynEdit.Lines[CompletionCaret.y - 1] := CompletionStart;
|
|
|
|
SynEdit.LogicalCaretXY:= point(CompletionCaret.x,CompletionCaret.y);
|
|
|
|
SynEdit.SelEnd:= SynEdit.SelStart;
|
|
|
|
end;
|
|
|
|
InCodeCompletion:= false;
|
|
|
|
SynEdit.SelectedColor.Style:= [];
|
|
|
|
SynEdit.SelectedColor.Foreground:= clHighlightText;
|
|
|
|
SynEdit.SelectedColor.Background:= clHighlight;
|
|
|
|
Synedit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempEnable;
|
2010-01-03 14:27:09 -05:00
|
|
|
end;
|
2010-01-14 13:34:17 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.editSearchListExit(Sender: TObject);
|
|
|
|
begin
|
|
|
|
frmFunctionList.editSearchList.Color := clWhite;
|
|
|
|
StopCodeCompletion;
|
2009-12-24 20:34:14 -05:00
|
|
|
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);
|
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;
|
2010-01-14 13:34:17 -05:00
|
|
|
StopCodeCompletion;
|
2009-12-26 07:44:40 -05:00
|
|
|
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;
|
|
|
|
CurrScript.SynEdit.SetFocus;
|
|
|
|
end else
|
|
|
|
if key in [' ',',','.','(',')'] then //on on these chars we will insert the function!
|
|
|
|
begin;
|
2010-01-14 13:34:17 -05:00
|
|
|
StopCodeCompletion;
|
2009-12-26 07:44:40 -05:00
|
|
|
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;
|
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
|
2010-01-14 13:34:17 -05:00
|
|
|
// StatusBar.Panels[2].Text:= '';
|
2009-12-24 20:34:14 -05:00
|
|
|
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
|
2010-01-12 10:56:42 -05:00
|
|
|
SearchString := dlgReplace.FindText;
|
|
|
|
DoSearch(True, False);
|
2009-11-07 23:45:26 -05:00
|
|
|
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
|
2010-01-12 10:56:42 -05:00
|
|
|
SearchString :=LabeledEditSearch.Text;
|
|
|
|
DoSearch(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);
|
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;
|
2010-01-10 17:01:33 -05:00
|
|
|
FirstRun := true;//Our next run is the first run.
|
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);
|
|
|
|
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;
|
2010-01-12 10:56:42 -05:00
|
|
|
SearchString:= LabeledEditSearch.Text;
|
|
|
|
DoSearch(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
|
2010-01-12 13:07:47 -05:00
|
|
|
if frmFunctionList.FunctionList.Items.Count = 0 then
|
2009-12-24 11:21:31 -05:00
|
|
|
begin;
|
2010-01-12 13:07:47 -05:00
|
|
|
Methods := TMMLPSThread.GetExportedMethods;
|
|
|
|
Tree := frmFunctionList.FunctionList;
|
|
|
|
Tree.Items.Clear;
|
|
|
|
Sections := TStringList.Create;
|
|
|
|
LastSection := '';
|
|
|
|
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script');
|
|
|
|
for i := 0 to high(Methods) do
|
2009-12-24 11:21:31 -05:00
|
|
|
begin;
|
2010-01-12 13:07:47 -05:00
|
|
|
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;
|
2009-12-24 11:21:31 -05:00
|
|
|
end;
|
2010-01-12 13:07:47 -05:00
|
|
|
Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false));
|
|
|
|
Temp2Node.Data:= strnew(PChar(Methods[i].FuncDecl));
|
2009-12-24 11:21:31 -05:00
|
|
|
end;
|
2010-01-12 13:07:47 -05:00
|
|
|
Sections.free;
|
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;
|
|
|
|
|
More GUI changes
I started to work on a Bug Report form, but came to the conclusion, have no way of posting the information.
Wizzup, could you please post on the new thread about how to post to Mantis if you know?
I wrote up some new code for a new internets.pas currently in (newinternets.pas, whooda thunk?)
Its good, just needs some crucial things like physically openning the connections and closing them.
I added PostHTTP stuff, and need more ideas, I worked through Indy and found the right things so.. yeah!
Oh, and I added some more icons to the MainMenu from famfam.
Just to reiterate, the new AboutForm is a template, and the Image is copyrighted and will have to change.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@406 3f818213-9676-44b0-a9b4-5e4c4e03d09d
2010-01-13 00:11:11 -05:00
|
|
|
procedure TForm1.MenuItemReportBugClick(Sender: TObject);
|
|
|
|
begin
|
2010-01-15 19:16:49 -05:00
|
|
|
OpenURL('http://old.villavu.com/mantis/bug_report_page.php');
|
More GUI changes
I started to work on a Bug Report form, but came to the conclusion, have no way of posting the information.
Wizzup, could you please post on the new thread about how to post to Mantis if you know?
I wrote up some new code for a new internets.pas currently in (newinternets.pas, whooda thunk?)
Its good, just needs some crucial things like physically openning the connections and closing them.
I added PostHTTP stuff, and need more ideas, I worked through Indy and found the right things so.. yeah!
Oh, and I added some more icons to the MainMenu from famfam.
Just to reiterate, the new AboutForm is a template, and the Image is copyrighted and will have to change.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@406 3f818213-9676-44b0-a9b4-5e4c4e03d09d
2010-01-13 00:11:11 -05:00
|
|
|
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
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
if lowercase(LoadSettingDef('Settings/ColourPicker/ShowHistoryOnPick', 'True')) = 'true' then
|
2010-01-10 09:34:23 -05:00
|
|
|
begin
|
|
|
|
ColourHistoryForm.AddColObj(cobj, true);
|
|
|
|
ColourHistoryForm.Show;
|
|
|
|
end;
|
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;
|
|
|
|
|
2010-01-12 10:56:42 -05:00
|
|
|
procedure TForm1.PopupItemFindClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SearchString := CurrScript.SynEdit.SelText;
|
|
|
|
ActionFindNextExecute(ScriptPopup);
|
|
|
|
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;
|
|
|
|
|
2010-01-12 13:07:47 -05:00
|
|
|
function TForm1.LoadSettingDef(Key: string; Def: string): string;
|
|
|
|
begin
|
|
|
|
result := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists(Key,def,SimbaSettingsFile);
|
|
|
|
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
|
2010-01-17 20:25:02 -05:00
|
|
|
result := LoadScriptFile(filename);
|
2009-10-17 13:57:09 -04:00
|
|
|
finally
|
|
|
|
Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-01-17 20:25:02 -05:00
|
|
|
function TForm1.LoadScriptFile(FileName : string): boolean;
|
|
|
|
begin
|
|
|
|
if FileExists(FileName) then
|
|
|
|
begin;
|
|
|
|
with CurrScript do
|
|
|
|
begin
|
|
|
|
filename := SetDirSeparators(filename);
|
|
|
|
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;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-10-17 13:57:09 -04:00
|
|
|
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);
|
2010-01-14 13:34:17 -05:00
|
|
|
Writeln('Saving to: ' + FileName);
|
2009-10-31 17:44:13 -04:00
|
|
|
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;
|
2010-01-13 17:35:20 -05:00
|
|
|
case MessageDlg('Script is still running', 'Do you want to stop the script?',
|
|
|
|
mtConfirmation, mbYesNoCancel, 0) of
|
|
|
|
mrYes: StopScript;
|
|
|
|
end;
|
2009-10-31 17:44:13 -04:00
|
|
|
end else
|
2010-01-13 17:35:20 -05:00
|
|
|
case MessageDlg('Script is stopping.', 'Do you want to terminate the script?',
|
|
|
|
mtConfirmation, mbYesNoCancel, 0) of
|
|
|
|
mrNo, mrCancel: Result := false;
|
|
|
|
mrYes: StopScript;
|
|
|
|
end;
|
2009-10-31 17:44:13 -04:00
|
|
|
end;
|
|
|
|
if Result and (CurrScript.StartText <> CurrScript.SynEdit.Lines.text) then
|
2010-01-13 17:35:20 -05:00
|
|
|
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;
|
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.
|
|
|
|
|