Hello!
I'm currently working on patch (not plugin) that may improve current brackets auto-closing. Patch is under construction but I hope for feedback - may be you are interesting in some on those features in geany and may be you have some ideas how to do it better.
Already implemented features. To use it all, enable all brackets completion in preferences.
* auto-complete second char for: {, [, (, ", ' as geany does (rewritten logic) * disable brackets auto-completion inside strings and comments * delete second completed char if you pressed BackSpace * suppress inserting one char twice (if you type "{}" you will get "{}", not "{}}") * wrap selected text into brackets instead of removing selection (select text and type "(" or ")" to wrap selection into "()") * keep selection in cause of wrapping * for C-like languages wrapping selection into "{}" makes auto-indentation (select text and type "{" or "}" - text will be wrapped and indented) * {}-wrapper moves cursor to beginning (before first "{" * for C-like languages to insert {}-block you do not need to select text precisely: geany detects boundaries automatically, just ensure that selection covers lines you need to indent (works like TAB indentation) * fix auto-indent inside {} for C-like languages (makes full indent for this block) * auto-close functions ("sin(|" -> "sin(|);") with double-chars suppression (for C only)
Patch itself and planning features you will find on my github: https://github.com/scriptum/geany-patches/
I also planning to move all brackets logic from editor_notify to GTK's key-press-event because of lack of features in editor_notify events. Is it possible? I tried it and seems that it works fine...
On 6 April 2013 06:04, Pavel Roschin roshin@scriptumplus.ru wrote:
Hello!
I'm currently working on patch (not plugin) that may improve current brackets auto-closing. Patch is under construction but I hope for feedback - may be you are interesting in some on those features in geany and may be you have some ideas how to do it better.
Already implemented features. To use it all, enable all brackets completion in preferences.
- auto-complete second char for: {, [, (, ", ' as geany does (rewritten logic)
- disable brackets auto-completion inside strings and comments
Thats a good idea
- delete second completed char if you pressed BackSpace
Whats wrong with deleting it by pressing delete which does not need any special handling and your "horrible hack" mentioned below? This is essentially contrary to the usual operation of backslash.
- suppress inserting one char twice (if you type "{}" you will get "{}", not "{}}")
What do I get when I am editing and accidentally delete the ( and then re-type it?
- wrap selected text into brackets instead of removing selection (select text and type "(" or ")" to wrap selection into "()")
This should be a keycode, not automatic. Its essentailly contrary to the usual UI operation.
- keep selection in cause of wrapping
- for C-like languages wrapping selection into "{}" makes auto-indentation (select text and type "{" or "}" - text will be wrapped and indented)
- {}-wrapper moves cursor to beginning (before first "{"
- for C-like languages to insert {}-block you do not need to select text precisely: geany detects boundaries automatically, just ensure that selection covers lines you need to indent (works like TAB indentation)
- fix auto-indent inside {} for C-like languages (makes full indent for this block)
I presume this works in accordance with the the indent settings, so it doesn't change them if autoindent is off
- auto-close functions ("sin(|" -> "sin(|);") with double-chars suppression (for C only)
Does the tooltip still work?
Patch itself and planning features you will find on my github: https://github.com/scriptum/geany-patches/
I also planning to move all brackets logic from editor_notify to GTK's key-press-event because of lack of features in editor_notify events. Is it possible? I tried it and seems that it works fine...
Key press and adding a character to the buffer can be different things, not all keypresses get to be characters in the buffer. Admittedly brackets might be fairly safe, but still it would be nice to keep the current division for maintainability.
Test thoroughly that when each type of the autoclose preference is turned off, all effects of this change must be removed. As I said above it would be preferable to maintain normal UI operation if possible.
Cheers Lex
-- Pavel aka RPG _______________________________________________ Users mailing list Users@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/users
Sat, 6 Apr 2013 10:28:34 +1100 сообщение от Lex Trotman elextr@gmail.com:
- delete second completed char if you pressed BackSpace
Whats wrong with deleting it by pressing delete which does not need any special handling and your "horrible hack" mentioned below? This is essentially contrary to the usual operation of backslash.
You have to press a half of keys:) Actually it deletes pairing char. This is useful to keep parentheses. Feature I seen in many editors. Someone may wants to have it in Geany to suit it needs.
- suppress inserting one char twice (if you type "{}" you will get "{}", not "{}}")
What do I get when I am editing and accidentally delete the ( and then re-type it?
you type ( -> editor gives (|) you type BackSp -> editor deletes it both: | you type ( again -> editor gives (|) again
- wrap selected text into brackets instead of removing selection (select text and type "(" or ")" to wrap selection into "()")
This should be a keycode, not automatic. Its essentailly contrary to the usual UI operation.
It comes with keeping in mind that you usually do not want "select text, delete it and put a "(" on its place") but want "select text and wrap it into ()-s". This is why people loves sublime text and so on. Feature existed in other editors and it will be useful for people who wants to switch an editor. First time this feature were noticed (for me) in KDE-s Kate in 2007. When I switched to geany I lived without this feature but it does not means that I do not want it:)
- keep selection in cause of wrapping
- for C-like languages wrapping selection into "{}" makes auto-indentation (select text and type "{" or "}" - text will be wrapped and indented)
- {}-wrapper moves cursor to beginning (before first "{"
- for C-like languages to insert {}-block you do not need to select text precisely: geany detects boundaries automatically, just
ensure that selection covers lines you need to indent (works like TAB indentation)
- fix auto-indent inside {} for C-like languages (makes full indent
for this block)
I presume this works in accordance with the the indent settings, so it doesn't change them if autoindent is off
Yes, I do not make an auto-indent if it is off.
- auto-close functions ("sin(|" -> "sin(|);") with double-chars suppression (for C only)
Does the tooltip still work?
Hmmm... it seems "yes" but I will check it again. I have enabled all completion features and did not noticed that somethig went wrong.
Patch itself and planning features you will find on my github: https://github.com/scriptum/geany-patches/
I also planning to move all brackets logic from editor_notify to GTK's key-press-event because of lack of features in editor_notify events. Is it possible? I tried it and seems that it works fine...
Key press and adding a character to the buffer can be different things, not all keypresses get to be characters in the buffer. Admittedly brackets might be fairly safe, but still it would be nice to keep the current division for maintainability.
I see. I wiil try to make some work-around. And I will test it as much as possible. Maybe someone wants to test these too without merging a patch.
Test thoroughly that when each type of the autoclose preference is turned off, all effects of this change must be removed. As I said above it would be preferable to maintain normal UI operation if possible.
It's planning feature. It seems that I need a separate tab for auto-closing:)
Hi again,
After a *quick* look at your code, some more comments below.
On 6 April 2013 06:04, Pavel Roschin roshin@scriptumplus.ru wrote:
Hello!
I'm currently working on patch (not plugin) that may improve current brackets auto-closing. Patch is under construction but I hope for feedback - may be you are interesting in some on those features in geany and may be you have some ideas how to do it better.
Already implemented features. To use it all, enable all brackets completion in preferences.
- auto-complete second char for: {, [, (, ", ' as geany does (rewritten logic)
- disable brackets auto-completion inside strings and comments
- delete second completed char if you pressed BackSpace
To be clear, actually deletes *both* the opening and closing, makes more sense.
- suppress inserting one char twice (if you type "{}" you will get "{}", not "{}}")
- wrap selected text into brackets instead of removing selection (select text and type "(" or ")" to wrap selection into "()")
- keep selection in cause of wrapping
- for C-like languages wrapping selection into "{}" makes auto-indentation (select text and type "{" or "}" - text will be wrapped and indented)
- {}-wrapper moves cursor to beginning (before first "{"
- for C-like languages to insert {}-block you do not need to select text precisely: geany detects boundaries automatically, just ensure that selection covers lines you need to indent (works like TAB indentation)
- fix auto-indent inside {} for C-like languages (makes full indent for this block)
- auto-close functions ("sin(|" -> "sin(|);") with double-chars suppression (for C only)
Why are you putting a semicolon? that leaves characters to delete when the user is trying to type "if( getc() == 'a' )return" or "sin(x)+cos(y)". The assumption that a function call is the end of a statement is a bad one.
Patch itself and planning features you will find on my github: https://github.com/scriptum/geany-patches/
I also planning to move all brackets logic from editor_notify to GTK's key-press-event because of lack of features in editor_notify events. Is it possible? I tried it and seems that it works fine...
What do you need that you don't currently have in notify?
Cheers Lex
-- Pavel aka RPG _______________________________________________ Users mailing list Users@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/users
Sat, 6 Apr 2013 12:30:56 +1100 сообщение от Lex Trotman elextr@gmail.com:
Hi again,
After a *quick* look at your code, some more comments below.
On 6 April 2013 06:04, Pavel Roschin roshin@scriptumplus.ru wrote:
Hello!
I'm currently working on patch (not plugin) that may improve current brackets auto-closing. Patch is under construction but I hope for feedback - may be you are interesting in some on those features in geany and may be you have some ideas how to do it better.
Already implemented features. To use it all, enable all brackets completion in preferences.
- auto-complete second char for: {, [, (, ", ' as geany does
(rewritten logic)
- disable brackets auto-completion inside strings and comments
- delete second completed char if you pressed BackSpace
To be clear, actually deletes *both* the opening and closing, makes more sense.
Yes it is, as discussed in IRC
- suppress inserting one char twice (if you type "{}" you will get "{}", not "{}}")
- wrap selected text into brackets instead of removing selection (select text and type "(" or ")" to wrap selection into "()")
- keep selection in cause of wrapping
- for C-like languages wrapping selection into "{}" makes auto-indentation (select text and type "{" or "}" - text will be wrapped and indented)
- {}-wrapper moves cursor to beginning (before first "{"
- for C-like languages to insert {}-block you do not need to select text precisely: geany detects boundaries automatically, just
ensure that selection covers lines you need to indent (works like TAB indentation)
- fix auto-indent inside {} for C-like languages (makes full indent
for this block)
- auto-close functions ("sin(|" -> "sin(|);") with double-chars suppression (for C only)
Why are you putting a semicolon? that leaves characters to delete when the user is trying to type "if( getc() == 'a' )return" or "sin(x)+cos(y)". The assumption that a function call is the end of a statement is a bad one.
It's more clewer:) if( getc() == 'a') completes only (-s and '-s sin(x)+cos(y) what actually happens: type "sin(" -> sin(|); type "x)+" -> sin(x)+|; type "cos(" -> sin(x)+cos(|); type "y);" -> sin(x)+cos(y);|
Here quote suppressor and auto-closer works.
Patch itself and planning features you will find on my github: https://github.com/scriptum/geany-patches/
I also planning to move all brackets logic from editor_notify to GTK's key-press-event because of lack of features in editor_notify events. Is it possible? I tried it and seems that it works fine...
What do you need that you don't currently have in notify?
BackSpace, Shift. Also there is selection hack due to when you get notify you have selection disappeared.