[Geany-devel] Adding auto-close brackets, braces and string

Enrico Tröger enrico.troeger at xxxxx
Sun Nov 30 19:44:25 UTC 2008

On Fri, 28 Nov 2008 05:55:25 +0100 (CET), ioguix at free.fr wrote:

>First of all, thanks for this great piece of code that is Geany !
>Now, I would like to use auto-close brackets, brace and string in
>Geany. As it doesn't looks very complicated, it could be a fairly easy
>feature to implement for a first time contributor like me.
>So here is my proposal:
>These options will auto-close ( [ { ' and " while typing, positionning
>the cursor between the pair.
>Nothing really revolutionar here as some IDE already implement that.
>Moreover, it sounds this cannot be done using snippets and I can't 
>seriously think about doing a plugin for such a feature (I'm not even 
>sure it's fesable). So I believe it belongs to Geany's core.

As long as it is configurable(i.e. I can disable it :D) I'm fine with
this. We already have the basic code for this in Geany, even
though it's only used for LaTeX right now.
Check auto_close_bracket() in src/editor.c. Remove the check for the
lexer == latex and add the missing characters (currently it only works
for { and [.

>- where should I put the booleans options in the conf panel ?
>"Editor" > "Completion" tab sounds obvious, what do you think about
>that ?
>- should I group brackets and braces, under the same checkbox and 
>[single-]quotes in an other one ?
>- what about adding a "Typing" Section to group these options in the 
>completion tab ?

Just put one checkbox in Editor->Completions, toggling the feature on
and off.
The easiest solution to make the completed characters configurable
could be:
Add a text field (GtkEntry) which holds all valid opening
braces (and a single and double quote). The user can remove some of
these to disable completion for those. The tooltip should make clear
what can be entered and what not.

But this is not the most user-friendly way, I think :).

Alternatively, you could add a frame containing checkboxes for each of
your suggested characters but for storage in the config file use a
string containing the opening braces/brackets/... or an integer
containing a bitmask to avoid having too many trivial settings.

Last note: if you edit the preferences dialog, please use Glade 2.10,
newer versions generate code which is incompatible with GTK 2.6. If you
can't use it, then just skip the GUI part of the prefs dialog, we will
do this then.


Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20081130/e758e5fe/attachment.pgp>

More information about the Devel mailing list