All,
First I'd like to thank you for developing Geany as it has been my preferred IDE for 7 years due to how customizable and fast it is, especially over ssh/X forwarding. I also use VS Code in certain instances, and one of the features that I really wish was in Geany is the bracket pair colorization. Has anyone proposed this or is currently working on such functionality?
I decided to take a crack at implementing this into geany via a plugin based on this blog post: https://code.visualstudio.com/blogs/2021/09/29/bracket-pair-colorization
I got a simple a proof of concept working, basically using SCI_BRACEMATCH with indicators that colored braces with SCI_INDICSETSTYLE/INDIC_TEXTFORE/SCI_INDICSETFORE
[image: image.png]
Is this approach reasonable? I'm not sure how well this will scale on large documents or if using indicators for this purpose is valid
Thanks!
On Thu, 15 Dec 2022 at 02:42, Asif Aaron Amin via Devel < devel@lists.geany.org> wrote:
All,
First I'd like to thank you for developing Geany as it has been my preferred IDE for 7 years due to how customizable and fast it is, especially over ssh/X forwarding. I also use VS Code in certain instances, and one of the features that I really wish was in Geany is the bracket pair colorization. Has anyone proposed this or is currently working on such functionality?
I presume you mean VS code using differing colours for each nesting level of braces. I also happen to use VS, but you can't expect that contributors to one project will be aware of the features of others apps, you need to describe the feature you want.
I decided to take a crack at implementing this into geany via a plugin based on this blog post: https://code.visualstudio.com/blogs/2021/09/29/bracket-pair-colorization
I got a simple a proof of concept working, basically using SCI_BRACEMATCH with indicators that colored braces with SCI_INDICSETSTYLE/INDIC_TEXTFORE/SCI_INDICSETFORE
[image: image.png]
Is this approach reasonable? I'm not sure how well this will scale on large documents or if using indicators for this purpose is valid
Without seeing your code, can't tell, you point to the VScode plugin, but not yours ;-)
Probably best if you just try it on big files ... using a slow computer, eg Raspberry PI. To reduce its impact only run it after a delay after change, and reset the delay if another change happens in the meantime. That way it runs when the user stops or slows typing.
Using a plugin seems a sensible idea, the alternative of having the Lexers do it means changing every lexer, but your plugin should be able to work for any language.
Cheers Lex
Thanks!
Devel mailing list -- devel@lists.geany.org To unsubscribe send an email to devel-leave@lists.geany.org
Lex/All,
I presume you mean VS code using differing colours for each nesting level
of braces. I also happen to use VS, but you can't expect that contributors to one project will be aware of the features of others apps, you need to describe the feature you want.
You are correct and thanks for the heads up.
Without seeing your code, can't tell, you point to the VScode plugin, but
not yours ;-)
That was because my code at the time was too embarrassing to release publicly 😅 I currently have my code hosted here: https://github.com/asifamin13/bracket-colors . Admittedly it's very minimal and currently bare on documentation and builds with a simple cmake setup. I plan to add the autotools build and docs later this week
Over the U.S. holiday break I decided to take a crack at writing the plugin. I used your idea of using timers to handle massive files, I think it performs pretty well. I didn't even have to use "a recursive descent parser to build an abstract syntax tree" like what VSCode does. The scintilla SCI_BRACEMATCH was enough and is also language agnostic. My plugin also handles coloring parentheses, braces, and angle brackets on dark and light backgrounds. I'd like to make the colors user configurable at some point
[image: image.png] [image: image.png]
A few questions
- I use 3 indicators to render colored text. From the scintilla documentation, there are only 43 indicators available to use. Currently I use INDICATOR_IME - 3 as my start index, the rationale being I don't know what INDICATOR_IME is used for and it doesn't seem to affect anything. Is there a better way to choose my start indicator? - The tricky part when writing this was determining when a bracket was inside a string, docstring, etc. The way I solved it was to check the style of the text and see if it matched up with known styles I got from trial and error: static const std::set<int> sIgnoreStyles { 1, 2, 3, 4, 6, 7, 9 } There must a better way to do this, does there exist a notion of "geany comment styles" I can leverage?
Thanks, Asif Amin
On Wed, Dec 14, 2022 at 3:29 PM Lex Trotman via Devel devel@lists.geany.org wrote:
On Thu, 15 Dec 2022 at 02:42, Asif Aaron Amin via Devel < devel@lists.geany.org> wrote:
All,
First I'd like to thank you for developing Geany as it has been my preferred IDE for 7 years due to how customizable and fast it is, especially over ssh/X forwarding. I also use VS Code in certain instances, and one of the features that I really wish was in Geany is the bracket pair colorization. Has anyone proposed this or is currently working on such functionality?
I presume you mean VS code using differing colours for each nesting level of braces. I also happen to use VS, but you can't expect that contributors to one project will be aware of the features of others apps, you need to describe the feature you want.
I decided to take a crack at implementing this into geany via a plugin based on this blog post: https://code.visualstudio.com/blogs/2021/09/29/bracket-pair-colorization
I got a simple a proof of concept working, basically using SCI_BRACEMATCH with indicators that colored braces with SCI_INDICSETSTYLE/INDIC_TEXTFORE/SCI_INDICSETFORE
[image: image.png]
Is this approach reasonable? I'm not sure how well this will scale on large documents or if using indicators for this purpose is valid
Without seeing your code, can't tell, you point to the VScode plugin, but not yours ;-)
Probably best if you just try it on big files ... using a slow computer, eg Raspberry PI. To reduce its impact only run it after a delay after change, and reset the delay if another change happens in the meantime. That way it runs when the user stops or slows typing.
Using a plugin seems a sensible idea, the alternative of having the Lexers do it means changing every lexer, but your plugin should be able to work for any language.
Cheers Lex
Thanks!
Devel mailing list -- devel@lists.geany.org To unsubscribe send an email to devel-leave@lists.geany.org
Devel mailing list -- devel@lists.geany.org To unsubscribe send an email to devel-leave@lists.geany.org
On Sat, 14 Jan 2023 at 05:54, Asif Aaron Amin via Devel < devel@lists.geany.org> wrote:
Lex/All,
I presume you mean VS code using differing colours for each nesting level
of braces. I also happen to use VS, but you can't expect that contributors to one project will be aware of the features of others apps, you need to describe the feature you want.
You are correct and thanks for the heads up.
Without seeing your code, can't tell, you point to the VScode plugin, but
not yours ;-)
That was because my code at the time was too embarrassing to release publicly 😅 I currently have my code hosted here: https://github.com/asifamin13/bracket-colors . Admittedly it's very minimal and currently bare on documentation and builds with a simple cmake setup. I plan to add the autotools build and docs later this week
Over the U.S. holiday break I decided to take a crack at writing the plugin. I used your idea of using timers to handle massive files, I think it performs pretty well. I didn't even have to use "a recursive descent parser to build an abstract syntax tree" like what VSCode does. The scintilla SCI_BRACEMATCH was enough and is also language agnostic. My plugin also handles coloring parentheses, braces, and angle brackets on dark and light backgrounds. I'd like to make the colors user configurable at some point
Well, Vscode likely _RE_uses a recursive descent parser in the language
server ..... its used for lots of other stuff as well.
SCI_BRACEMATCH actually isn't language agnostic either, it uses the styling set by the lexer and only looks at braces that are in the same style. See https://github.com/geany/geany/blob/607fcec1fa5aff005090fbda17280976dcee68c8.... So for example, assuming the lexer styles comments and strings so they are different to code, it can ignore braces in comments and strings. The example the Vscode article uses "{ /* } */ char str[] = "}"; }" matches the outer pair correctly in C in Geany.
Configurability via the theme would be good, then themes with weird colour sets can choose colours that stand out in their collection. That will also remove the need for you to handle dark/light and 50 shades of grey.
I didn't even have to use "a recursive descent parser to build an abstract syntax tree" like what VSCode does.selects matching braces correct in Geany.
A few questions
- I use 3 indicators to render colored text. From the scintilla
documentation, there are only 43 indicators available to use. Currently I use INDICATOR_IME - 3 as my start index, the rationale being I don't know what INDICATOR_IME is used for and it doesn't seem to affect anything. Is there a better way to choose my start indicator?
Geany itself uses three at the low end of the range, so probably no better
way, there is no recognised way of sharing resources like indicators between plugins, but IIRC others use indicators from low up, so starting at the top is probably ok.
IME is a set of ways (they are plugins IIUC) of entering characters not on your keyboard, think typing Chinese Japanese Korean on a US international keyboard, so yeah don't use those indicators.
- The tricky part when writing this was determining when a bracket was
inside a string, docstring, etc. The way I solved it was to check the style of the text and see if it matched up with known styles I got from trial and error: static const std::set<int> sIgnoreStyles { 1, 2, 3, 4, 6, 7, 9 } There must a better way to do this, does there exist a notion of "geany comment styles" I can leverage?
As I said above, SCI_BRACEMATCH already does that, so you probably don't
need to.
And keeping a list of styles up to date is unlikely, I notice that https://github.com/geany/geany/blob/607fcec1fa5aff005090fbda17280976dcee68c8... doesn't mention Julia, but IIRC it has block comments (issue raised). Having a list in a plugin updated is even less likely to happen.
Cheers Lex
Thanks,
Asif Amin ...
Lex/All,
Configurability via the theme would be good, then themes with weird colour
sets can choose colours that stand out in their collection. That will also remove the need for you to handle dark/light and 50 shades of grey.
I agree this would be cool. What would be the best way to go about doing this? Adding a bracket_colors= entry in the colorschemes/*conf files? Making an entry for each theme that is dependent on a plugin doesn't seem like the correct way to do this. FWIW in VSCode they have a default dark and light bracket colors (which I copied) that appears to be used for every theme. I noticed some themes override the default (Solarized Dark)
I'm working on making a fork/pull request for the geany-plugins project. I noticed that most (if not all) of the plugins are in C, not C++. Are C++ plugins not preferred? I currently use C++11 features, but I can easily do a pure C implementation.
On Fri, Jan 13, 2023 at 6:38 PM Lex Trotman via Devel devel@lists.geany.org wrote:
On Sat, 14 Jan 2023 at 05:54, Asif Aaron Amin via Devel < devel@lists.geany.org> wrote:
Lex/All,
I presume you mean VS code using differing colours for each nesting
level of braces. I also happen to use VS, but you can't expect that contributors to one project will be aware of the features of others apps, you need to describe the feature you want.
You are correct and thanks for the heads up.
Without seeing your code, can't tell, you point to the VScode plugin, but
not yours ;-)
That was because my code at the time was too embarrassing to release publicly 😅 I currently have my code hosted here: https://github.com/asifamin13/bracket-colors . Admittedly it's very minimal and currently bare on documentation and builds with a simple cmake setup. I plan to add the autotools build and docs later this week
Over the U.S. holiday break I decided to take a crack at writing the plugin. I used your idea of using timers to handle massive files, I think it performs pretty well. I didn't even have to use "a recursive descent parser to build an abstract syntax tree" like what VSCode does. The scintilla SCI_BRACEMATCH was enough and is also language agnostic. My plugin also handles coloring parentheses, braces, and angle brackets on dark and light backgrounds. I'd like to make the colors user configurable at some point
Well, Vscode likely _RE_uses a recursive descent parser in the language
server ..... its used for lots of other stuff as well.
SCI_BRACEMATCH actually isn't language agnostic either, it uses the styling set by the lexer and only looks at braces that are in the same style. See https://github.com/geany/geany/blob/607fcec1fa5aff005090fbda17280976dcee68c8.... So for example, assuming the lexer styles comments and strings so they are different to code, it can ignore braces in comments and strings. The example the Vscode article uses "{ /* } */ char str[] = "}"; }" matches the outer pair correctly in C in Geany.
Configurability via the theme would be good, then themes with weird colour sets can choose colours that stand out in their collection. That will also remove the need for you to handle dark/light and 50 shades of grey.
I didn't even have to use "a recursive descent parser to build an abstract syntax tree" like what VSCode does.selects matching braces correct in Geany.
A few questions
- I use 3 indicators to render colored text. From the scintilla
documentation, there are only 43 indicators available to use. Currently I use INDICATOR_IME - 3 as my start index, the rationale being I don't know what INDICATOR_IME is used for and it doesn't seem to affect anything. Is there a better way to choose my start indicator?
Geany itself uses three at the low end of the range, so probably no
better way, there is no recognised way of sharing resources like indicators between plugins, but IIRC others use indicators from low up, so starting at the top is probably ok.
IME is a set of ways (they are plugins IIUC) of entering characters not on your keyboard, think typing Chinese Japanese Korean on a US international keyboard, so yeah don't use those indicators.
- The tricky part when writing this was determining when a bracket
was inside a string, docstring, etc. The way I solved it was to check the style of the text and see if it matched up with known styles I got from trial and error: static const std::set<int> sIgnoreStyles { 1, 2, 3, 4, 6, 7, 9 } There must a better way to do this, does there exist a notion of "geany comment styles" I can leverage?
As I said above, SCI_BRACEMATCH already does that, so you probably don't
need to.
And keeping a list of styles up to date is unlikely, I notice that https://github.com/geany/geany/blob/607fcec1fa5aff005090fbda17280976dcee68c8... doesn't mention Julia, but IIRC it has block comments (issue raised). Having a list in a plugin updated is even less likely to happen.
Cheers Lex
Thanks,
Asif Amin ...
Devel mailing list -- devel@lists.geany.org To unsubscribe send an email to devel-leave@lists.geany.org