From 95f19c6286132c46dced7449378d6dac0a93885c Mon Sep 17 00:00:00 2001 From: spikey-pb Date: Tue, 2 Sep 2025 20:45:47 +0100 Subject: [PATCH 1/4] - Set caret location after a template insert using the ^ symbol. --- PureBasicIDE/ScintillaHighlighting.pb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/PureBasicIDE/ScintillaHighlighting.pb b/PureBasicIDE/ScintillaHighlighting.pb index 1534ec08..dfe060f3 100644 --- a/PureBasicIDE/ScintillaHighlighting.pb +++ b/PureBasicIDE/ScintillaHighlighting.pb @@ -4,8 +4,6 @@ ; See LICENSE and LICENSE-FANTAISIE in the project root for license information. ; -------------------------------------------------------------------------------------------- - - CompilerIf #CompileWindows | #CompileLinux | #CompileMac #SCI_NORM = 0 @@ -3501,17 +3499,32 @@ CompilerIf #CompileWindows | #CompileLinux | #CompileMac SetBackgroundColor(Gadget) ; updates the 'disabled background color' EndProcedure - Procedure InsertCodeString(String$) + If *ActiveSource\Parser\Encoding = 1 ; utf8 Format = #PB_UTF8 Else Format = #PB_Ascii EndIf + ; Embed insertion into a single transaction, otherwise the insertion mark will reappear in an Undo action. + SendEditorMessage(#SCI_BEGINUNDOACTION, 0, 0) + + CurrentPos = SendEditorMessage(#SCI_GETCURRENTPOS, 0, 0) Converted$ = Space(StringByteLength(String$, Format)) PokeS(@Converted$, String$, -1, Format) SendEditorMessage(#SCI_REPLACESEL, 0, @Converted$) + + ; Remove marker and move caret, if a position is specified. + MarkerOffset = FindString(String$, "^") + Debug "MarkerOffset = " + Str(MarkerOffset) + If MarkerOffset > 0 + SendEditorMessage(#SCI_GOTOPOS, CurrentPos + MarkerOffset - 1) + SendEditorMessage(#SCI_DELETERANGE, CurrentPos + MarkerOffset - 1, 1) + EndIf + + SendEditorMessage(#SCI_ENDUNDOACTION, 0, 0) + EndProcedure Procedure Undo() From 443e00773b2813a2bd0997d07bffbe61ca53aebc Mon Sep 17 00:00:00 2001 From: Spikey <144023315+spikey-pb@users.noreply.github.com> Date: Sun, 7 Sep 2025 13:28:38 +0100 Subject: [PATCH 2/4] Update ScintillaHighlighting.pb Remove a debug line I missed. --- PureBasicIDE/ScintillaHighlighting.pb | 1 - 1 file changed, 1 deletion(-) diff --git a/PureBasicIDE/ScintillaHighlighting.pb b/PureBasicIDE/ScintillaHighlighting.pb index dfe060f3..d4da79e5 100644 --- a/PureBasicIDE/ScintillaHighlighting.pb +++ b/PureBasicIDE/ScintillaHighlighting.pb @@ -3517,7 +3517,6 @@ CompilerIf #CompileWindows | #CompileLinux | #CompileMac ; Remove marker and move caret, if a position is specified. MarkerOffset = FindString(String$, "^") - Debug "MarkerOffset = " + Str(MarkerOffset) If MarkerOffset > 0 SendEditorMessage(#SCI_GOTOPOS, CurrentPos + MarkerOffset - 1) SendEditorMessage(#SCI_DELETERANGE, CurrentPos + MarkerOffset - 1, 1) From d0feb75e86ff5c0bb6948d1ac2cd298c2b900276 Mon Sep 17 00:00:00 2001 From: spikey-pb Date: Tue, 9 Sep 2025 15:54:22 +0100 Subject: [PATCH 3/4] Updates from code review. --- Documentation/English/Reference/ide_tools.txt | 4 + PureBasicIDE/Declarations.pb | 2 +- PureBasicIDE/PureBasicIDE.pbp | 120 +++++++++--------- PureBasicIDE/ScintillaHighlighting.pb | 35 +++-- PureBasicIDE/Templates.pb | 2 +- 5 files changed, 92 insertions(+), 71 deletions(-) diff --git a/Documentation/English/Reference/ide_tools.txt b/Documentation/English/Reference/ide_tools.txt index cffe39e0..4c89e14f 100644 --- a/Documentation/English/Reference/ide_tools.txt +++ b/Documentation/English/Reference/ide_tools.txt @@ -107,6 +107,10 @@ quickly insert into your source code with a double-click. It allows you to manage the codes in different directories, and put a comment to each code. This tool is perfect to manage small, often used code parts. +@LineBreak +@LineBreak + Normally, the cursor will be moved to the end of the inserted code. You can specify + a different cursor position by including a caret symbol (^) within the template code. @LineBreak @LineBreak diff --git a/PureBasicIDE/Declarations.pb b/PureBasicIDE/Declarations.pb index 6885dafb..8b5b2c06 100644 --- a/PureBasicIDE/Declarations.pb +++ b/PureBasicIDE/Declarations.pb @@ -150,7 +150,7 @@ Declare.s GetContinuationLine(Index, *Offset.INTEGER = 0, *Source.SourceFile = 0 Declare SetLine(Index, NewLine$) ; replace the indexed line with the given text (and highlight it again) Declare CreateEditorGadget() ; create the editing gadget for this source (must call ChangeActiveSource() right after creating the gadget!) Declare SetReadOnly(Gadget, State) ; set the editing gadget to readonly -Declare InsertCodeString(String$) ; insert given string at the current position (also converts to utf8 if needed) +Declare InsertCodeString(String$, MoveCursor = #False) ; insert given string at the current position (also converts to utf8 if needed) Declare Undo() ; perform the standard editior function Declare Redo() Declare Cut() diff --git a/PureBasicIDE/PureBasicIDE.pbp b/PureBasicIDE/PureBasicIDE.pbp index 5d31d6de..4d890cd9 100644 --- a/PureBasicIDE/PureBasicIDE.pbp +++ b/PureBasicIDE/PureBasicIDE.pbp @@ -1,15 +1,64 @@ - +
- +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -17,9 +66,6 @@ - - - @@ -29,9 +75,6 @@ - - - @@ -46,7 +89,7 @@ - + @@ -54,12 +97,6 @@ - - - - - - @@ -77,11 +114,11 @@ - + - + @@ -90,9 +127,6 @@ - - - @@ -108,10 +142,6 @@ - - - - @@ -121,9 +151,6 @@ - - - @@ -140,28 +167,16 @@ - + - + - - - - - - - + - - - - - - - + @@ -308,21 +323,6 @@ - - - - - - - - - - - - - - - @@ -366,7 +366,7 @@
- + @@ -398,7 +398,7 @@ - + diff --git a/PureBasicIDE/ScintillaHighlighting.pb b/PureBasicIDE/ScintillaHighlighting.pb index d4da79e5..de38fdb6 100644 --- a/PureBasicIDE/ScintillaHighlighting.pb +++ b/PureBasicIDE/ScintillaHighlighting.pb @@ -3499,27 +3499,44 @@ CompilerIf #CompileWindows | #CompileLinux | #CompileMac SetBackgroundColor(Gadget) ; updates the 'disabled background color' EndProcedure - Procedure InsertCodeString(String$) + Procedure InsertCodeString(String$, MoveCursor = #False) + ; String$: The string to insert. + ; MoveCursor: If #True, the cursor will be relocated to the location of the caret symbol after insertion and the symbol deleted. + ; Otherwise, caret symbols will be inserted literally. + + Define Find.Sci_TextToFind If *ActiveSource\Parser\Encoding = 1 ; utf8 Format = #PB_UTF8 Else Format = #PB_Ascii EndIf - - ; Embed insertion into a single transaction, otherwise the insertion mark will reappear in an Undo action. + + ; Embed insertion into a single transaction, otherwise the caret symbol will reappear in an Undo action. SendEditorMessage(#SCI_BEGINUNDOACTION, 0, 0) - CurrentPos = SendEditorMessage(#SCI_GETCURRENTPOS, 0, 0) + BeforePos = SendEditorMessage(#SCI_GETCURRENTPOS, 0, 0) Converted$ = Space(StringByteLength(String$, Format)) PokeS(@Converted$, String$, -1, Format) SendEditorMessage(#SCI_REPLACESEL, 0, @Converted$) - ; Remove marker and move caret, if a position is specified. - MarkerOffset = FindString(String$, "^") - If MarkerOffset > 0 - SendEditorMessage(#SCI_GOTOPOS, CurrentPos + MarkerOffset - 1) - SendEditorMessage(#SCI_DELETERANGE, CurrentPos + MarkerOffset - 1, 1) + ; Remove caret symbol and move cursor, if a position is specified. + If MoveCursor And FindString(String$, "^") + If *ActiveSource\Parser\Encoding = 1 ; utf8 + Find\lpstrText = UTF8("^") + Else + Find\lpstrText = Ascii("^") + EndIf + + AfterPos = SendEditorMessage(#SCI_GETCURRENTPOS, 0, 0) + Find\chrg\cpMin = BeforePos + Find\chrg\cpMax = AfterPos + FindPos = SendEditorMessage(#SCI_FINDTEXT, #SCFIND_NONE, @Find) + SendEditorMessage(#SCI_DELETERANGE, FindPos, 1) + SendEditorMessage(#SCI_GOTOPOS, FindPos) + + FreeMemory(Find\lpstrText) + EndIf SendEditorMessage(#SCI_ENDUNDOACTION, 0, 0) diff --git a/PureBasicIDE/Templates.pb b/PureBasicIDE/Templates.pb index 5ad02e3d..2965c6ad 100644 --- a/PureBasicIDE/Templates.pb +++ b/PureBasicIDE/Templates.pb @@ -409,7 +409,7 @@ Procedure Template_Insert() Template$ = Template_Unescape(Template()\Code$) Code$ = ReplaceString(Template$, #NewLine, #NewLine+Prefix$) - InsertCodeString(Code$) + InsertCodeString(Code$, #True) SetActiveGadget(*ActiveSource\EditorGadget) EndIf EndIf From 05ba61fbeb5d0a1a9ef72ab09145d016d1eeac71 Mon Sep 17 00:00:00 2001 From: spikey-pb Date: Tue, 9 Sep 2025 16:29:09 +0100 Subject: [PATCH 4/4] Remove mistakenly included 'PureBasicIDE.pbp'. --- PureBasicIDE/PureBasicIDE.pbp | 488 ---------------------------------- 1 file changed, 488 deletions(-) delete mode 100644 PureBasicIDE/PureBasicIDE.pbp diff --git a/PureBasicIDE/PureBasicIDE.pbp b/PureBasicIDE/PureBasicIDE.pbp deleted file mode 100644 index 4d890cd9..00000000 --- a/PureBasicIDE/PureBasicIDE.pbp +++ /dev/null @@ -1,488 +0,0 @@ - - - -
- -
-
- - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - data\PBLogoBig.ico - - - - - - - - - - - - - - - - - - data\PBLogoBig.ico - - - - - - - - - - - - - - - - - data\logo\PBLogoLinux.png - - - - - - - - - - - - - - - - - data\logo\PBLogoLinux.png - - - - - - - - - - - - - - - - - data\logo\PB3D_MacIcon.icns - - - - - - - - - - - - - - - - - data\logo\PB3D_MacIcon.icns - - - - - - - - - - -
-