64#include <gdk/gdkkeysyms.h>
102 const gchar *wc, gboolean stem);
119 gsize i, j, len = 0, len_keys = 0;
120 gchar **groups_user, **groups_sys;
121 gchar **keys_user, **keys_sys;
127 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
130 groups_sys = g_key_file_get_groups(sysconfig, &len);
131 for (i = 0; i < len; i++)
133 if (strcmp(groups_sys[i],
"Keybindings") == 0)
135 keys_sys = g_key_file_get_keys(sysconfig, groups_sys[i], &len_keys,
NULL);
137 tmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
138 g_hash_table_insert(
snippet_hash, g_strdup(groups_sys[i]), tmp);
140 for (j = 0; j < len_keys; j++)
142 g_hash_table_insert(tmp, g_strdup(keys_sys[j]),
145 g_strfreev(keys_sys);
147 g_strfreev(groups_sys);
150 groups_user = g_key_file_get_groups(userconfig, &len);
151 for (i = 0; i < len; i++)
153 if (strcmp(groups_user[i],
"Keybindings") == 0)
155 keys_user = g_key_file_get_keys(userconfig, groups_user[i], &len_keys,
NULL);
157 tmp = g_hash_table_lookup(
snippet_hash, groups_user[i]);
160 tmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
161 g_hash_table_insert(
snippet_hash, g_strdup(groups_user[i]), tmp);
163 for (j = 0; j < len_keys; j++)
165 value = g_hash_table_lookup(tmp, keys_user[j]);
168 g_hash_table_insert(tmp, g_strdup(keys_user[j]),
173 g_hash_table_replace(tmp, g_strdup(keys_user[j]),
177 g_strfreev(keys_user);
179 g_strfreev(groups_user);
188 if (!doc || !gtk_widget_has_focus(GTK_WIDGET(doc->
editor->
sci)))
194 GHashTable *specials = g_hash_table_lookup(
snippet_hash,
"Special");
196 if (G_LIKELY(specials !=
NULL))
197 s = g_hash_table_lookup(specials, key);
212static void add_kb(GKeyFile *keyfile,
const gchar *
group, gchar **keys)
218 for (i = 0; i < g_strv_length(keys); i++)
221 GdkModifierType mods;
222 gchar *accel_string = g_key_file_get_value(keyfile,
group, keys[i],
NULL);
224 gtk_accelerator_parse(accel_string, &key, &mods);
225 g_free(accel_string);
227 if (key == 0 && mods == 0)
229 g_warning(
"Can not parse accelerator \"%s\" from user snippets.conf", accel_string);
234 g_strdup(keys[i]), (GClosureNotify)g_free));
239static void load_kb(GKeyFile *sysconfig, GKeyFile *userconfig)
241 const gchar kb_group[] =
"Keybindings";
242 gchar **keys = g_key_file_get_keys(userconfig, kb_group,
NULL,
NULL);
247 g_key_file_remove_key(sysconfig, kb_group, *
ptr,
NULL);
249 add_kb(userconfig, kb_group, keys);
252 keys = g_key_file_get_keys(sysconfig, kb_group,
NULL,
NULL);
253 add_kb(sysconfig, kb_group, keys);
260 gchar *sysconfigfile, *userconfigfile;
261 GKeyFile *sysconfig = g_key_file_new();
262 GKeyFile *userconfig = g_key_file_new();
264 sysconfigfile = g_build_filename(
app->
datadir,
"snippets.conf",
NULL);
268 if (! g_file_test(userconfigfile, G_FILE_TEST_IS_REGULAR))
272 g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE,
NULL);
273 g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE,
NULL);
280 load_kb(sysconfig, userconfig);
282 g_free(sysconfigfile);
283 g_free(userconfigfile);
284 g_key_file_free(sysconfig);
285 g_key_file_free(userconfig);
298 if (event->x > 0.0 && event->y > 0.0)
300 (gint)event->x, (gint)event->y, FALSE);
304 if (event->button == 1)
329 if (event->button == 3)
334 gtk_widget_grab_focus(widget);
344 g_signal_emit_by_name(
geany_object,
"update-editor-menu",
397#define get_project_pref(id)\
398 (app->project ? app->project->priv->id : editor_prefs.id)
443 ScintillaObject *
sci;
446 g_return_if_fail(editor !=
NULL);
503 ScintillaObject *
sci = editor->
sci;
538 ScintillaObject *
sci = editor->
sci;
539 gint
line, lstart, col;
563 gint diff, last_pos, last_col;
570 diff = last_col - col;
594 if (rootlen >= words->len ||
595 (words->str[rootlen] ==
'?' && rootlen >= words->len - 2))
608 ScintillaObject *
sci = editor->
sci;
610 g_return_if_fail(tags);
614 GString *words = g_string_sized_new(150);
617 for (j = 0; j < tags->len; ++j)
619 TMTag *tag = tags->pdata[j];
622 g_string_append_c(words,
'\n');
626 g_string_append(words,
"...");
629 g_string_append(words, tag->
name);
633 g_string_append(words,
"?2");
635 g_string_append(words,
"?1");
638 g_string_free(words, TRUE);
646 gsize len = strlen(str);
649 g_return_val_if_fail(len < 100, FALSE);
654 buf = g_alloca(len + 1);
656 return strcmp(str, buf) == 0;
694 ScintillaObject *
sci = editor->
sci;
701 gboolean function = FALSE;
703 gboolean scope_sep_typed = FALSE;
704 gboolean ret = FALSE;
705 const gchar *current_scope;
724 pos -= strlen(context_sep);
725 scope_sep_typed = TRUE;
727 else if (typed ==
'.')
743 if (
pos > 0 && (brace_char ==
')' || brace_char ==
']'))
750 function = brace_char ==
')';
773 member, current_scope, scope_sep_typed);
776 GPtrArray *filtered = g_ptr_array_new();
782 if (g_str_has_prefix(tag->
name, root))
783 g_ptr_array_add(filtered, tag);
786 if (filtered->len > 0)
792 g_ptr_array_free(tags, TRUE);
793 g_ptr_array_free(filtered, TRUE);
803 ScintillaObject *
sci = editor->
sci;
879 gboolean force, gint visLevels, gint level)
882 gint levelLine = level;
884 while (*
line <= lineMaxSubord)
975 gboolean enforcePolicy)
990 gint next_linecount = 1;
994 while (next_linecount <= linecount)
995 next_linecount *= 10;
1023 if (strlen(
text) <= strlen(stem))
1026 text += strlen(stem);
1041 if (g_ascii_isupper(*
ptr) && g_ascii_islower(
ptr[1]))
1056 gpointer scnt, gpointer data)
1061 g_return_if_fail(editor !=
NULL);
1063 g_signal_emit_by_name(
geany_object,
"editor-notify", editor, scnt, &retval);
1079 ScintillaObject *
sci = editor->
sci;
1155 if (g_str_equal(nt->
text,
"..."))
1189 case 2:
calltip.tag_index++;
break;
1211 return indent_prefs->
width;
1222 g_return_val_if_fail(width >= 0,
NULL);
1225 return g_strdup(
"");
1229 return g_strnfill(width,
' ');
1234 gint
tabs = width / tab_width;
1235 gint spaces = width % tab_width;
1236 gint len =
tabs + spaces;
1239 str = g_malloc(len + 1);
1241 memset(str,
'\t',
tabs);
1242 memset(str +
tabs,
' ', spaces);
1295 ScintillaObject *
sci = editor->
sci;
1344 ScintillaObject *
sci = editor->
sci;
1345 guint i, len, j = 0;
1354 for (i = 0; i < len && j <= (
sizeof(
indent) - 1); i++)
1356 if (linebuf[i] ==
' ' || linebuf[i] ==
'\t')
1357 indent[j++] = linebuf[i];
1387 return count > 0 ? 1 : 0;
1427 gboolean need_close = FALSE;
1448 if (!
EMPTY(opened_tag_name))
1454 g_free(line_contents);
1455 g_free(opened_tag_name);
1459 return need_close ? 1 : 0;
1465 ScintillaObject *
sci = editor->
sci;
1469 g_return_val_if_fail(
line >= 0, 0);
1475 gint additional_indent = 0;
1485 if (additional_indent == 0 &&
1493 size += additional_indent;
1501 ScintillaObject *
sci = editor->
sci;
1529 const gchar *closing_char =
NULL;
1555 closing_char =
"\"";
1559 if (closing_char !=
NULL)
1575 gint direction = -1;
1597 if (chAtPos == chBrace)
1599 if (chAtPos == chSeek)
1614 gint x = 0, cnt = 0;
1615 gint
line, line_len;
1617 ScintillaObject *
sci;
1618 gint line_indent, last_indent;
1634 line_buf[line_len] =
'\0';
1635 while (x < line_len)
1637 if (isspace(line_buf[x]))
1643 if ((line_len - 1) != cnt)
1650 if (start_brace >= 0)
1656 gchar *
text = g_strconcat(ind,
"}",
NULL);
1672 if (line_indent < last_indent)
1674 line_indent -= iprefs->
width;
1675 line_indent =
MAX(0, line_indent);
1681#define IS_ASCII(c) (((unsigned char)(c)) < 0x80)
1689 const gchar *wc, gboolean stem)
1691 gint
line, line_start, startword, endword;
1693 ScintillaObject *
sci;
1695 g_return_if_fail(editor !=
NULL);
1703 startword =
pos - line_start;
1704 endword =
pos - line_start;
1715 while (startword > 0 && (strchr(wc, chunk[startword - 1]) || !
IS_ASCII(chunk[startword - 1])))
1719 while (chunk[endword] != 0 && (strchr(wc, chunk[endword]) || !
IS_ASCII(chunk[endword])))
1723 if (startword != endword)
1725 chunk[endword] =
'\0';
1727 g_strlcpy(word, chunk + startword, wordlen);
1730 g_strlcpy(word,
"", wordlen);
1754 g_return_if_fail(editor !=
NULL);
1766 if ((guint)(end - start) >= wordlen)
1767 end = start + (wordlen - 1);
1795 g_return_val_if_fail(editor !=
NULL, FALSE);
1799 return (*cword ==
'\0') ?
NULL : g_strdup(cword);
1811 return (*word) ? word :
NULL;
1817 gint orig_pos =
pos;
1819 while (
pos >= 0 &&
pos > orig_pos - 300)
1833 gint orig_pos =
pos;
1835 while (
pos > 0 &&
pos > orig_pos - 300)
1839 if (c ==
')') brackets++;
1840 else if (c ==
'(') brackets--;
1841 if (brackets < 0)
return pos;
1859 g_string_append(str, tag->
var_type);
1862 g_string_append_c(str,
'*');
1864 g_string_append_c(str,
' ');
1870 g_string_append(str, tag->
scope);
1871 g_string_append(str, cosep);
1873 g_string_append(str, tag->
name);
1874 g_string_append_c(str,
' ');
1875 g_string_append(str, tag->
arglist);
1880 g_string_append(str, tag->
name);
1881 g_string_append_c(str,
' ');
1882 g_string_append(str, tag->
arglist);
1887 g_string_append(str, tag->
var_type);
1901 GString *str =
NULL;
1904 g_return_val_if_fail(ft && word && *word,
NULL);
1910 g_ptr_array_free(tags, TRUE);
1914 tag =
TM_TAG(tags->pdata[0]);
1919 g_ptr_array_free(tags, TRUE);
1924 g_ptr_array_free(tags, TRUE);
1930 for (i = 0; i < tags->len; i++)
1932 tag =
TM_TAG(tags->pdata[i]);
1935 tags->pdata[i] =
NULL;
1940 g_ptr_array_free(tags, TRUE);
1948 tm_tags_sort((GPtrArray *) tags, sort_attr, TRUE, FALSE);
1956 calltip.last_word = g_strdup(word);
1959 for (i =
calltip.tag_index; i < tags->len; i++)
1961 tag =
TM_TAG(tags->pdata[i]);
1965 str = g_string_new(
NULL);
1967 g_string_prepend(str,
"\001 ");
1973 g_string_insert_c(str, 1,
'\002');
1975 g_string_prepend(str,
"\002 ");
1980 g_ptr_array_free(tags, TRUE);
1984 gchar *result = str->str;
1986 g_string_free(str, FALSE);
1996 gint orig_pos =
pos;
2001 ScintillaObject *
sci;
2003 g_return_val_if_fail(editor !=
NULL, FALSE);
2043 if (word[0] ==
'\0')
2066 g_return_val_if_fail(editor !=
NULL,
NULL);
2068 str = g_string_new(
NULL);
2070 return g_string_free(str, FALSE);
2072 return g_string_free(str, TRUE);
2083 g_return_val_if_fail(editor, FALSE);
2086 found = tags->len > 0;
2089 g_ptr_array_free(tags, TRUE);
2098 gboolean
try = FALSE;
2121 tmp = strchr(root,
'&');
2136 gint len, current, word_end;
2137 gint pos_find, flags;
2140 GSList *words =
NULL;
2155 while (pos_find >= 0 && pos_find < len)
2157 word_end = pos_find + rootlen;
2158 if (pos_find != current)
2162 word_length = word_end - pos_find;
2163 if (word_length > rootlen)
2167 if (g_slist_find_custom(words, word, (GCompareFunc)strcmp) !=
NULL)
2171 words = g_slist_prepend(words, word);
2189 ScintillaObject *
sci = editor->
sci;
2190 GSList *words, *node;
2201 str = g_string_sized_new(rootlen * 2 * 10);
2204 g_string_append(str, node->data);
2207 g_string_append_c(str,
'\n');
2211 g_string_append(str,
"\n...");
2213 g_slist_free(words);
2216 g_string_free(str, TRUE);
2223 gint rootlen, lexer, style;
2226 ScintillaObject *
sci;
2227 gboolean ret = FALSE;
2231 g_return_val_if_fail(editor !=
NULL, FALSE);
2238 if (G_UNLIKELY(
pos < 2))
2262 rootlen = strlen(root);
2281 if (!ret && rootlen > 0)
2284 rootlen == 3 && strcmp(root,
"php") == 0 &&
pos >= 5 &&
2315 gchar *result =
NULL;
2323 result = g_hash_table_lookup(tmp,
name);
2332 result = g_hash_table_lookup(tmp,
name);
2345 GString *pattern = user_data;
2347 g_return_if_fail(key !=
NULL);
2348 g_return_if_fail(value !=
NULL);
2350 needle = g_strconcat(
"%", (gchar*) key,
"%",
NULL);
2362 gint cflags = G_REGEX_MULTILINE;
2365 whitespace = g_strnfill(iprefs->
width,
' ');
2366 regex = g_regex_new(
"^ *(\t)", cflags, 0,
NULL);
2368 g_regex_unref(regex);
2381 str = g_strdup_printf(
"^\t*(%s)", whitespace);
2383 regex = g_regex_new(str, cflags, 0,
NULL);
2385 g_regex_unref(regex);
2398#define CURSOR_PLACEHOLDER "_"
2408 gboolean indicator_for_first)
2411 GSList *temp_list =
NULL;
2412 gint cursor_steps = 0;
2418 if (cursor_steps == -1)
2422 sel->
start = cursor_steps;
2424 if (i > 0 || indicator_for_first)
2430 temp_list = g_slist_append(temp_list, sel);
2457 gint cursor_index, gint newline_indent_size, gboolean replace_newlines)
2459 ScintillaObject *
sci = editor->
sci;
2463 GSList *jump_locs, *item;
2465 g_return_if_fail(
text);
2466 g_return_if_fail(editor !=
NULL);
2467 g_return_if_fail(insert_pos >= 0);
2469 buf = g_string_new(
text);
2471 if (cursor_index >= 0)
2474 if (newline_indent_size == -1)
2488 if (newline_indent_size > 0)
2490 const gchar *nl = replace_newlines ?
"\n" : eol;
2493 whitespace = g_strnfill(newline_indent_size,
' ');
2494 SETPTR(whitespace, g_strconcat(nl, whitespace,
NULL));
2500 if (replace_newlines)
2511 gint start = insert_pos + sel->
start;
2512 gint end = start + sel->
len;
2515 if (item == jump_locs)
2520 if (cursor_index >= 0)
2522 else if (jump_locs ==
NULL)
2525 g_slist_free_full(jump_locs, g_free);
2526 g_string_free(buf, TRUE);
2532 ScintillaObject *
sci = editor->
sci;
2551 return sel->
len > 0;
2559 ScintillaObject *
sci = editor->
sci;
2577 GHashTable *specials;
2580 specials = g_hash_table_lookup(
snippet_hash,
"Special");
2581 if (G_LIKELY(specials !=
NULL))
2603 ScintillaObject *
sci = editor->
sci;
2605 const gchar *completion;
2609 str = g_strdup(word);
2613 if (completion ==
NULL)
2622 str_len = strlen(str);
2645 if (c ==
' ' || c ==
'\t')
2657 gboolean result = FALSE;
2660 ScintillaObject *
sci;
2662 g_return_val_if_fail(editor !=
NULL, FALSE);
2692 ScintillaObject *
sci = editor->
sci;
2693 gchar *to_insert =
NULL;
2697 const gchar *gt =
">";
2702 to_insert = g_strconcat(tag_name, gt,
NULL);
2705 to_insert = g_strconcat(
"</", tag_name,
">",
NULL);
2724 ScintillaObject *
sci = editor->
sci;
2726 gint min, size, style;
2727 gchar *str_found, sel[512];
2728 gboolean result = FALSE;
2745 min =
pos - (
sizeof(sel) - 1);
2746 if (min < 0) min = 0;
2752 sel[
sizeof(sel) - 1] =
'\0';
2754 if (ch ==
'>' && sel[
pos - min - 2] ==
'/')
2767 else if (!
EMPTY(str_found))
2784 g_return_val_if_fail(base_indent, 0);
2786 for (
ptr = base_indent; *
ptr != 0;
ptr++)
2808 gint style, line_start;
2811 g_return_val_if_fail(editor !=
NULL,
NULL);
2861 gchar *str_begin, *str_end;
2862 const gchar *co, *cc;
2872 g_return_if_reached();
2873 str_begin = g_strdup_printf(
"%s%s", (co !=
NULL) ? co :
"", eol);
2874 str_end = g_strdup_printf(
"%s%s", (cc !=
NULL) ? cc :
"", eol);
2901 ttf.
chrg.
cpMin = backwards ? end + 1 : start;
2902 ttf.
chrg.
cpMax = backwards ? start : end + 1;
2918 gint start, end, start_line, end_line;
2920 const gchar *co, *cc;
2926 g_return_val_if_reached(FALSE);
2931 if (start < 0 || end < 0 || start > end )
2982 return style_comment;
2991 gint first_line, last_line;
2992 gint x, i, line_start, line_len;
2993 gint sel_start, sel_end;
2997 const gchar *co, *cc;
2998 gboolean single_line = FALSE;
3012 last_line =
MAX(first_line, last_line);
3016 first_line = last_line =
line;
3025 co_len = strlen(co);
3031 for (i = first_line; i <= last_line; i++)
3039 buf_len = MIN((gint)
sizeof(sel) - 1, line_len);
3043 sel[buf_len] =
'\0';
3045 while (isspace(sel[x])) x++;
3048 if (x < line_len && sel[x] !=
'\0')
3058 if (strncmp(sel + x, co, co_len) != 0 ||
3066 if (strncmp(sel + x, co, co_len) != 0)
3096 if (! toggle && sel_start < sel_end)
3117 gint first_line, last_line;
3118 gint x, i, line_start, line_len, first_line_start, last_line_start;
3119 gint sel_start, sel_end;
3120 gint count_commented = 0, count_uncommented = 0;
3122 const gchar *co, *cc;
3123 gboolean single_line = FALSE;
3124 gboolean first_line_was_comment = FALSE;
3125 gboolean last_line_was_comment = FALSE;
3139 last_line =
MAX(first_line, last_line);
3149 co_len = strlen(co);
3155 for (i = first_line; i <= last_line; i++)
3163 buf_len = MIN((gint)
sizeof(sel) - 1, line_len);
3167 sel[buf_len] =
'\0';
3169 while (isspace(sel[x])) x++;
3174 gboolean do_continue = FALSE;
3177 if (strncmp(sel + x, co, co_len) == 0 &&
3183 if (do_continue && i == first_line)
3184 first_line_was_comment = TRUE;
3185 last_line_was_comment = do_continue;
3206 count_uncommented++;
3226 gint a = (first_line_was_comment) ? - (gint) co_len : (gint) co_len;
3231 indent_len = (gint) strlen(
indent);
3232 if ((sel_start - first_line_start) <= indent_len)
3235 else if (first_line_was_comment &&
3236 sel_start >= (first_line_start + indent_len) &&
3237 sel_start <= (first_line_start + indent_len + (gint) co_len))
3239 a = (first_line_start + indent_len) - sel_start;
3242 if (sel_start < sel_end)
3244 gint b = (count_commented * (gint) co_len) - (count_uncommented * (gint) co_len);
3248 indent_len = (gint) strlen(
indent);
3249 if ((sel_end - last_line_start) < indent_len)
3250 b += last_line_was_comment ? (gint) co_len : -(gint) co_len;
3251 else if (last_line_was_comment &&
3252 sel_end >= (last_line_start + indent_len) &&
3253 sel_end <= (last_line_start + indent_len + (gint) co_len))
3255 b += (gint) co_len - (sel_end - (last_line_start + indent_len));
3267 if (count_uncommented > 0)
3272 else if (count_commented > 0)
3277 if (sel_start >= sel_end)
3285 gboolean single_comment)
3287 gint first_line, last_line;
3288 gint x, i, line_start, line_len;
3289 gint sel_start, sel_end, co_len;
3292 const gchar *co, *cc;
3293 gboolean single_line = FALSE;
3307 last_line =
MAX(first_line, last_line);
3311 first_line = last_line =
line;
3320 co_len = strlen(co);
3326 for (i = first_line; i <= last_line; i++)
3334 buf_len = MIN((gint)
sizeof(sel) - 1, line_len);
3338 sel[buf_len] =
'\0';
3340 while (isspace(sel[x])) x++;
3343 if (allow_empty_lines || (x < line_len && sel[x] !=
'\0'))
3348 gint start = line_start;
3352 start = line_start + x;
3386 if (! toggle && sel_start < sel_end)
3410 gint brace_pos = GPOINTER_TO_INT(user_data);
3411 gint end_pos, cur_pos;
3420 if (cur_pos != brace_pos)
3423 if (cur_pos != brace_pos)
3456 gint brace_pos = cur_pos - 1;
3515 if ((c ==
'*' || c ==
'+') && lexer ==
SCLEX_D)
3527 ScintillaObject *
sci = editor->
sci;
3528 gint indent_pos, style;
3543 const gchar *continuation =
"*";
3544 const gchar *whitespace =
"";
3546 gint len = strlen(previous_line);
3551 while (i >= 0 && isspace(previous_line[i])) i--;
3552 if (i >= 1 &&
is_comment_char(previous_line[i - 1], lexer) && previous_line[i] ==
'/')
3554 gint indent_len, indent_width;
3562 if (indent_len % indent_width == 1)
3564 g_free(previous_line);
3569 while (i < len && isspace(previous_line[i])) i++;
3572 previous_line[i] ==
'/' &&
is_comment_char(previous_line[i + 1], lexer))
3580 result = g_strconcat(whitespace, continuation,
" ",
NULL);
3584 g_free(previous_line);
3590static gboolean editor_lexer_is_c_like(gint lexer)
3612 gboolean have_multiline_comment = FALSE;
3614 const gchar *co, *cc;
3619 g_return_if_reached();
3621 have_multiline_comment = TRUE;
3638 text_len = strlen(
text);
3642 text = g_strdup(
"\n\n\n");
3658 if (have_multiline_comment)
3679 g_return_if_fail(editor !=
NULL);
3681 wid = GTK_WIDGET(editor->
sci);
3683 if (! gtk_widget_get_window(wid) || ! gdk_window_is_viewable(gtk_widget_get_window(wid)))
3694 line =
line - los * percent_of_view;
3706 g_return_if_fail(editor !=
NULL);
3708 switch (iprefs.
type)
3730 g_return_if_fail(editor !=
NULL);
3754 gint start, end,
line;
3756 g_return_if_fail(editor !=
NULL);
3762 if (! extra_line && start != end &&
3789 ScintillaObject *
sci = editor->
sci;
3795 if (direction == GTK_DIR_UP)
3815 if (direction == GTK_DIR_UP)
3826 gint pos_start, pos_end, line_start, line_found;
3828 g_return_if_fail(editor !=
NULL);
3833 if (line_found == -1)
3850 ScintillaObject *
sci = editor->
sci;
3856 if (direction == GTK_DIR_UP)
3878 if (direction == GTK_DIR_UP)
3889 gint pos_start, pos_end, line_start, line_found;
3891 g_return_if_fail(editor !=
NULL);
3896 if (line_found == -1)
3911 gint i, sel_start = 0, sel_end = 0;
3917 for (i = first_line; i <= last_line; i++)
3927 if (sel_start < sel_end)
3940 gint first_line, last_line;
3941 gint first_sel_start, first_sel_end;
3942 ScintillaObject *
sci;
3944 g_return_if_fail(editor !=
NULL);
3954 last_line =
MAX(first_line, last_line);
3961 if (first_sel_start == first_sel_end)
3982 gint i, first_line, last_line, line_start, indentation_end,
count = 0;
3983 gint sel_start, sel_end, first_line_offset = 0;
3985 g_return_if_fail(editor !=
NULL);
3993 last_line =
MAX(first_line, last_line);
4000 for (i = first_line; i <= last_line; i++)
4007 while (
sci_get_char_at(editor->
sci, indentation_end) !=
' ' && indentation_end > line_start)
4015 if (i == first_line)
4016 first_line_offset = -1;
4023 if (i == first_line)
4024 first_line_offset = 1;
4029 if (sel_start < sel_end)
4031 gint start = sel_start + first_line_offset;
4032 if (first_line_offset < 0)
4033 start =
MAX(sel_start + first_line_offset,
4062 g_return_val_if_fail(editor !=
NULL,
NULL);
4075 if (word[0] !=
'\0')
4091 g_return_val_if_fail(editor !=
NULL, FALSE);
4102 return (
line >= vis1 &&
line < vis1 + los);
4112 g_return_if_fail(editor !=
NULL);
4153 g_return_if_fail(editor !=
NULL);
4181 g_return_if_fail(editor !=
NULL);
4182 g_return_if_fail(
line >= 0);
4188 if ((start + 1) == end ||
4199 while (isspace(linebuf[i]))
4201 while (len > 1 && len > i && isspace(linebuf[len - 1]))
4227 g_return_if_fail(editor !=
NULL);
4240 g_return_if_fail(editor !=
NULL);
4245 const gchar *replacement = colour;
4333 default:
return 1;
break;
4362 gint
lines, first, i;
4370 for (i = 0; i <
lines; i++)
4398 gint anchor_pos, caret_pos;
4401 g_return_if_fail(editor !=
NULL);
4420 gint search_pos, pos_in_line, current_tab_true_length;
4425 if (search_pos == -1)
4430 current_tab_true_length = tab_len - (pos_in_line % tab_len);
4431 tab_str = g_strnfill(current_tab_true_length,
' ');
4436 ttf.
chrg.
cpMin = search_pos + current_tab_true_length - 1;
4438 ttf.
chrg.
cpMax += current_tab_true_length - 1;
4441 if (anchor_pos > search_pos)
4442 anchor_pos += current_tab_true_length - 1;
4443 if (caret_pos > search_pos)
4444 caret_pos += current_tab_true_length - 1;
4456 gint anchor_pos, caret_pos;
4457 static gdouble tab_len_f = -1.0;
4462 g_return_if_fail(editor !=
NULL);
4464 if (tab_len_f < 0.0)
4468 _(
"Enter Tab Width"),
4469 _(
"Enter the amount of spaces which should be replaced by a tab character."),
4470 &tab_len_f, 1, 100, 1))
4474 tab_len = (gint) tab_len_f;
4475 text = g_strnfill(tab_len,
' ');
4495 if (search_pos == -1)
4511 if (anchor_pos > search_pos)
4512 anchor_pos -= tab_len - 1;
4513 if (caret_pos > search_pos)
4514 caret_pos -= tab_len - 1;
4526 gint i = line_end - 1;
4533 while ((i >= line_start) && ((ch ==
' ') || (ch ==
'\t')))
4538 if (i < (line_end - 1))
4583 gboolean append_newline = (max_lines == 1);
4605 PangoFontDescription *pfd;
4608 g_return_if_fail(
sci);
4610 pfd = pango_font_description_from_string(font);
4611 size = pango_font_description_get_size(pfd) / (gdouble) PANGO_SCALE;
4612 font_name = g_strdup_printf(
"!%s", pango_font_description_get_family(pfd));
4613 pango_font_description_free(pfd);
4615 for (style = 0; style <=
STYLE_MAX; style++)
4624 g_return_if_fail(editor);
4635 g_return_if_fail(editor !=
NULL);
4671 ScintillaObject *
sci = editor->
sci;
4683 static gboolean warn = TRUE;
4705 g_return_val_if_fail(editor, FALSE);
4713 line_no = current_line + line_no;
4734 g_return_val_if_fail(editor, FALSE);
4735 if (G_UNLIKELY(
pos < 0))
4762 if (event->direction != GDK_SCROLL_UP && event->direction != GDK_SCROLL_DOWN)
4767 if (event->state & GDK_MOD1_MASK)
4772 else if (event->state & GDK_SHIFT_MASK)
4774 gint amount = (
event->direction == GDK_SCROLL_DOWN) ? 8 : -8;
4869 gint n_channels, rowstride, width, height;
4872 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &size,
NULL);
4873 pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
name, size, 0, &
error);
4876 g_warning(
"failed to load icon '%s': %s",
name,
error->message);
4877 g_error_free(
error);
4881 n_channels = gdk_pixbuf_get_n_channels(
pixbuf);
4882 rowstride = gdk_pixbuf_get_rowstride(
pixbuf);
4883 width = gdk_pixbuf_get_width(
pixbuf);
4884 height = gdk_pixbuf_get_height(
pixbuf);
4886 if (gdk_pixbuf_get_bits_per_sample(
pixbuf) != 8 ||
4887 ! gdk_pixbuf_get_has_alpha(
pixbuf) ||
4889 rowstride != width * n_channels)
4891 g_warning(
"incompatible image data for icon '%s'",
name);
4909 ScintillaObject *
sci;
4910 int rectangular_selection_modifier;
4917 gtk_widget_set_direction(GTK_WIDGET(
sci), GTK_TEXT_DIR_LTR);
4919 gtk_widget_show(GTK_WIDGET(
sci));
4944 rectangular_selection_modifier =
SCMOD_ALT;
4956#ifdef GDK_WINDOWING_QUARTZ
4957# if ! GTK_CHECK_VERSION(3,16,0)
4987 ScintillaObject *old, *
sci;
5054 g_return_val_if_fail(editor, FALSE);
5096 g_return_if_fail(editor !=
NULL);
5163 ScintillaObject *
sci;
5166 g_return_if_fail(editor !=
NULL);