[Lazarus] Can the Lazarus IDE match parentheses and begin/ends?
Martin Frb
lazarus at mfriebe.de
Sat Jan 6 12:33:43 CET 2018
On 06/01/18 10:25, Bo Berglund via Lazarus wrote:
> On Fri, 5 Jan 2018 14:12:59 +0100, Martin Frb via Lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
>
>> On 05/01/18 12:41, Bo Berglund via Lazarus wrote:
>>> I wonder if it is possible (and if so how) to enable the Lazarus code
>>> editor to match the open/close parenthesis and begin/end block
>>> delimiters?
> Martin, thanks for your detailed description! It made it possible for
> me to at least partially solve the problem!
which part (about begin/end) is NOT solved? (Or does "partly" refer to
brackets?)
>> brackets are already answered in the other mails.
> But the links in these replies go to a webpage that says a bit down:
>
> "Bracket Highlight
>
> If the cursor is behind or in front of a bracket, highlight matching
> bracket"
>
> And that is all. No description on *how* to actually activate this
> function, which was clearly not working in my Lazarus...
Same options dialog/page as above "Markup and Matches"
There is a dropdown "Bracket highlight" (below the 1st divider / unamed
divider)
with options such as "on both sides", "Left of cursor", .... "no
highlight"
I am not sure, it may require that the text has some highlighter active
(but pascal sources always have this).
If you load plain text, then it may not work on that file...
It matches (), {}, [], and single quotes. It toggles between bold and
not bold, and applies a frame (at least for me, I may have changed settings)
But again in color options you can change what highlight to apply:
Editor > Display > Colors:
Entry "Bracket Highlights" (1st in section "Text").
> Furthermore the webpage directs me to the "Automatic feature" page of
> the editor option, which in fact does not exist in my Lazarus.
> Under Editor there are 8 subpages, none named "Automatic feature". If
> one expands the Display node there are Colors, Markup and Matches,
> User defined markup. So the wiki page is misleading.
The wiki is indeed outdated. (If anyone has time...)
"Automatic ..." was probably the name of a sub page in an older Lazarus
version.
>> begin/end is not on the wiki (yet), but it is in the Options dialog
>> under > Editor > Display > Markup and Matches
>>
>> It is called "Word Brackets on caret"
>>
>> There is a listbox with: "Procedure","Begin/end", "repeat" .....
>> you can select each entry and check "Markup (on caret), to get the highlight
> In my case these are all checked except for the last 4 boxes.
> Additionally the checkbox to the right "Markup (on caret)" is checked
> as is the top "Word Brackets on caret" and yet I did not see anything
> in the IDE...
> Do I have to use some kind of hot key to make it display?
> Well, it seems to be a mis-match in the default settings where the
> feature is enabled by default but the colors are set by default to
> completely hide the highlight....
Which color profile are you using? (Default, Delphi, Ocean....)
In the Default it should have a red frame (for begin/end pairs)
You can always check the default by deleting (BACK UP !) your
editor_options.xml
This is in the primary config path (View Menu > Ide Internals > About IDE
> After a lot of fiddling I managed to get the following working:
>
> begin-end: A red box pink background via "Word-brackets" color
> [ ]: basically the same, but via "Brackets highlights" color
> if-then-else: same via "Word-brackets" color
>
> Not working:
> ( ): Controlled by what?
Should be the same as ()
Just remember, I think there is a bug in 1.8 (already fixed for the not
yet released 1.8.2)
brackets only work if they are surrounded by spaces (or maybe it was NOT
surrounded...)
https://bugs.freepascal.org/view.php?id=32803
svn rev 56695
rebuild ide with this patch
Index: components/synedit/synedit.pp
===================================================================
--- components/synedit/synedit.pp (revision 56694)
+++ components/synedit/synedit.pp (revision 56695)
@@ -8945,7 +8945,7 @@
while not Highlighter.GetEol do begin
Start := Highlighter.GetTokenPos + 1;
Token := Highlighter.GetToken;
- if (PosX >= Start) and (PosX <= Start + Length(Token)) then begin
+ if (PosX >= Start) and (PosX < Start + Length(Token)) then begin
Attri := Highlighter.GetTokenAttribute;
TokenType := Highlighter.GetTokenKind;
exit(True);
@@ -8990,7 +8990,7 @@
//TokenType := Highlighter.GetTokenKind;
Attri := Highlighter.GetTokenAttribute;
//DebugLn([' TCustomSynEdit.CaretAtIdentOrString: Start=',
Start, ', Token=', Token]);
- if (PosX >= Start) and (PosX <= Start + Length(Token)) then
+ if (PosX >= Start) and (PosX < Start + Length(Token)) then
begin
AtIdent := Attri = Highlighter.IdentifierAttribute;
NearString := (Attri = Highlighter.StringAttribute)
More information about the Lazarus
mailing list