Make marker and matching brace keybindings global.

(Also indent some case statement bodies).


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1507 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2007-05-05 16:35:59 +00:00
parent e83bf14955
commit ad56cd59de
2 changed files with 93 additions and 78 deletions

View File

@ -1,3 +1,10 @@
2007-05-05 Nick Treleaven <nick.treleaven@btinternet.com>
* src/keybindings.c:
Make marker and matching brace keybindings global.
(Also indent some case statement bodies).
2007-05-05 Enrico Tröger <enrico.troeger@uvena.de>
* doc/geany.docbook: Applied patch from John Gabriele which adds some

View File

@ -99,6 +99,9 @@ static void cb_func_hide_show_all(guint key_id);
// common function for editing keybindings, only valid when scintilla has focus.
static void cb_func_edit(guint key_id);
// common function for global editing keybindings.
static void cb_func_edit_global(guint key_id);
// common function for keybindings using current word
static void cb_func_current_word(guint key_id);
@ -250,16 +253,16 @@ void keybindings_init(void)
GDK_2, GDK_CONTROL_MASK, "edit_sendtocmd2", _("Send to Custom Command 2"));
keys[GEANY_KEYS_EDIT_SENDTOCMD3] = fill(cb_func_edit,
GDK_3, GDK_CONTROL_MASK, "edit_sendtocmd3", _("Send to Custom Command 3"));
keys[GEANY_KEYS_EDIT_GOTOMATCHINGBRACE] = fill(cb_func_edit,
keys[GEANY_KEYS_EDIT_GOTOMATCHINGBRACE] = fill(cb_func_edit_global,
0, 0, "edit_gotomatchingbrace",
_("Goto matching brace"));
keys[GEANY_KEYS_EDIT_TOGGLEMARKER] = fill(cb_func_edit,
keys[GEANY_KEYS_EDIT_TOGGLEMARKER] = fill(cb_func_edit_global,
GDK_m, GDK_CONTROL_MASK, "edit_togglemarker",
_("Toggle marker"));
keys[GEANY_KEYS_EDIT_GOTONEXTMARKER] = fill(cb_func_edit,
keys[GEANY_KEYS_EDIT_GOTONEXTMARKER] = fill(cb_func_edit_global,
GDK_period, GDK_CONTROL_MASK, "edit_gotonextmarker",
_("Goto next marker"));
keys[GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER] = fill(cb_func_edit,
keys[GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER] = fill(cb_func_edit_global,
GDK_comma, GDK_CONTROL_MASK, "edit_gotopreviousmarker",
_("Goto previous marker"));
@ -846,39 +849,30 @@ static void cb_func_build_action(guint key_id)
case GEANY_KEYS_BUILD_COMPILE:
item = menu_items->item_compile;
break;
case GEANY_KEYS_BUILD_LINK:
item = menu_items->item_link;
break;
case GEANY_KEYS_BUILD_MAKE:
item = menu_items->item_make_all;
break;
case GEANY_KEYS_BUILD_MAKEOWNTARGET:
item = menu_items->item_make_custom;
break;
case GEANY_KEYS_BUILD_MAKEOBJECT:
item = menu_items->item_make_object;
break;
case GEANY_KEYS_BUILD_NEXTERROR:
item = menu_items->item_next_error;
break;
case GEANY_KEYS_BUILD_RUN:
item = menu_items->item_exec;
break;
case GEANY_KEYS_BUILD_RUN2:
item = menu_items->item_exec2;
break;
case GEANY_KEYS_BUILD_OPTIONS:
item = menu_items->item_set_args;
break;
default:
item = NULL;
}
@ -1062,18 +1056,64 @@ static void goto_matching_brace(gint idx)
}
/* Common function for editing keybindings that don't change any text, and are
* useful even when sci doesn't have focus. */
static void cb_func_edit_global(guint key_id)
{
gint idx = document_get_cur_idx();
gint cur_line;
if (! DOC_IDX_VALID(idx)) return;
cur_line = sci_get_current_line(doc_list[idx].sci, -1);
switch (key_id)
{
case GEANY_KEYS_EDIT_GOTOMATCHINGBRACE:
goto_matching_brace(idx);
break;
case GEANY_KEYS_EDIT_TOGGLEMARKER:
{
gboolean set = sci_is_marker_set_at_line(doc_list[idx].sci, cur_line, 1);
sci_set_marker_at_line(doc_list[idx].sci, cur_line, ! set, 1);
break;
}
case GEANY_KEYS_EDIT_GOTONEXTMARKER:
{
gint mline = sci_marker_next(doc_list[idx].sci, cur_line + 1, 1 << 1, TRUE);
if (mline != -1)
{
sci_goto_line(doc_list[idx].sci, mline, TRUE);
doc_list[idx].scroll_percent = 0.5F;
}
break;
}
case GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER:
{
gint mline = sci_marker_previous(doc_list[idx].sci, cur_line - 1, 1 << 1, TRUE);
if (mline != -1)
{
sci_goto_line(doc_list[idx].sci, mline, TRUE);
doc_list[idx].scroll_percent = 0.5F;
}
break;
}
}
}
// common function for editing keybindings, only valid when scintilla has focus.
static void cb_func_edit(guint key_id)
{
gint idx = document_get_cur_idx();
gint cur_line;
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window));
// edit keybindings only valid when scintilla widget has focus
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(doc_list[idx].sci)) return;
cur_line = sci_get_current_line(doc_list[idx].sci, -1);
switch (key_id)
{
case GEANY_KEYS_EDIT_DUPLICATELINE:
@ -1124,38 +1164,6 @@ static void cb_func_edit(guint key_id)
case GEANY_KEYS_EDIT_DECREASEINDENT:
on_menu_decrease_indent1_activate(NULL, NULL);
break;
case GEANY_KEYS_EDIT_GOTOMATCHINGBRACE:
goto_matching_brace(idx);
break;
case GEANY_KEYS_EDIT_TOGGLEMARKER:
{
gboolean set = sci_is_marker_set_at_line(doc_list[idx].sci, cur_line, 1);
sci_set_marker_at_line(doc_list[idx].sci, cur_line, ! set, 1);
break;
}
case GEANY_KEYS_EDIT_GOTONEXTMARKER:
{
gint mline = sci_marker_next(doc_list[idx].sci, cur_line + 1, 1 << 1, TRUE);
if (mline != -1)
{
sci_goto_line(doc_list[idx].sci, mline, TRUE);
doc_list[idx].scroll_percent = 0.5F;
}
break;
}
case GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER:
{
gint mline = sci_marker_previous(doc_list[idx].sci, cur_line - 1, 1 << 1, TRUE);
if (mline != -1)
{
sci_goto_line(doc_list[idx].sci, mline, TRUE);
doc_list[idx].scroll_percent = 0.5F;
}
break;
}
case GEANY_KEYS_EDIT_TOLOWERCASE:
on_to_lower_case1_activate(NULL, NULL);
break;