SF.net SVN: geany:[3228] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Nov 14 18:02:29 UTC 2008
Revision: 3228
http://geany.svn.sourceforge.net/geany/?rev=3228&view=rev
Author: ntrel
Date: 2008-11-14 18:02:28 +0000 (Fri, 14 Nov 2008)
Log Message:
-----------
Make auto_table() use editor_insert_text_block().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-11-14 17:24:54 UTC (rev 3227)
+++ trunk/ChangeLog 2008-11-14 18:02:28 UTC (rev 3228)
@@ -13,6 +13,8 @@
Add editor_insert_text_block() newline_indent_size argument to add
fixed indentation on each newline, or -1 to read from insert_pos's
line.
+ * src/editor.c:
+ Make auto_table() use editor_insert_text_block().
2008-11-13 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-11-14 17:24:54 UTC (rev 3227)
+++ trunk/src/editor.c 2008-11-14 18:02:28 UTC (rev 3228)
@@ -2016,6 +2016,7 @@
}
+/* like sci_get_line_indentation(), but for a string. */
static gsize count_indent_size(GeanyEditor *editor, const gchar *base_indent)
{
const gchar *ptr;
@@ -2040,45 +2041,12 @@
}
-static void string_append_indent_width(GString *str, const GeanyIndentPrefs *iprefs,
- gsize width)
-{
- gchar *ws = get_whitespace(iprefs, width);
-
- g_string_append(str, ws);
- g_free(ws);
-}
-
-
-static gchar *get_table_body(GeanyEditor *editor, const gchar *base_indent)
-{
- gsize base_size = count_indent_size(editor, base_indent);
- const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
- gsize indent_width = iprefs->width;
- GString *str = g_string_new("\n");
-
- if (! editor->auto_indent)
- indent_width = 0;
-
- string_append_indent_width(str, iprefs, base_size + indent_width);
- g_string_append(str, "<tr>\n");
- string_append_indent_width(str, iprefs, base_size + indent_width + indent_width);
- g_string_append(str, "<td>\n");
- string_append_indent_width(str, iprefs, base_size + indent_width + indent_width);
- g_string_append(str, "</td>\n");
- string_append_indent_width(str, iprefs, base_size + indent_width);
- g_string_append(str, "</tr>\n");
- string_append_indent_width(str, iprefs, base_size);
-
- return g_string_free(str, FALSE);
-}
-
-
static void auto_table(GeanyEditor *editor, gint pos)
{
ScintillaObject *sci = editor->sci;
gchar *table;
gint indent_pos;
+ const gchar *indent_str;
if (SSM(sci, SCI_GETLEXER, 0, 0) != SCLEX_HTML) return;
@@ -2102,9 +2070,18 @@
indent[x] = '\0';
}
- /* get indent string for generated code */
- table = get_table_body(editor, indent);
- sci_insert_text(sci, pos, table);
+ if (! editor->auto_indent)
+ indent_str = "";
+ else
+ indent_str = "\t";
+
+ table = g_strconcat("\n", indent_str, "<tr>\n",
+ indent_str, indent_str, "<td>\n",
+ indent_str, indent_str, "</td>\n",
+ indent_str, "</tr>\n",
+ NULL);
+ editor_insert_text_block(editor, table, pos, -1,
+ count_indent_size(editor, indent));
g_free(table);
}
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