On Fri, 22 Oct 2010 13:38:42 +0100%
Nick Treleaven <[email protected]> wrote:

> On Fri, 22 Oct 2010 12:51:10 +0400
> Eugene Arshinov <[email protected]> wrote:
> 
> > > > The suggestion is to make use of snippets: if "table" or
> > > > "<table>" snippet is specified in [HTML] section of
> > > > snippets.conf, the snippet is automatically inserted, otherwise
> > > > <table> tag is just closed, like other tags now.  This should
> > > > also work for any other tag.
> > > > 
> > > > Though, you can just define a snippet (say, "table") and use it
> > > > when you want to insert a table.  I doubt it's worth
> > > > implementing the suggestion if everything it gives is the
> > > > ability to type "<table>" instead of typing "table" and
> > > > pressing complete-snippet keybinding.
> > > 
> > > Perhaps the behaviour could be moved to the 'HTML chars' plugin,
> > > which could be renamed HTML or Markup.
> > 
> > Geany will have to notify the plugin about every char added.  Won't
> > it be too "heavy" to send a signal in this case?
> 
> Actually, this is already done for that plugin. See the editor-notify
> signal.
> 

Nice, I'll look at it sometime.

> > > We could add a 'table' snippet. With the <> angle brackets you
> > > would probably get the automatic closing tag before pressing tab
> > > to complete the snippet.
> > 
> > I think it's reasonable to remove "autotable" and add "table"
> > snippet instead.
> 
> Perhaps this is better because then the user can decide when to use
> the completion, instead of always. Patch welcome.

Attached :)

Best regards,
Eugene.
diff --git a/data/snippets.conf b/data/snippets.conf
index 042413a..dbc5e0c 100644
--- a/data/snippets.conf
+++ b/data/snippets.conf
@@ -71,3 +71,6 @@ monitor=monitor%block_cursor%handle%block%
 [Haskell]
 # prevent completion of "do"-while-loops in Haskell
 do=
+
+[HTML]
+table=<table>\n\t<tr>\n\t\t<td> </td>\n\t</tr>\n</table>
\ No newline at end of file
diff --git a/src/editor.c b/src/editor.c
index a012f7d..5e1fdca 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -106,7 +106,6 @@ static void auto_multiline(GeanyEditor *editor, gint pos);
 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 void auto_table(GeanyEditor *editor, gint pos);
 static void close_block(GeanyEditor *editor, gint pos);
 static void editor_highlight_braces(GeanyEditor *editor, gint cur_pos);
 static void read_current_word(GeanyEditor *editor, gint pos, gchar *word, size_t wordlen,
@@ -2600,11 +2599,7 @@ static void insert_closing_tag(GeanyEditor *editor, gint pos, gchar ch, const gc
 	sci_start_undo_action(sci);
 	sci_replace_sel(sci, to_insert);
 	if (ch == '>')
-	{
 		sci_set_selection(sci, pos, pos);
-		if (utils_str_equal(tag_name, "table"))
-			auto_table(editor, pos);
-	}
 	sci_end_undo_action(sci);
 	g_free(to_insert);
 }
@@ -2703,50 +2698,6 @@ static gsize count_indent_size(GeanyEditor *editor, const gchar *base_indent)
 }
 
 
-static void auto_table(GeanyEditor *editor, gint pos)
-{
-	ScintillaObject *sci = editor->sci;
-	gchar *table;
-	gint indent_pos;
-	const gchar *indent_str;
-
-	if (sci_get_lexer(sci) != SCLEX_HTML) return;
-
-	read_indent(editor, pos);
-	indent_pos = sci_get_line_indent_position(sci, sci_get_line_from_position(sci, pos));
-	if ((pos - 7) != indent_pos) /* 7 == strlen("<table>") */
-	{
-		gint i;
-		guint x;
-
-		x = strlen(indent);
-		/* find the start of the <table tag */
-		i = 1;
-		while (i <= pos && sci_get_char_at(sci, pos - i) != '<') i++;
-		/* add all non whitespace before the tag to the indent string */
-		while ((pos - i) != indent_pos && x < sizeof(indent) - 1)
-		{
-			indent[x++] = ' ';
-			i++;
-		}
-		indent[x] = '\0';
-	}
-
-	if (! editor->auto_indent)
-		indent_str = "";
-	else
-		indent_str = "\t";
-
-	table = g_strconcat("\n", indent_str, "<tr>\n",
-						indent_str, indent_str, "<td> </td>\n",
-						indent_str, "</tr>\n",
-						NULL);
-	editor_insert_text_block(editor, table, pos, -1,
-		count_indent_size(editor, indent), TRUE);
-	g_free(table);
-}
-
-
 static void real_comment_multiline(GeanyEditor *editor, gint line_start, gint last_line)
 {
 	const gchar *eol;
_______________________________________________
Geany mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany

Reply via email to