Revision: 4015 http://geany.svn.sourceforge.net/geany/?rev=4015&view=rev Author: ntrel Date: 2009-07-23 16:23:28 +0000 (Thu, 23 Jul 2009)
Log Message: ----------- For the Tabs indent type, remove spaces when unindenting (only) if there are no tabs on the line. Group undo actions for (un)indenting of multiple lines.
Modified Paths: -------------- trunk/ChangeLog trunk/src/editor.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-07-23 16:01:45 UTC (rev 4014) +++ trunk/ChangeLog 2009-07-23 16:23:28 UTC (rev 4015) @@ -8,6 +8,10 @@ src/printing.c, src/callbacks.c: Rename utils_str_replace() utils_str_replace_all(), setting a 'gchar **haystack' argument instead of returning a new string. + * src/editor.c: + For the Tabs indent type, remove spaces when unindenting (only) if + there are no tabs on the line. + Group undo actions for (un)indenting of multiple lines.
2009-07-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/editor.c =================================================================== --- trunk/src/editor.c 2009-07-23 16:01:45 UTC (rev 4014) +++ trunk/src/editor.c 2009-07-23 16:23:28 UTC (rev 4015) @@ -4785,8 +4785,9 @@
/* This is for tab-indents, space aligns formatted code. Spaces should be preserved. */ -static void change_tab_indentation(ScintillaObject *sci, gint line, gboolean increase) +static void change_tab_indentation(GeanyEditor *editor, gint line, gboolean increase) { + ScintillaObject *sci = editor->sci; gint pos = sci_get_position_from_line(sci, line);
if (increase) @@ -4800,6 +4801,13 @@ sci_set_selection(sci, pos, pos + 1); sci_replace_sel(sci, ""); } + else /* remove spaces only if no tabs */ + { + gint width = sci_get_line_indentation(sci, line); + + width -= editor_get_indent_prefs(editor)->width; + sci_set_line_indentation(sci, line, width); + } } }
@@ -4809,8 +4817,8 @@ const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor); ScintillaObject *sci = editor->sci;
- if (iprefs->type == GEANY_INDENT_TYPE_TABS /* && iprefs->ignore_spaces */) - change_tab_indentation(sci, line, increase); + if (iprefs->type == GEANY_INDENT_TYPE_TABS) + change_tab_indentation(editor, line, increase); else { gint width = sci_get_line_indentation(sci, line); @@ -4841,10 +4849,14 @@ if (end == sci_get_length(sci)) lend++; /* for last line with text on it */
+ sci_start_undo_action(sci); for (line = lstart; line < lend; line++) { editor_change_line_indent(editor, line, increase); } + sci_end_undo_action(sci); + + /* set cursor/selection */ if (lend > lstart) { sci_set_selection_start(sci, start);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.