Revision: 879 http://svn.sourceforge.net/geany/?rev=879&view=rev Author: eht16 Date: 2006-10-10 09:27:31 -0700 (Tue, 10 Oct 2006)
Log Message: ----------- Got rid of goto usage and added auto completion for monitor construct for filetype Ferite.
Modified Paths: -------------- trunk/ChangeLog trunk/src/sci_cb.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-10-10 16:02:41 UTC (rev 878) +++ trunk/ChangeLog 2006-10-10 16:27:31 UTC (rev 879) @@ -8,6 +8,8 @@ * src/document.c, src/sci_cb.c, src/callbacks.c: Finished new Undo system. Now some more actions can be undone and also redone. + * src/sci_cb.c: Got rid of goto usage and added auto completion for + monitor construct for filetype Ferite.
2006-10-09 Nick Treleaven nick.treleaven@btinternet.com
Modified: trunk/src/sci_cb.c =================================================================== --- trunk/src/sci_cb.c 2006-10-10 16:02:41 UTC (rev 878) +++ trunk/src/sci_cb.c 2006-10-10 16:27:31 UTC (rev 879) @@ -757,11 +757,13 @@ gchar *construct; gint lexer, style; gint i; + gint last_pos; ScintillaObject *sci;
if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_type == NULL) return; sci = doc_list[idx].sci;
+ last_pos = sci_get_length(sci); lexer = SSM(sci, SCI_GETLEXER, 0, 0); style = SSM(sci, SCI_GETSTYLEAT, pos - 2, 0);
@@ -799,16 +801,24 @@ // check the first 8 characters of buf for whitespace, but only in this line i = 14; while (isalpha(buf[i])) i--; // find pos before keyword - while (i >= 0 && buf[i] != '\n' && buf[i] != '\r') // we want to keep in this line('\n' check) + while (i >= 0 && buf[i] != '\n' && buf[i] != '\r') // we want to stay in this line('\n' check) { - if (! isspace(buf[i])) goto free_and_return; + if (! isspace(buf[i])) + { + g_free(eol); + return; + } i--; }
// "pattern", buf + x, y -> x + y = 15, because buf is (pos - 16)...(pos - 1) = 15 if (! strncmp("if", buf + 13, 2)) { - if (! isspace(*(buf + 12))) goto free_and_return; + if (! isspace(*(buf + 12))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("()%s{%s\t%s}%s", eol, eol, eol, eol);
@@ -818,7 +828,11 @@ } else if (! strncmp("else", buf + 11, 4)) { - if (! isspace(*(buf + 10))) goto free_and_return; + if (! isspace(*(buf + 10))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("%s{%s\t%s}%s", eol, eol, eol, eol);
@@ -831,7 +845,11 @@ gchar *var; gint contruct_len;
- if (! isspace(*(buf + 11))) goto free_and_return; + if (! isspace(*(buf + 11))) + { + g_free(eol); + return; + }
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PHP) { @@ -857,7 +875,11 @@ } else if (! strncmp("while", buf + 10, 5)) { - if (! isspace(*(buf + 9))) goto free_and_return; + if (! isspace(*(buf + 9))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("()%s{%s\t%s}%s", eol, eol, eol, eol);
@@ -867,7 +889,11 @@ } else if (! strncmp("do", buf + 13, 2)) { - if (! isspace(*(buf + 12))) goto free_and_return; + if (! isspace(*(buf + 12))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("%s{%s\t%s}%swhile ();%s", eol, eol, eol, eol, eol);
@@ -877,7 +903,11 @@ } else if (! strncmp("try", buf + 12, 3)) { - if (! isspace(*(buf + 11))) goto free_and_return; + if (! isspace(*(buf + 11))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("%s{%s\t%s}%scatch ()%s{%s\t%s}%s", eol, eol, eol, eol, eol, eol, eol, eol); @@ -888,7 +918,11 @@ } else if (! strncmp("switch", buf + 9, 6)) { - if (! isspace(*(buf + 8))) goto free_and_return; + if (! isspace(*(buf + 8))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("()%s{%s\tcase : break;%s\tdefault: %s}%s", eol, eol, eol, eol, eol);
@@ -896,10 +930,14 @@ sci_goto_pos(sci, pos + 1, TRUE); g_free(construct); } - else if (! strncmp("iferr", buf + 10, 5)) + else if (doc_list[idx].file_type->id == GEANY_FILETYPES_FERITE && ! strncmp("iferr", buf + 10, 5)) { if (doc_list[idx].file_type->id != GEANY_FILETYPES_FERITE || - ! isspace(*(buf + 9))) goto free_and_return; + ! isspace(*(buf + 9))) + { + g_free(eol); + return; + }
construct = g_strdup_printf("%s{%s\t%s}%sfix%s{%s\t%s}%s", eol, eol, eol, eol, eol, eol, eol, eol);
@@ -907,9 +945,20 @@ sci_goto_pos(sci, pos + 4 + (2 * strlen(indent)), TRUE); g_free(construct); } + else if (doc_list[idx].file_type->id == GEANY_FILETYPES_FERITE && ! strncmp("monitor", buf + 8, 7)) + { + if (! isspace(*(buf + 7))) + { + g_free(eol); + return; + }
- free_and_return: - g_free(eol); + construct = g_strdup_printf("%s{%s\t%s}%shandle%s{%s\t%s}%s", eol, eol, eol, eol, eol, eol, eol, eol); + + SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct); + sci_goto_pos(sci, pos + 4 + (2 * strlen(indent)), TRUE); + g_free(construct); + } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.