SF.net SVN: geany: [772] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Tue Aug 29 16:12:02 UTC 2006
Revision: 772
Author: eht16
Date: 2006-08-29 09:11:55 -0700 (Tue, 29 Aug 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=772&view=rev
Log Message:
-----------
Added auto completion for LaTeX command "begin".
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/sci_cb.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-08-28 16:27:16 UTC (rev 771)
+++ trunk/ChangeLog 2006-08-29 16:11:55 UTC (rev 772)
@@ -1,3 +1,8 @@
+2006-08-29 Enrico Tröger <enrico.troeger at uvena.de>
+
+ * src/sci_cb.c: Added auto completion for LaTeX command "begin".
+
+
2006-08-28 Enrico Tröger <enrico.troeger at uvena.de>
* geany.glade, src/interface.c: Fixed typo in a tooltip text.
Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c 2006-08-28 16:27:16 UTC (rev 771)
+++ trunk/src/sci_cb.c 2006-08-29 16:11:55 UTC (rev 772)
@@ -614,12 +614,10 @@
void sci_cb_auto_latex(ScintillaObject *sci, gint pos, gint idx)
{
- // currently disabled
-#if 0
if (sci_get_char_at(sci, pos - 2) == '}')
{
gchar *eol, *buf, *construct;
- gchar env[30]; /// FIXME are 30 chars enough?
+ gchar env[50];
gint line = sci_get_line_from_position(sci, pos - 2);
gint line_len = sci_get_line_length(sci, line);
gint i, start;
@@ -629,21 +627,35 @@
sci_get_line(sci, line, buf);
// get to the first non-blank char (some kind of ltrim())
- i = start = 0;
- while (isspace(buf[i++])) start++;
+ start = 0;
+ //while (isspace(buf[i++])) start++;
+ while (isspace(buf[start])) start++;
// check for begin
if (strncmp(buf + start, "\\begin", 6) == 0)
{
- // goto through the line and get the environment, begin at first non-blank char (= start)
- for (i = start; i < line_len; i++)
+ gchar full_cmd[15];
+ gint j = 0;
+
+ // take also "\begingroup" (or whatever there can be) and append "\endgroup" and so on.
+ i = start + 6;
+ while (buf[i] != '{' && j < (sizeof(full_cmd) - 1))
+ { // copy all between "\begin" and "{" to full_cmd
+ full_cmd[j] = buf[i];
+ i++;
+ j++;
+ }
+ full_cmd[j] = '\0';
+
+ // go through the line and get the environment
+ for (i = start + j; i < line_len; i++)
{
if (buf[i] == '{')
{
- gint j = 0;
+ j = 0;
i++;
- while (buf[i] != '}')
- { // this could be done in a shorter way, but so it resists readable ;-)
+ while (buf[i] != '}' && j < (sizeof(env) - 1))
+ { // this could be done in a shorter way, but so it remains readable ;-)
env[j] = buf[i];
j++;
i++;
@@ -657,7 +669,7 @@
if (doc_list[idx].use_auto_indention) sci_cb_get_indent(sci, pos, TRUE);
eol = g_strconcat(utils_get_eol_char(idx), indent, NULL);
- construct = g_strdup_printf("%s\\end{%s}", eol, env);
+ construct = g_strdup_printf("%s\\end%s{%s}", eol, full_cmd, env);
SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct);
sci_goto_pos(sci, pos + 1, TRUE);
@@ -670,7 +682,6 @@
return;
}
}
-#endif
}
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