From 6a20a971a434f893764387da58a51bcce25686b3 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 16 Aug 2014 03:08:02 +0200 Subject: [PATCH] implemented expandSymbolicString, added usage for several TProcess.Parameters, added a runnable d test for current constants --- lazproj/test/src/expandSymString.d | 19 ++++++ src/ce_editor.lfm | 5 +- src/ce_main.lfm | 4 +- src/ce_main.pas | 99 +++++++++++++++++++++++++++++- 4 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 lazproj/test/src/expandSymString.d diff --git a/lazproj/test/src/expandSymString.d b/lazproj/test/src/expandSymString.d new file mode 100644 index 00000000..54e90c24 --- /dev/null +++ b/lazproj/test/src/expandSymString.d @@ -0,0 +1,19 @@ +module runnable; + +import std.stdio; +import std.getopt; + +// pass --a= --b= --c= --d= --e= --f= --g= as parameters in "Run file..." +void main(string args[]) +{ + + string expanded; + for (char c = 'a'; c != 'z'; c++) + { + expanded = ""; + getopt(args, std.getopt.config.passThrough, c, &expanded); + if (expanded.length != 0) + writeln(expanded); + } + +} diff --git a/src/ce_editor.lfm b/src/ce_editor.lfm index 9a5095c4..62d2d46a 100644 --- a/src/ce_editor.lfm +++ b/src/ce_editor.lfm @@ -98,12 +98,13 @@ inherited CEEditorWidget: TCEEditorWidget object completion: TSynCompletion[4] OnExecute = completionExecute Position = 0 - LinesInWindow = 6 + LinesInWindow = 8 SelectedColor = clHighlight CaseSensitive = True Width = 262 + ShowSizeDrag = True ShortCut = 16416 - EndOfTokenChr = '()[].' + EndOfTokenChr = '()[].!+"''(-*/\$:;?<>' OnCodeCompletion = completionCodeCompletion ExecCommandID = ecSynCompletionExecute left = 96 diff --git a/src/ce_main.lfm b/src/ce_main.lfm index 5c3243ec..2077dbaf 100644 --- a/src/ce_main.lfm +++ b/src/ce_main.lfm @@ -1936,6 +1936,7 @@ object CEMainForm: TCEMainForm Caption = 'Compile and run file...' ImageIndex = 22 OnExecute = ActFileCompAndRunWithArgsExecute + ShortCut = 24695 end object actFileSaveAll: TAction Category = 'File' @@ -3039,9 +3040,6 @@ object CEMainForm: TCEMainForm } end object ApplicationProperties1: TApplicationProperties - HintHidePause = 4000 - HintPause = 100 - HintShortPause = 50 OnException = ApplicationProperties1Exception OnShowHint = ApplicationProperties1ShowHint left = 96 diff --git a/src/ce_main.pas b/src/ce_main.pas index 31c02c97..45950e37 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -866,7 +866,10 @@ begin CanShow := true; {if EditWidget.currentEditor <> nil then if EditWidget.currentEditor.Focused then - HintStr := EditWidget.getEditorHint;} + begin + HintStr := EditWidget.getEditorHint; + CanShow := HintStr <> ''; + end;} end; {$ENDREGION} @@ -1272,7 +1275,7 @@ begin fMesgWidg.addCeInf(editor.fileName + ' successfully compiled', mcEditor ); runproc.Options := [poStderrToOutPut, poUsePipes]; runproc.CurrentDirectory := extractFilePath(runProc.Executable); - runproc.Parameters.DelimitedText := runArgs; + runproc.Parameters.DelimitedText := expandSymbolicString(runArgs); runproc.Executable := fname {$IFDEF WINDOWS}+ '.exe'{$ENDIF}; runproc.Execute; repeat ProcessOutputToMsg(runproc, mcEditor) until not runproc.Running; @@ -1316,6 +1319,8 @@ begin ppproc := TProcess.Create(nil); try preBuildProcess.setProcess(ppproc); + for i:= 0 to ppproc.Parameters.Count-1 do + ppproc.Parameters.Strings[i] := expandSymbolicString(ppproc.Parameters.Strings[i]); if ppproc.CurrentDirectory = '' then ppproc.CurrentDirectory := extractFilePath(ppproc.Executable); ppproc.Execute; @@ -1371,6 +1376,8 @@ begin ppproc := TProcess.Create(nil); try postBuildProcess.setProcess(ppproc); + for i:= 0 to ppproc.Parameters.Count-1 do + ppproc.Parameters.Strings[i] := expandSymbolicString(ppproc.Parameters.Strings[i]); if ppproc.CurrentDirectory = '' then ppproc.CurrentDirectory := extractFilePath(ppproc.Executable); ppproc.Execute; @@ -1408,6 +1415,7 @@ begin prm := ''; i := 1; repeat prm := ExtractDelimited(i, runArgs, [' ']); + prm := expandSymbolicString(prm); if prm <> '' then runProc.Parameters.AddText(prm); Inc(i); @@ -1849,9 +1857,94 @@ end; {$ENDREGION} function TCEMainForm.expandSymbolicString(const symString: string): string; +var + elems: TStringList; + elem: string; + begs, ends: boolean; + i: integer; begin - // expands some symbolic constant, e.g: project path, current file name, etc. result := ''; + elems := TStringList.Create; + try + i := 0; + elem := ''; + repeat + inc(i); + if not (symString[i] in ['<', '>']) then + elem += symString[i] + else + begin + if symString[i] = '<' then + begs := true; + ends := symString[i] = '>'; + elems.Add(elem); + elem := ''; + if begs and ends then + begin + begs := false; + ends := false; + elems.Objects[elems.Count-1] := Self; + end; + end; + until + i = length(symString); + elems.Add(elem); + elem := ''; + for i:= 0 to elems.Count-1 do + begin + if elems.Objects[i] = nil then + result += elems.Strings[i] + else case elems.Strings[i] of + '<','>' : + continue; + 'CPF', 'CurrentProjectFile': + begin + result += '`'; + if fProject <> nil then + if fileExists(fProject.fileName) then + result += fProject.fileName; + result += '`'; + end; + 'CPP', 'CurrentProjectPath': + begin + result += '`'; + if fProject <> nil then + if fileExists(fProject.fileName) then + result += extractFilePath(fProject.fileName); + result += '`'; + end; + 'CFF', 'CurrentFileFile': + begin + result += '`'; + if EditWidget.currentEditor <> nil then + if fileExists(EditWidget.currentEditor.fileName) then + result += EditWidget.currentEditor.fileName; + result += '`'; + end; + 'CFP', 'CurrentFilePath': + begin + result += '`'; + if EditWidget.currentEditor <> nil then + if fileExists(EditWidget.currentEditor.fileName) then + result += extractFilePath(EditWidget.currentEditor.fileName); + result += '`'; + end; + 'CI', 'CurrentIdentifier': + begin + result += '`'; + if EditWidget.currentEditor <> nil then + result += EditWidget.currentEditor.Identifier; + result += '`'; + end; + 'CAF', 'CoeditApplicationFile': + result += '`' + application.ExeName + '`'; + 'CAP', 'CoeditApplicationPath': + result += '`' + extractFilePath(Application.ExeName) + '`'; + end; + end; + finally + elems.Free; + end; end; procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl;