Re: [Geany] Auto-close quotes and brackets - addition request

2008-12-19 Thread Harold Aling
On Thu, 18 Dec 2008 21:23:10 +0100, Enrico Tröger
enrico.troe...@uvena.de
wrote:
 On Thu, 18 Dec 2008 14:40:54 +0100, Harold Aling ge...@sait.nl wrote:
My request:

If the next character is the same as the one Geany has inserted
(/closed), overwrite the previously inserted one.
 
 Attached is a patch which might fix it but I didn't test it well and I
 want you (Harold, Guillaume, whoever else is using this feature) to
 test it before, it might need some tweaking.

Enrico,

Just tested it a bit. First thoughts:
* There's a bit of a lag when the 'patch' kicks in
* I believe the patch looks at the next character on a line so if you're
prefixing a single quote with another quote that won't work.


-H-
___
Geany mailing list
Geany@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany


[Geany] Auto-close quotes and brackets - addition request

2008-12-18 Thread Harold Aling
Dear Geany devs,

After a (short) period of getting used to it, I really like the new feature
to automatically insert quotes and brackets! It saves me a lot of
keypresses to construct a piece of code ;)

Except for this example: $var[] = 'test';

Instead of typing [] I/we now have to type [ and right arrow key. Same goes
for $empty = '', etc...


My request:

If the next character is the same as the one Geany has inserted(/closed),
overwrite the previously inserted one.


So when typing $test = ''; it is exactly as typed and not $test = '';''



What do you guys think of such an 'additional' feature?


-H-
___
Geany mailing list
Geany@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany


Re: [Geany] Auto-close quotes and brackets - addition request

2008-12-18 Thread Enrico Tröger
On Thu, 18 Dec 2008 14:40:54 +0100, Harold Aling ge...@sait.nl wrote:

Dear Geany devs,

After a (short) period of getting used to it, I really like the new
feature to automatically insert quotes and brackets! It saves me a lot
of keypresses to construct a piece of code ;)

Except for this example: $var[] = 'test';

Instead of typing [] I/we now have to type [ and right arrow key. Same
goes for $empty = '', etc...


My request:

If the next character is the same as the one Geany has inserted
(/closed), overwrite the previously inserted one.

Sounds like a good idea.

Attached is a patch which might fix it but I didn't test it well and I
want you (Harold, Guillaume, whoever else is using this feature) to
test it before, it might need some tweaking.

Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.asc
Index: src/editor.c
===
--- src/editor.c	(Revision 3401)
+++ src/editor.c	(Arbeitskopie)
@@ -91,6 +91,7 @@
 static gboolean is_code_style(gint lexer, gint style);
 static gboolean is_string_style(gint lexer, gint style);
 static void auto_close_chars(ScintillaObject *sci, gint pos, gchar c);
+static gboolean auto_close_chars_check_dup(ScintillaObject *sci, gint pos, gchar c);
 static void auto_table(GeanyEditor *editor, gint pos);
 static void close_block(GeanyEditor *editor, gint pos);
 
@@ -435,7 +436,8 @@
 		}
 		case '(':
 		{
-			auto_close_chars(sci, pos, nt-ch);
+			if (editor_prefs.autoclose_chars != 0)
+auto_close_chars(sci, pos, nt-ch);
 			/* show calltips */
 			editor_show_calltip(editor, --pos);
 			break;
@@ -451,6 +453,9 @@
 			calltip.pos = 0;
 			calltip.sci = NULL;
 			calltip.set = FALSE;
+
+			if (editor_prefs.autoclose_chars != 0)
+auto_close_chars_check_dup(sci, pos, nt-ch);
 			break;
 		}
 		case '{':
@@ -458,13 +463,22 @@
 		case '':
 		case '\'':
 		{
-			auto_close_chars(sci, pos, nt-ch);
+			if (! auto_close_chars_check_dup(sci, pos, nt-ch))
+auto_close_chars(sci, pos, nt-ch);
 			break;
 		}
+		case ']':
+		{
+			if (editor_prefs.autoclose_chars != 0)
+auto_close_chars_check_dup(sci, pos, nt-ch);
+			break;
+		}
 		case '}':
 		{	/* closing bracket handling */
 			if (editor-auto_indent)
 close_block(editor, pos - 1);
+			if (editor_prefs.autoclose_chars != 0)
+auto_close_chars_check_dup(sci, pos, nt-ch);
 			break;
 		}
 		default:
@@ -1016,6 +1030,40 @@
 }
 
 
+static gboolean auto_close_chars_check_dup(ScintillaObject *sci, gint pos, gchar c)
+{
+	if (c != sci_get_char_at(sci, pos))
+		return FALSE;
+
+	switch (c)
+	{
+		case '(':
+			if (! (editor_prefs.autoclose_chars  GEANY_AC_PARENTHESIS))
+return FALSE;
+			break;
+		case '{':
+			if (! (editor_prefs.autoclose_chars  GEANY_AC_CBRACKET))
+return FALSE;
+			break;
+		case '[':
+			if (! (editor_prefs.autoclose_chars  GEANY_AC_SBRACKET))
+return FALSE;
+			break;
+		case '\'':
+			if (! (editor_prefs.autoclose_chars  GEANY_AC_SQUOTE))
+return FALSE;
+			break;
+		case '':
+			if (! (editor_prefs.autoclose_chars  GEANY_AC_DQUOTE))
+return FALSE;
+			break;
+	}
+	SSM(sci, SCI_DELETEBACK, 0, 0);
+	sci_set_current_position(sci, pos, FALSE);
+	return TRUE;
+}
+
+
 static void auto_close_chars(ScintillaObject *sci, gint pos, gchar c)
 {
 	const gchar *closing_char = NULL;


pgpBLUGNq30WS.pgp
Description: PGP signature
___
Geany mailing list
Geany@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany


Re: [Geany] Auto-close quotes and brackets - addition request

2008-12-18 Thread Gordon Wrigley
what will happen with stuff of the form funcA(funcB))

On Fri, Dec 19, 2008 at 7:23 AM, Enrico Tröger enrico.troe...@uvena.de wrote:
 On Thu, 18 Dec 2008 14:40:54 +0100, Harold Aling ge...@sait.nl wrote:

Dear Geany devs,

After a (short) period of getting used to it, I really like the new
feature to automatically insert quotes and brackets! It saves me a lot
of keypresses to construct a piece of code ;)

Except for this example: $var[] = 'test';

Instead of typing [] I/we now have to type [ and right arrow key. Same
goes for $empty = '', etc...


My request:

If the next character is the same as the one Geany has inserted
(/closed), overwrite the previously inserted one.

 Sounds like a good idea.

 Attached is a patch which might fix it but I didn't test it well and I
 want you (Harold, Guillaume, whoever else is using this feature) to
 test it before, it might need some tweaking.

 Regards,
 Enrico

 --
 Get my GPG key from http://www.uvena.de/pub.asc

 ___
 Geany mailing list
 Geany@uvena.de
 http://lists.uvena.de/cgi-bin/mailman/listinfo/geany


___
Geany mailing list
Geany@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany