SF.net SVN: geany: [1836] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Aug 29 15:14:08 UTC 2007


Revision: 1836
          http://geany.svn.sourceforge.net/geany/?rev=1836&view=rev
Author:   ntrel
Date:     2007-08-29 08:14:07 -0700 (Wed, 29 Aug 2007)

Log Message:
-----------
Add 'Current chars' indentation mode, rename 'Advanced' indentation
to 'Match braces' (closes #1726880).
For 'Match braces' indentation, if a brace could not be matched,
fall back to 'Current chars' indentation.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.html
    trunk/doc/geany.txt
    trunk/geany.glade
    trunk/src/editor.c
    trunk/src/editor.h
    trunk/src/interface.c
    trunk/src/keyfile.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/ChangeLog	2007-08-29 15:14:07 UTC (rev 1836)
@@ -1,3 +1,13 @@
+2007-08-29  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/keyfile.c, src/editor.c, src/editor.h, doc/geany.txt,
+   doc/geany.html:
+   Add 'Current chars' indentation mode, rename 'Advanced' indentation
+   to 'Match braces' (closes #1726880).
+   For 'Match braces' indentation, if a brace could not be matched,
+   fall back to 'Current chars' indentation.
+
+
 2007-08-28  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/keyfile.c:

Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/doc/geany.html	2007-08-29 15:14:07 UTC (rev 1836)
@@ -6,7 +6,7 @@
 <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
 <title>Geany</title>
 <meta name="authors" content="Enrico Tröger  Nick Treleaven  Frank Lanitz" />
-<meta name="date" content="2007-08-16" />
+<meta name="date" content="2007-08-28" />
 <style type="text/css">
 
 /*
@@ -133,7 +133,7 @@
 <br />Nick Treleaven
 <br />Frank Lanitz</td></tr>
 <tr><th class="docinfo-name">Date:</th>
-<td>2007-08-16</td></tr>
+<td>2007-08-28</td></tr>
 <tr><th class="docinfo-name">Version:</th>
 <td>0.12</td></tr>
 </tbody>
@@ -695,16 +695,19 @@
 </div>
 <div class="section">
 <h3><a class="toc-backref" href="#id25" id="auto-indentation" name="auto-indentation">Auto indentation</a></h3>
-<p>Geany knows three types of auto indentation:</p>
+<p>Geany knows four types of auto indentation:</p>
 <dl class="docutils">
 <dt>None</dt>
 <dd>Disables auto indentation completely.</dd>
 <dt>Basic</dt>
 <dd>Adds the same amount of whitespace on a new line as on the last line.</dd>
-<dt>Advanced</dt>
-<dd>Does the same as Basic but also indents curly brackets and adds a
-tabulator character (or spaces) on a new line after an opening '{'
-brace.</dd>
+<dt>Current chars</dt>
+<dd>Does the same as <em>Basic</em> but also indents a new line after an opening
+brace '{', and de-indents when typing a closing brace '}'. For Python,
+a new line will be indented after typing ':' at the end of a line.</dd>
+<dt>Match braces</dt>
+<dd>Similar to <em>Current chars</em> but the closing brace will be aligned to
+match the indentation of the line with the opening brace.</dd>
 </dl>
 </div>
 <div class="section">
@@ -1206,9 +1209,7 @@
 <p>Keybinding tab in preferences dialog</p>
 <img alt="./images/pref_dialog_keys.png" src="./images/pref_dialog_keys.png" />
 <p>There are some handy commands in here that are not, by default,
-bound to a key combination, and may in fact not even be available as
-a menu item (for example, the very handy "Hide and show all additional
-widgets").</p>
+bound to a key combination, and may not be available as a menu item.</p>
 <div class="note">
 <p class="first admonition-title">Note</p>
 <p class="last">For more information see the section called <a class="reference" href="#keybindings">Keybindings</a>.</p>
@@ -2928,7 +2929,7 @@
 <div class="footer">
 <hr class="footer" />
 <a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2007-08-28 15:43 UTC.
+Generated on: 2007-08-29 10:58 UTC.
 Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>

Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/doc/geany.txt	2007-08-29 15:14:07 UTC (rev 1836)
@@ -451,16 +451,19 @@
 Auto indentation
 ^^^^^^^^^^^^^^^^
 
-Geany knows three types of auto indentation:
+Geany knows four types of auto indentation:
 
 None
     Disables auto indentation completely.
 Basic
     Adds the same amount of whitespace on a new line as on the last line.
-Advanced
-    Does the same as Basic but also indents curly brackets and adds a
-    tabulator character (or spaces) on a new line after an opening '{'
-    brace.
+Current chars
+    Does the same as *Basic* but also indents a new line after an opening
+    brace '{', and de-indents when typing a closing brace '}'. For Python,
+    a new line will be indented after typing ':' at the end of a line.
+Match braces
+    Similar to *Current chars* but the closing brace will be aligned to
+    match the indentation of the line with the opening brace.
 
 
 Bookmarks
@@ -1043,9 +1046,7 @@
 .. image:: ./images/pref_dialog_keys.png
 
 There are some handy commands in here that are not, by default,
-bound to a key combination, and may in fact not even be available as
-a menu item (for example, the very handy "Hide and show all additional
-widgets").
+bound to a key combination, and may not be available as a menu item.
 
 .. note::
     For more information see the section called `Keybindings`_.

Modified: trunk/geany.glade
===================================================================
--- trunk/geany.glade	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/geany.glade	2007-08-29 15:14:07 UTC (rev 1836)
@@ -5561,7 +5561,8 @@
 				  <property name="visible">True</property>
 				  <property name="items" translatable="yes">None
 Basic
-Advanced</property>
+Current chars
+Match braces</property>
 				  <property name="add_tearoffs">False</property>
 				  <property name="focus_on_click">True</property>
 				</widget>

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/src/editor.c	2007-08-29 15:14:07 UTC (rev 1836)
@@ -232,8 +232,7 @@
 		}
 		case '}':
 		{	// closing bracket handling
-			if (doc_list[idx].auto_indent &&
-				editor_prefs.indent_mode == INDENT_ADVANCED)
+			if (doc_list[idx].auto_indent)
 				editor_close_block(idx, pos - 1);
 			break;
 		}
@@ -406,7 +405,7 @@
 		get_indent(sci, pos, FALSE);
 		sci_add_text(sci, indent);
 
-		if (editor_prefs.indent_mode == INDENT_ADVANCED)
+		if (editor_prefs.indent_mode > INDENT_BASIC)
 		{
 			// add extra indentation for Python after colon
 			if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_PYTHON &&
@@ -489,7 +488,7 @@
 	{
 		if (linebuf[i] == ' ' || linebuf[i] == '\t')	// simple indentation
 			indent[j++] = linebuf[i];
-		else if (editor_prefs.indent_mode != INDENT_ADVANCED)
+		else if (editor_prefs.indent_mode <= INDENT_BASIC)
 			break;
 		else if (use_this_line)
 			break;
@@ -580,15 +579,19 @@
 }
 
 
-/* Called after typing '}', if editor_prefs.indent_mode is INDENT_ADVANCED. */
+/* Called after typing '}'. */
 void editor_close_block(gint idx, gint pos)
 {
 	gint x = 0, cnt = 0;
-	gint start_brace, line, line_len, eol_char_len;
+	gint line, line_len, eol_char_len;
 	gchar *text, *line_buf;
 	ScintillaObject *sci;
+	gint line_indent, last_indent;
 
-	if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_type == NULL) return;
+	if (editor_prefs.indent_mode < INDENT_CURRENTCHARS)
+		return;
+	if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_type == NULL)
+		return;
 
 	sci = doc_list[idx].sci;
 
@@ -611,34 +614,37 @@
 	}
 	g_free(line_buf);
 
-	if ((line_len - eol_char_len - 1) != cnt) return;
+	if ((line_len - eol_char_len - 1) != cnt)
+		return;
 
-	start_brace = brace_match(sci, pos);	// same as sci_find_bracematch (Document::BraceMatch)?
-
-	if (start_brace >= 0)
+	if (editor_prefs.indent_mode == INDENT_MATCHBRACES)
 	{
-		gint line_start;
+		gint start_brace = brace_match(sci, pos);
 
-		get_indent(sci, start_brace, TRUE);
-		text = g_strconcat(indent, "}", NULL);
-		line_start = sci_get_position_from_line(sci, line);
-		sci_set_anchor(sci, line_start);
-		SSM(sci, SCI_REPLACESEL, 0, (sptr_t) text);
-		g_free(text);
-	}
-	else
-	if (sci_get_lexer(sci) == SCLEX_HTML || sci_get_lexer(sci) == SCLEX_TCL)
-	{	/* For TCL & PHP brace_match doesn't work here (maybe lexer bugs?),
-		 * so this is a simple workaround. */
-		gint line_indent = sci_get_line_indentation(sci, line);
-		gint last_indent = sci_get_line_indentation(sci, line - 1);
+		if (start_brace >= 0)
+		{
+			gint line_start;
 
-		if (line_indent < last_indent)
+			get_indent(sci, start_brace, TRUE);
+			text = g_strconcat(indent, "}", NULL);
+			line_start = sci_get_position_from_line(sci, line);
+			sci_set_anchor(sci, line_start);
+			SSM(sci, SCI_REPLACESEL, 0, (sptr_t) text);
+			g_free(text);
 			return;
-		line_indent -= editor_prefs.tab_width;
-		line_indent = MAX(0, line_indent);
-		sci_set_line_indentation(sci, line, line_indent);
+		}
+		// fall through - unmatched brace (possibly because of TCL, PHP lexer bugs)
 	}
+
+	// INDENT_CURRENTCHARS
+	line_indent = sci_get_line_indentation(sci, line);
+	last_indent = sci_get_line_indentation(sci, line - 1);
+
+	if (line_indent < last_indent)
+		return;
+	line_indent -= editor_prefs.tab_width;
+	line_indent = MAX(0, line_indent);
+	sci_set_line_indentation(sci, line, line_indent);
 }
 
 

Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/src/editor.h	2007-08-29 15:14:07 UTC (rev 1836)
@@ -35,7 +35,8 @@
 {
 	INDENT_NONE = 0,
 	INDENT_BASIC,
-	INDENT_ADVANCED
+	INDENT_CURRENTCHARS,
+	INDENT_MATCHBRACES
 } IndentMode;
 
 /* These are the default prefs when creating a new editor window.

Modified: trunk/src/interface.c
===================================================================
--- trunk/src/interface.c	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/src/interface.c	2007-08-29 15:14:07 UTC (rev 1836)
@@ -3493,7 +3493,8 @@
                     (GtkAttachOptions) (GTK_FILL), 0, 0);
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("None"));
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Basic"));
-  gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Advanced"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Current chars"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Match braces"));
 
   label195 = gtk_label_new (_("<b>Indentation</b>"));
   gtk_widget_show (label195);

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2007-08-28 16:15:26 UTC (rev 1835)
+++ trunk/src/keyfile.c	2007-08-29 15:14:07 UTC (rev 1836)
@@ -428,7 +428,7 @@
 	editor_prefs.long_line_column = utils_get_setting_integer(config, PACKAGE, "long_line_column", 72);
 	editor_prefs.autocompletion_max_height = utils_get_setting_integer(config, PACKAGE, "autocompletion_max_height", GEANY_MAX_AUTOCOMPLETE_HEIGHT);
 	editor_prefs.line_wrapping = utils_get_setting_boolean(config, PACKAGE, "line_breaking", FALSE); // default is off for better performance
-	editor_prefs.indent_mode = utils_get_setting_integer(config, PACKAGE, "indent_mode", INDENT_ADVANCED);
+	editor_prefs.indent_mode = utils_get_setting_integer(config, PACKAGE, "indent_mode", INDENT_CURRENTCHARS);
 	editor_prefs.use_tab_to_indent = utils_get_setting_boolean(config, PACKAGE, "use_tab_to_indent", FALSE);
 	editor_prefs.use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
 	editor_prefs.show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list