mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-13 12:55:05 -05:00
Merge branch 'external-editor'
Conflicts: Projects/Simba/simbaunit.pas
This commit is contained in:
commit
4c1d67d1b6
@ -83,9 +83,13 @@ type
|
||||
procedure undo;
|
||||
procedure redo;
|
||||
procedure HandleErrorData;
|
||||
function GetReadOnly: Boolean;
|
||||
procedure SetReadOnly(ReadOnly: Boolean);
|
||||
procedure MakeActiveScriptFrame;
|
||||
procedure ScriptThreadTerminate(Sender: TObject);
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
|
||||
procedure ReloadScript;
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
@ -644,6 +648,37 @@ begin
|
||||
AddKey(SynEdit,ecCodeHints,VK_SPACE,[ssCtrl,ssShift]);
|
||||
end;
|
||||
|
||||
function TScriptFrame.GetReadOnly: Boolean;
|
||||
begin
|
||||
Result := SynEdit.ReadOnly;
|
||||
end;
|
||||
|
||||
procedure TScriptFrame.SetReadOnly(ReadOnly: Boolean);
|
||||
begin
|
||||
SynEdit.ReadOnly := ReadOnly;
|
||||
SynEdit.Enabled := not ReadOnly;
|
||||
if not ReadOnly and SynEdit.CanFocus then
|
||||
SynEdit.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TScriptFrame.ReloadScript;
|
||||
var
|
||||
newScript: String;
|
||||
ExternScript: TFileStream;
|
||||
begin
|
||||
try
|
||||
ExternScript := TFileStream.Create(ScriptFile, fmOpenRead);
|
||||
ExternScript.Read(NewScript, ExternScript.Size);
|
||||
|
||||
SynEdit.Lines.SetText(PChar(NewScript));
|
||||
except
|
||||
on EFOpenError do
|
||||
begin
|
||||
formWriteln('Could not open extern script :' + ScriptFile);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$R *.lfm}
|
||||
|
||||
|
@ -5,7 +5,7 @@ object SimbaForm: TSimbaForm
|
||||
Width = 660
|
||||
AllowDropFiles = True
|
||||
Caption = 'THA FUKING Simba'
|
||||
ClientHeight = 603
|
||||
ClientHeight = 598
|
||||
ClientWidth = 660
|
||||
KeyPreview = True
|
||||
Menu = MainMenu
|
||||
@ -207,8 +207,8 @@ object SimbaForm: TSimbaForm
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 580
|
||||
Height = 21
|
||||
Top = 577
|
||||
Width = 660
|
||||
Panels = <
|
||||
item
|
||||
@ -230,7 +230,7 @@ object SimbaForm: TSimbaForm
|
||||
object PanelMemo: TPanel
|
||||
Left = 0
|
||||
Height = 154
|
||||
Top = 426
|
||||
Top = 423
|
||||
Width = 660
|
||||
Align = alBottom
|
||||
ClientHeight = 154
|
||||
@ -253,19 +253,19 @@ object SimbaForm: TSimbaForm
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 421
|
||||
Top = 418
|
||||
Width = 660
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
end
|
||||
object ScriptPanel: TPanel
|
||||
Left = 0
|
||||
Height = 397
|
||||
Height = 394
|
||||
Top = 24
|
||||
Width = 660
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 397
|
||||
ClientHeight = 394
|
||||
ClientWidth = 660
|
||||
DockSite = True
|
||||
TabOrder = 4
|
||||
@ -273,7 +273,7 @@ object SimbaForm: TSimbaForm
|
||||
OnDockOver = ScriptPanelDockOver
|
||||
object PageControl1: TPageControl
|
||||
Left = 155
|
||||
Height = 362
|
||||
Height = 359
|
||||
Top = 0
|
||||
Width = 505
|
||||
Align = alClient
|
||||
@ -292,7 +292,7 @@ object SimbaForm: TSimbaForm
|
||||
object SearchPanel: TPanel
|
||||
Left = 0
|
||||
Height = 35
|
||||
Top = 362
|
||||
Top = 359
|
||||
Width = 660
|
||||
Align = alBottom
|
||||
BevelOuter = bvSpace
|
||||
@ -387,7 +387,7 @@ object SimbaForm: TSimbaForm
|
||||
end
|
||||
object LabeledEditSearch: TLabeledEdit
|
||||
Left = 104
|
||||
Height = 21
|
||||
Height = 27
|
||||
Top = 6
|
||||
Width = 80
|
||||
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
|
||||
@ -395,10 +395,10 @@ object SimbaForm: TSimbaForm
|
||||
EditLabel.AnchorSideTop.Side = asrCenter
|
||||
EditLabel.AnchorSideRight.Control = LabeledEditSearch
|
||||
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
|
||||
EditLabel.Left = 73
|
||||
EditLabel.Height = 14
|
||||
EditLabel.Top = 9
|
||||
EditLabel.Width = 28
|
||||
EditLabel.Left = 67
|
||||
EditLabel.Height = 18
|
||||
EditLabel.Top = 10
|
||||
EditLabel.Width = 34
|
||||
EditLabel.Caption = 'Find: '
|
||||
EditLabel.ParentColor = False
|
||||
LabelPosition = lpLeft
|
||||
@ -411,9 +411,9 @@ object SimbaForm: TSimbaForm
|
||||
end
|
||||
object CheckBoxMatchCase: TCheckBox
|
||||
Left = 320
|
||||
Height = 17
|
||||
Height = 22
|
||||
Top = 7
|
||||
Width = 72
|
||||
Width = 97
|
||||
Caption = 'Match case'
|
||||
OnClick = CheckBoxMatchCaseClick
|
||||
TabOrder = 1
|
||||
@ -421,34 +421,38 @@ object SimbaForm: TSimbaForm
|
||||
end
|
||||
object SplitterFunctionList: TSplitter
|
||||
Left = 150
|
||||
Height = 362
|
||||
Height = 359
|
||||
Top = 0
|
||||
Width = 5
|
||||
OnCanResize = SplitterFunctionListCanResize
|
||||
Visible = False
|
||||
end
|
||||
inline frmFunctionList: TFunctionListFrame
|
||||
Height = 362
|
||||
Height = 359
|
||||
Width = 150
|
||||
ClientHeight = 362
|
||||
ClientHeight = 359
|
||||
ClientWidth = 150
|
||||
OnEndDock = nil
|
||||
TabOrder = 3
|
||||
inherited FunctionList: TTreeView
|
||||
Height = 323
|
||||
Height = 310
|
||||
Top = 22
|
||||
Width = 150
|
||||
DefaultItemHeight = 19
|
||||
OnChange = FunctionListChange
|
||||
OnEnter = FunctionListEnter
|
||||
OnExit = FunctionListExit
|
||||
end
|
||||
inherited editSearchList: TEdit
|
||||
Top = 341
|
||||
Height = 27
|
||||
Top = 332
|
||||
Width = 150
|
||||
OnExit = editSearchListExit
|
||||
OnKeyDown = editSearchListKeyDown
|
||||
OnKeyPress = editSearchListKeyPress
|
||||
end
|
||||
inherited FunctionListLabel: TLabel
|
||||
Height = 18
|
||||
Width = 146
|
||||
end
|
||||
end
|
||||
@ -2839,6 +2843,10 @@ object SimbaForm: TSimbaForm
|
||||
Caption = 'Close Other Tabs'
|
||||
OnClick = MenuItemTabCloseOthersClick
|
||||
end
|
||||
object MenuItemReadOnlyTab: TMenuItem
|
||||
Caption = 'Read Only'
|
||||
OnClick = MenuItemReadOnlyTabClick
|
||||
end
|
||||
end
|
||||
object ActionList: TActionList
|
||||
Images = Mufasa_Image_List
|
||||
|
@ -30,7 +30,7 @@ unit SimbaUnit;
|
||||
interface
|
||||
|
||||
uses
|
||||
{$ifdef linux}cthreads,{$endif}Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
{$ifdef linux}cthreads,cmem,{$endif}Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Menus, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas,
|
||||
//Client,
|
||||
MufasaTypes,
|
||||
@ -116,6 +116,7 @@ type
|
||||
MenuHelp: TMenuItem;
|
||||
MenuDivider7: TMenuItem;
|
||||
MenuInterpreters: TMenuItem;
|
||||
MenuItemReadOnlyTab: TMenuItem;
|
||||
MenuItemGoto: TMenuItem;
|
||||
MenuItemDivider50: TMenuItem;
|
||||
MenuItemPascalScript: TMenuItem;
|
||||
@ -288,6 +289,7 @@ type
|
||||
procedure FunctionListEnter(Sender: TObject);
|
||||
procedure FunctionListExit(Sender: TObject);
|
||||
procedure FunctionListTimerTimer(Sender: TObject);
|
||||
procedure MenuItemReadOnlyTabClick(Sender: TObject);
|
||||
procedure MenuItemBitmapConvClick(Sender: TObject);
|
||||
procedure MenuItemHandbookClick(Sender: TObject);
|
||||
procedure MenuItemColourHistoryClick(Sender: TObject);
|
||||
@ -408,7 +410,7 @@ type
|
||||
procedure SetScriptState(const State: TScriptState);
|
||||
function CreateSetting(const Key, Value : string) : string;
|
||||
procedure SetSetting(const key,Value : string; save : boolean = false);
|
||||
function SettingExtists(const key : string) : boolean;
|
||||
function SettingExists(const key : string) : boolean;
|
||||
procedure FontUpdate;
|
||||
public
|
||||
DebugStream: String;
|
||||
@ -1191,7 +1193,8 @@ begin
|
||||
if Self.Showing then
|
||||
if Tab.TabSheet.TabIndex = Self.PageControl1.TabIndex then
|
||||
if CurrScript.SynEdit.CanFocus then
|
||||
CurrScript.SynEdit.SetFocus;
|
||||
CurrScript.SynEdit.SetFocus; // XXX: This is never called
|
||||
|
||||
StopCodeCompletion;//To set the highlighting back to normal;
|
||||
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
||||
with CurrScript.SynEdit do
|
||||
@ -1204,6 +1207,7 @@ begin
|
||||
LabeledEditSearch.SelLength:= 0;
|
||||
LabeledEditSearch.Color:= clWindow;
|
||||
LabeledEditSearch.Font.Color:= clWindowText;
|
||||
|
||||
//Set tha edit buttons right
|
||||
SetEditActions;
|
||||
end;
|
||||
@ -1294,7 +1298,7 @@ begin
|
||||
else
|
||||
// if str = 'normal' then
|
||||
Self.WindowState := wsNormal;
|
||||
if SettingExtists('LastConfig/MainForm/RecentFiles/Count') then
|
||||
if SettingExists('LastConfig/MainForm/RecentFiles/Count') then
|
||||
begin;
|
||||
ii := StrToIntDef(LoadSettingDef('LastConfig/MainForm/RecentFiles/Count','-1'),-1);
|
||||
for i := 0 to ii do
|
||||
@ -1385,7 +1389,7 @@ var
|
||||
if (number < 0) or (number >= extCount) then
|
||||
exit;
|
||||
path := 'Extensions/Extension' + inttostr(number);
|
||||
if SettingExtists(Path) = false then
|
||||
if SettingExists(Path) = false then
|
||||
exit;
|
||||
ExtPath := LoadSettingDef(Path + '/Path','');
|
||||
if ExtPath = '' then
|
||||
@ -1454,8 +1458,16 @@ var
|
||||
Se: TMMLSettingsSandbox;
|
||||
loadFontsOnScriptStart: boolean;
|
||||
Continue : boolean;
|
||||
|
||||
begin
|
||||
Script :=CurrScript.SynEdit.Lines.Text;
|
||||
if (CurrScript.ScriptFile <> '') and CurrScript.GetReadOnly() then
|
||||
begin
|
||||
formWriteln('Reloading read only script');
|
||||
CurrScript.ReloadScript;
|
||||
end;
|
||||
|
||||
Script := CurrScript.SynEdit.Lines.Text;
|
||||
|
||||
if Assigned(OnScriptStart) then
|
||||
begin
|
||||
Continue := True;
|
||||
@ -1480,6 +1492,7 @@ begin
|
||||
Thread.SetDebug(@formWriteln);
|
||||
{$ENDIF}
|
||||
Thread.SetScript(Script);
|
||||
|
||||
Thread.ErrorData:= @CurrScript.ErrorData;
|
||||
Thread.OnError:= @CurrScript.HandleErrorData;
|
||||
FormCallBackData.FormCallBack:= @self.FormCallBack;
|
||||
@ -2081,7 +2094,7 @@ end;
|
||||
|
||||
procedure TSimbaForm.MenuItemHandbookClick(Sender: TObject);
|
||||
begin
|
||||
OpenURL('http://wizzup.org/simbadoc/');
|
||||
OpenURL('http://docs.wizzup.org/simba/');
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.MenuItemColourHistoryClick(Sender: TObject);
|
||||
@ -2571,6 +2584,17 @@ begin
|
||||
CloseTabs(PopupTab);
|
||||
end;
|
||||
|
||||
|
||||
procedure TSimbaForm.MenuItemReadOnlyTabClick(Sender: TObject);
|
||||
var
|
||||
Tab: TMufasaTab;
|
||||
|
||||
begin
|
||||
Tab := TMufasaTab(Tabs[PopupTab]);
|
||||
Tab.ScriptFrame.SetReadOnly(not Tab.ScriptFrame.GetReadOnly());
|
||||
MenuItemReadOnlyTab.Checked := not Tab.ScriptFrame.GetReadOnly();
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.MenuItemFunctionListClick(Sender: TObject);
|
||||
begin
|
||||
FunctionListShown(not MenuItemFunctionList.Checked);
|
||||
@ -2684,6 +2708,9 @@ begin
|
||||
begin
|
||||
mDebugLn('We couldn''t find which tab you clicked on, closing the popup');
|
||||
Handled := true;
|
||||
end else
|
||||
begin
|
||||
MenuItemReadOnlyTab.Checked := TMufasaTab(Tabs[PopupTab]).ScriptFrame.GetReadOnly();
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2874,7 +2901,7 @@ begin
|
||||
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
|
||||
end;
|
||||
|
||||
function TSimbaForm.SettingExtists(const key: string): boolean;
|
||||
function TSimbaForm.SettingExists(const key: string): boolean;
|
||||
begin
|
||||
result :=SettingsForm.Settings.KeyExists(key);
|
||||
end;
|
||||
@ -3065,7 +3092,7 @@ end;
|
||||
|
||||
procedure TSimbaForm.UpdateTitle;
|
||||
begin
|
||||
Application.Title:= PChar('Simba');
|
||||
Application.Title:= PChar('Simba'); // XXX - Sure you want to do this for Disguise?
|
||||
if CurrScript.ScriptChanged then
|
||||
begin;
|
||||
CurrTab.TabSheet.Caption:= CurrScript.ScriptName + '*';
|
||||
@ -3165,6 +3192,11 @@ end;
|
||||
|
||||
function TSimbaForm.SaveCurrentScript: boolean;
|
||||
begin
|
||||
if CurrScript.GetReadOnly() then
|
||||
begin
|
||||
formWriteln('Script is in read-only/external editor mode. Not saving!');
|
||||
exit(false);
|
||||
end;
|
||||
if not CurrScript.ScriptChanged then
|
||||
begin
|
||||
writeln('SaveScript - no changes.');
|
||||
|
Loading…
Reference in New Issue
Block a user