mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-25 18:52:15 -05:00
Merge branch 'master' of ssh://villavu.com:54367/simba
This commit is contained in:
commit
ca34d1011c
@ -88,13 +88,13 @@ type
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1): string;
|
||||
function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1; Offset: Integer = 0): string;
|
||||
|
||||
implementation
|
||||
uses
|
||||
SimbaUnit, SynEditTypes, LCLIntF, StrUtils,framefunctionlist;
|
||||
SimbaUnit, MufasaTypes, SynEditTypes, LCLIntF, StrUtils,framefunctionlist;
|
||||
|
||||
function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1): string;
|
||||
function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1; Offset: Integer = 0): string;
|
||||
var
|
||||
s: string;
|
||||
l: Integer;
|
||||
@ -102,6 +102,7 @@ begin
|
||||
Result := '';
|
||||
if (Start = -1) then
|
||||
Start := e.CaretX;
|
||||
Start := Start + Offset;
|
||||
sp := Start - 1;
|
||||
ep := Start - 1;
|
||||
s := e.Lines[e.CaretY - 1];
|
||||
@ -222,11 +223,17 @@ var
|
||||
s: string;
|
||||
sp, ep: Integer;
|
||||
begin
|
||||
if (Command = ecChar) and (AChar = '(') and (SimbaForm.ParamHint.Visible = false) and (SimbaForm.ShowHintAuto) then
|
||||
begin
|
||||
Command2:= ecCodeHints;
|
||||
SynEditProcessUserCommand(sender,command2,achar,nil);
|
||||
end;
|
||||
if (Command = ecChar) then
|
||||
if(AChar = '(') and (SimbaForm.ParamHint.Visible = False) and (SimbaForm.ShowParamHintAuto) then
|
||||
begin
|
||||
Command2:= ecCodeHints;
|
||||
SynEditProcessUserCommand(sender,command2,achar,nil);
|
||||
end
|
||||
else if(AChar = '.') and (SimbaForm.CodeCompletionForm.Visible = False) and (SimbaForm.ShowCodeCompletionAuto) then
|
||||
begin
|
||||
Command2:= ecCodeCompletion;
|
||||
SynEditProcessUserCommand(sender,command2,achar, Pointer(@s));
|
||||
end;
|
||||
|
||||
if SimbaForm.CodeCompletionForm.Visible then
|
||||
case Command of
|
||||
@ -328,43 +335,6 @@ begin
|
||||
if (Command = ecCodeCompletion) and ((not SynEdit.GetHighlighterAttriAtRowCol(SynEdit.CaretXY, s, Attri)) or
|
||||
((Attri.Name <> SYNS_AttrComment) and (Attri.name <> SYNS_AttrString) and (Attri.name <> SYNS_AttrDirective))) then
|
||||
begin
|
||||
{SimbaForm.FunctionListShown(True);
|
||||
with SimbaForm.frmFunctionList do
|
||||
if editSearchList.CanFocus then
|
||||
begin;
|
||||
editSearchList.SetFocus;
|
||||
LineText := SynEdit.LineText;
|
||||
Caret:=SynEdit.LogicalCaretXY;
|
||||
i := Caret.X - 1;
|
||||
endi := caret.x;
|
||||
if (i > length(LineText)) or ((i = 0) and (length(lineText) = 0)) then
|
||||
begin
|
||||
SearchText:= '';
|
||||
CompletionLine := PadRight(linetext,caret.x);
|
||||
end
|
||||
else begin
|
||||
while (i > 0) and (LineText[i] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
||||
dec(i);
|
||||
while LineText[endi] in ['a'..'z','A'..'Z','0'..'9','_'] do
|
||||
inc(endi);
|
||||
SearchText := Trim(copy(LineText, i + 1, Caret.X - i - 1));
|
||||
CompletionLine := LineText;
|
||||
end;
|
||||
CompletionStart:= LineText;
|
||||
Delete(CompletionLine,i+1,endi - i - 1);
|
||||
Insert('%s',CompletionLine,i+1);
|
||||
CompletionCaret := Point(endi,Caret.y);
|
||||
StartWordCompletion:= Point(i+1,caret.y);
|
||||
mDebugLn(CompletionLine);
|
||||
mDebugLn(CompletionStart);
|
||||
InCodeCompletion := true;
|
||||
editSearchList.Text:= SearchText;
|
||||
editSearchList.SelStart:= Length(searchText);
|
||||
SynEdit.SelectedColor.Style:= [fsUnderline];
|
||||
SynEdit.SelectedColor.Foreground:= clBlack;
|
||||
SynEdit.SelectedColor.Background:= clWhite;
|
||||
Synedit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempDisable;
|
||||
end;}
|
||||
mp := TCodeInsight.Create;
|
||||
mp.FileName := ScriptFile;
|
||||
mp.OnMessage := @SimbaForm.OnCCMessage;
|
||||
@ -399,10 +369,17 @@ begin
|
||||
s := '';
|
||||
end;
|
||||
|
||||
mp.FillSynCompletionProposal(ItemList, InsertList, s);
|
||||
p := SynEdit.ClientToScreen(SynEdit.RowColumnToPixels(Point(ep, SynEdit.CaretY)));
|
||||
p.y := p.y + SynEdit.LineHeight;
|
||||
SimbaForm.CodeCompletionForm.Show(p, ItemList, InsertList, Filter, SynEdit);
|
||||
if (Data <> nil) then //If showing automatically
|
||||
if (s <> '') and (((mp.DeclarationAtPos <> nil) and (mp.DeclarationAtPos is TciCompoundStatement)) or ((mp.DeclarationAtPos.Owner <> nil) and (mp.DeclarationAtPos.Owner is TciCompoundStatement))) then
|
||||
Data := nil;
|
||||
|
||||
if (Data = nil) then
|
||||
begin
|
||||
mp.FillSynCompletionProposal(ItemList, InsertList, s);
|
||||
p := SynEdit.ClientToScreen(SynEdit.RowColumnToPixels(Point(ep, SynEdit.CaretY)));
|
||||
p.y := p.y + SynEdit.LineHeight;
|
||||
SimbaForm.CodeCompletionForm.Show(p, ItemList, InsertList, Filter, SynEdit);
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(ms);
|
||||
FreeAndNil(mp);
|
||||
@ -425,9 +402,9 @@ begin
|
||||
Synedit.GetWordBoundsAtRowCol(Synedit.CaretXY, sp, ep);
|
||||
s := SynEdit.Lines[SynEdit.Carety-1];
|
||||
if ep > length(s) then //We are outside the real text, go back to the last char
|
||||
mp.Run(ms, nil, Synedit.SelStart - ep + length(s),true)
|
||||
mp.Run(ms, nil, Synedit.SelStart - ep + length(s), True)
|
||||
else
|
||||
mp.Run(ms, nil, Synedit.SelStart + (ep - Synedit.CaretX) - 1,true);
|
||||
mp.Run(ms, nil, Synedit.SelStart + (ep - Synedit.CaretX) - 1, True);
|
||||
bcc := 1;bck := 0;cc := 0;
|
||||
s := mp.GetExpressionAtPos(bcc, bck, cc,posi, true);
|
||||
|
||||
@ -463,7 +440,7 @@ begin
|
||||
d := d.Owner;
|
||||
if (TciProcedureDeclaration(d).Params <> '') then
|
||||
SimbaForm.ParamHint.Show(PosToCaretXY(synedit,posi + 1), PosToCaretXY(synedit,bracketpos),
|
||||
TciProcedureDeclaration(d), synedit,mp)
|
||||
TciProcedureDeclaration(d), synedit,mp)
|
||||
else
|
||||
FormWriteln('<no parameters expected>');
|
||||
end;
|
||||
@ -544,8 +521,6 @@ begin
|
||||
end;
|
||||
|
||||
procedure TScriptFrame.HandleErrorData;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
if ErrorData.Module <> '' then
|
||||
begin;
|
||||
@ -610,6 +585,9 @@ begin
|
||||
inherited Create(TheOwner);
|
||||
OwnerSheet := TTabSheet(TheOwner);
|
||||
OwnerPage := TPageControl(OwnerSheet.Owner);
|
||||
|
||||
if FileExists(MainDir + DS + 'default.simba') then
|
||||
SynEdit.Lines.LoadFromFile(MainDir + DS + 'default.simba');
|
||||
StartText:= SynEdit.Lines.text;
|
||||
ScriptDefault:= StartText;
|
||||
ScriptName:= 'Untitled';
|
||||
|
@ -592,6 +592,10 @@ object SimbaForm: TSimbaForm
|
||||
Caption = 'Save as...'
|
||||
OnClick = ActionSaveAsExecute
|
||||
end
|
||||
object MenuItemSaveDef: TMenuItem
|
||||
Action = ActionSaveDef
|
||||
OnClick = ActionSaveDefExecute
|
||||
end
|
||||
object MenuItemSaveAll: TMenuItem
|
||||
Action = ActionSaveAll
|
||||
Enabled = False
|
||||
@ -2693,6 +2697,16 @@ object SimbaForm: TSimbaForm
|
||||
Caption = 'Save as..'
|
||||
OnExecute = ActionSaveAsExecute
|
||||
end
|
||||
object ActionSaveDef: TAction
|
||||
Caption = 'Save as Default'
|
||||
OnExecute = ActionSaveDefExecute
|
||||
end
|
||||
object ActionSaveAll: TAction
|
||||
Caption = 'Save All'
|
||||
ImageIndex = 21
|
||||
OnExecute = ActionSaveAllExecute
|
||||
ShortCut = 24659
|
||||
end
|
||||
object ActionRunScript: TAction
|
||||
Caption = '&Run'
|
||||
OnExecute = ActionRunExecute
|
||||
@ -2707,12 +2721,6 @@ object SimbaForm: TSimbaForm
|
||||
OnExecute = ActionStopExecute
|
||||
ShortCut = 113
|
||||
end
|
||||
object ActionSaveAll: TAction
|
||||
Caption = 'Save All'
|
||||
ImageIndex = 21
|
||||
OnExecute = ActionSaveAllExecute
|
||||
ShortCut = 24659
|
||||
end
|
||||
object ActionClearDebug: TAction
|
||||
Caption = 'Clear'
|
||||
ImageIndex = 4
|
||||
@ -3090,7 +3098,24 @@ object SimbaForm: TSimbaForm
|
||||
left = 488
|
||||
top = 200
|
||||
end
|
||||
object LazHighlighter: TSynFreePascalSyn
|
||||
object FunctionListTimer: TTimer
|
||||
Interval = 750
|
||||
OnTimer = FunctionListTimerTimer
|
||||
left = 608
|
||||
top = 200
|
||||
end
|
||||
object SCARHighlighter: TSynPasSyn
|
||||
Enabled = False
|
||||
CommentAttri.Foreground = clGreen
|
||||
CommentAttri.Style = []
|
||||
NumberAttri.Foreground = clNavy
|
||||
StringAttri.Foreground = clFuchsia
|
||||
CompilerMode = pcmObjFPC
|
||||
NestedComments = False
|
||||
left = 568
|
||||
top = 200
|
||||
end
|
||||
object LazHighlighter: TSynPasSyn
|
||||
Enabled = False
|
||||
CommentAttri.Foreground = clBlue
|
||||
CommentAttri.Style = [fsBold]
|
||||
@ -3106,21 +3131,4 @@ object SimbaForm: TSimbaForm
|
||||
left = 528
|
||||
top = 200
|
||||
end
|
||||
object SCARHighlighter: TSynFreePascalSyn
|
||||
Enabled = False
|
||||
CommentAttri.Foreground = clGreen
|
||||
CommentAttri.Style = []
|
||||
NumberAttri.Foreground = clHotLight
|
||||
StringAttri.Foreground = clFuchsia
|
||||
CompilerMode = pcmObjFPC
|
||||
NestedComments = False
|
||||
left = 568
|
||||
top = 200
|
||||
end
|
||||
object FunctionListTimer: TTimer
|
||||
Interval = 750
|
||||
OnTimer = FunctionListTimerTimer
|
||||
left = 608
|
||||
top = 200
|
||||
end
|
||||
end
|
||||
|
@ -67,6 +67,7 @@ type
|
||||
{ TSimbaForm }
|
||||
|
||||
TSimbaForm = class(TForm)
|
||||
ActionSaveDef: TAction;
|
||||
ActionConsole: TAction;
|
||||
ActionNormalSize: TAction;
|
||||
ActionCompileScript: TAction;
|
||||
@ -96,14 +97,15 @@ type
|
||||
ActionTabNext: TAction;
|
||||
ActionList: TActionList;
|
||||
CheckBoxMatchCase: TCheckBox;
|
||||
LazHighlighter: TSynFreePascalSyn;
|
||||
frmFunctionList: TFunctionListFrame;
|
||||
LabeledEditSearch: TLabeledEdit;
|
||||
LazHighlighter: TSynPasSyn;
|
||||
MainMenu: TMainMenu;
|
||||
Memo1: TMemo;
|
||||
MenuFile: TMenuItem;
|
||||
MenuEdit: TMenuItem;
|
||||
MenuHelp: TMenuItem;
|
||||
MenuItemSaveDef: TMenuItem;
|
||||
MenuItemBitmapConv: TMenuItem;
|
||||
MenuItemExtensions: TMenuItem;
|
||||
MenuItemSettingsButton: TMenuItem;
|
||||
@ -118,8 +120,8 @@ type
|
||||
MenuItemDivider9: TMenuItem;
|
||||
MouseTimer: TTimer;
|
||||
NewsTimer: TTimer;
|
||||
SCARHighlighter: TSynFreePascalSyn;
|
||||
FunctionListTimer: TTimer;
|
||||
SCARHighlighter: TSynPasSyn;
|
||||
TT_Console: TToolButton;
|
||||
TT_Cut: TToolButton;
|
||||
TT_Copy: TToolButton;
|
||||
@ -240,6 +242,7 @@ type
|
||||
procedure ActionRunExecute(Sender: TObject);
|
||||
procedure ActionSaveAllExecute(Sender: TObject);
|
||||
procedure ActionSaveAsExecute(Sender: TObject);
|
||||
procedure ActionSaveDefExecute(Sender: TObject);
|
||||
procedure ActionSaveExecute(Sender: TObject);
|
||||
procedure ActionSelectAllExecute(Sender: TObject);
|
||||
procedure ActionStopExecute(Sender: TObject);
|
||||
@ -359,14 +362,16 @@ type
|
||||
function GetIncludePath: String;
|
||||
function GetPluginPath: string;
|
||||
function GetScriptState: TScriptState;
|
||||
function GetShowHintAuto: boolean;
|
||||
function GetShowParamHintAuto: boolean;
|
||||
function GetShowCodeCompletionAuto: Boolean;
|
||||
function GetSimbaNews: String;
|
||||
procedure SetExtPath(const AValue: string);
|
||||
procedure SetFontPath(const AValue: String);
|
||||
procedure SetIncludePath(const AValue: String);
|
||||
procedure SetPluginPath(const AValue: string);
|
||||
procedure SetScriptPath(const AValue: string);
|
||||
procedure SetShowHintAuto(const AValue: boolean);
|
||||
procedure SetShowParamHintAuto(const AValue: boolean);
|
||||
procedure SetShowCodeCompletionAuto(const AValue: boolean);
|
||||
procedure SetScriptState(const State: TScriptState);
|
||||
function LoadSettingDef(const Key, Def : string) : string;
|
||||
function CreateSetting(const Key, Value : string) : string;
|
||||
@ -398,6 +403,7 @@ type
|
||||
function LoadScriptFile(filename : string; AlwaysOpenInNewTab : boolean = false; CheckOtherTabs : boolean = true) : boolean;
|
||||
function SaveCurrentScript : boolean;
|
||||
function SaveCurrentScriptAs : boolean;
|
||||
function SaveCurrentScriptAsDefault : boolean;
|
||||
function CanExitOrOpen : boolean;
|
||||
function ClearScript : boolean;
|
||||
procedure RunScript;
|
||||
@ -421,7 +427,8 @@ type
|
||||
procedure InitalizeTMThread(var Thread : TMThread);
|
||||
procedure HandleParameters;
|
||||
procedure OnSaveScript(const Filename : string);
|
||||
property ShowHintAuto : boolean read GetShowHintAuto write SetShowHintAuto;
|
||||
property ShowParamHintAuto : boolean read GetShowParamHintAuto write SetShowParamHintAuto;
|
||||
property ShowCodeCompletionAuto: Boolean read GetShowCodeCompletionAuto write SetShowCodeCompletionAuto;
|
||||
property IncludePath : String read GetIncludePath write SetIncludePath;
|
||||
property FontPath : String read GetFontPath write SetFontPath;
|
||||
property PluginPath : string read GetPluginPath write SetPluginPath;
|
||||
@ -1163,6 +1170,7 @@ begin
|
||||
CreateSetting('Settings/MainForm/NormalSize','739:555');
|
||||
CreateSetting('Settings/FunctionList/ShowOnStart','True');
|
||||
CreateSetting('Settings/CodeHints/ShowAutomatically','True');
|
||||
CreateSetting('Settings/CodeCompletion/ShowAutomatically','True');
|
||||
CreateSetting('Settings/SourceEditor/LazColors','True');
|
||||
CreateSetting('Settings/Extensions/FileExtension','sex');
|
||||
|
||||
@ -1691,6 +1699,11 @@ begin
|
||||
Self.SaveCurrentScriptAs;
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.ActionSaveDefExecute(Sender: TObject);
|
||||
begin
|
||||
Self.SaveCurrentScriptAsDefault;
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.ActionSaveExecute(Sender: TObject);
|
||||
begin
|
||||
Self.SaveCurrentScript;
|
||||
@ -2093,7 +2106,6 @@ begin
|
||||
//AutoCompletionStart := Point(-1, -1);
|
||||
CodeCompletionForm := TAutoCompletePopup.Create(Self);
|
||||
CodeCompletionForm.InsertProc := @OnCompleteCode;
|
||||
|
||||
ParamHint := TParamHint.Create(self);
|
||||
|
||||
{$ifdef MSWindows}
|
||||
@ -2580,11 +2592,16 @@ begin
|
||||
result := CurrScript.FScriptState;
|
||||
end;
|
||||
|
||||
function TSimbaForm.GetShowHintAuto: boolean;
|
||||
function TSimbaForm.GetShowParamHintAuto: boolean;
|
||||
begin
|
||||
Result := LowerCase(LoadSettingDef('Settings/CodeHints/ShowAutomatically','True')) = 'true';
|
||||
end;
|
||||
|
||||
function TSimbaForm.GetShowCodeCompletionAuto: boolean;
|
||||
begin
|
||||
Result := LowerCase(LoadSettingDef('Settings/CodeCompletion/ShowAutomatically','True')) = 'true';
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.SetFontPath(const AValue: String);
|
||||
begin
|
||||
SetSetting('Settings/Fonts/Path',AValue,true);
|
||||
@ -2755,9 +2772,14 @@ begin
|
||||
TThread.Synchronize(nil,@HandleScriptStartData);
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.SetShowHintAuto(const AValue: boolean);
|
||||
procedure TSimbaForm.SetShowParamHintAuto(const AValue: boolean);
|
||||
begin
|
||||
SetSetting('Settings/CodeHints/ShowAutomatically',Booltostr(AValue,true));
|
||||
SetSetting('Settings/CodeHints/ShowAutomatically', Booltostr(AValue,true));
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.SetShowCodeCompletionAuto(const AValue: boolean);
|
||||
begin
|
||||
SetSetting('Settings/CodeCompletion/ShowAutomatically', Booltostr(AValue,true));
|
||||
end;
|
||||
|
||||
{$ifdef mswindows}
|
||||
@ -2844,6 +2866,7 @@ end;
|
||||
|
||||
function TSimbaForm.OpenScript: boolean;
|
||||
var
|
||||
i: Integer;
|
||||
OpenInNewTab : boolean;
|
||||
begin
|
||||
Result := False;
|
||||
@ -2853,11 +2876,19 @@ begin
|
||||
Exit;
|
||||
with TOpenDialog.Create(nil) do
|
||||
try
|
||||
Filter:= 'Simba Files|*.Simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+
|
||||
Options := [ofAllowMultiSelect, ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail];
|
||||
Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+
|
||||
'|Any files|*.*';
|
||||
if Execute then
|
||||
if FileExistsUTF8(filename) then
|
||||
result := LoadScriptFile(filename);
|
||||
begin
|
||||
Result := True;
|
||||
for i := 0 to Files.Count - 1 do
|
||||
if (not FileExistsUTF8(Files[i])) or (not LoadScriptFile(Files[i])) then
|
||||
begin
|
||||
Result := False;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
@ -2953,6 +2984,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSimbaForm.SaveCurrentScriptAsDefault : boolean;
|
||||
begin
|
||||
with CurrScript do
|
||||
begin
|
||||
try
|
||||
SynEdit.Lines.SaveToFile(MainDir + DS + 'default.simba');
|
||||
mDebugLn('Script saved as default.');
|
||||
Result := True;
|
||||
except
|
||||
mDebugLn('Cannot save script as default.');
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSimbaForm.CanExitOrOpen: boolean;
|
||||
begin;
|
||||
Self.Enabled := False;//We HAVE to answer the popup
|
||||
|
Loading…
Reference in New Issue
Block a user