Move %ws and %newline% replacement into snippets-only code.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3387 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
604fb1c627
commit
4b000e09ae
@ -13,6 +13,8 @@
|
||||
* src/search.c:
|
||||
Set Find in Files directory entry to project base path or current
|
||||
working directory if the current file has no path.
|
||||
* src/editor.c:
|
||||
Move %ws and %newline% replacement into snippets-only code.
|
||||
|
||||
|
||||
2008-12-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
13
src/editor.c
13
src/editor.c
@ -1789,7 +1789,6 @@ static void fix_line_indents(GeanyEditor *editor, gint line_start, gint line_end
|
||||
* NOT any hard tabs (you get those when copying document text with the Tabs
|
||||
* & Spaces indent mode set).
|
||||
* @note This doesn't scroll the cursor in view afterwards. */
|
||||
/* note: %ws% and %newline% are just for snippets, they probably shouldn't be here :-/ */
|
||||
static void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint insert_pos,
|
||||
gint cursor_index, gint newline_indent_size)
|
||||
{
|
||||
@ -1822,12 +1821,10 @@ static void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gin
|
||||
|
||||
/* transform line endings */
|
||||
utils_string_replace_all(buf, "\n", editor_get_eol_char(editor));
|
||||
utils_string_replace_all(buf, "%newline%", editor_get_eol_char(editor));
|
||||
|
||||
/* transform tabs into indent widths (in spaces) */
|
||||
whitespace = g_strnfill(editor_get_indent_prefs(editor)->width, ' ');
|
||||
utils_string_replace_all(buf, "\t", whitespace);
|
||||
utils_string_replace_all(buf, "%ws%", whitespace);
|
||||
g_free(whitespace);
|
||||
|
||||
if (cursor_index >= 0)
|
||||
@ -1852,7 +1849,7 @@ static void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gin
|
||||
|
||||
static gboolean snippets_complete_constructs(GeanyEditor *editor, gint pos, const gchar *word)
|
||||
{
|
||||
gchar *str;
|
||||
gchar *str, *whitespace;
|
||||
GString *pattern;
|
||||
gint step, str_len;
|
||||
gsize cur_index;
|
||||
@ -1892,6 +1889,14 @@ static gboolean snippets_complete_constructs(GeanyEditor *editor, gint pos, cons
|
||||
/* replace any %template% wildcards */
|
||||
snippets_replace_wildcards(editor, pattern);
|
||||
|
||||
/* transform other wildcards */
|
||||
utils_string_replace_all(pattern, "%newline%", editor_get_eol_char(editor));
|
||||
|
||||
/* use spaces for indentation, will be fixed up */
|
||||
whitespace = g_strnfill(editor_get_indent_prefs(editor)->width, ' ');
|
||||
utils_string_replace_all(pattern, "%ws%", whitespace);
|
||||
g_free(whitespace);
|
||||
|
||||
/* find the %cursor% pos (has to be done after all other operations) */
|
||||
step = utils_strpos(pattern->str, "%cursor%");
|
||||
if (step != -1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user