2006-05-19 17:18:06 +00:00
|
|
|
/*
|
|
|
|
* keybindings.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2010-01-01 22:55:18 +00:00
|
|
|
* Copyright 2006-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2006-05-19 17:18:06 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
2010-03-18 13:17:05 +00:00
|
|
|
/**
|
|
|
|
* @file keybindings.h
|
2007-02-24 11:41:56 +00:00
|
|
|
* Configurable keyboard shortcuts.
|
2010-08-10 12:43:30 +00:00
|
|
|
* - keybindings_send_command() mimics a built-in keybinding action.
|
2010-04-05 11:42:31 +00:00
|
|
|
* - @ref GeanyKeyGroupID lists groups of built-in keybindings.
|
2010-03-18 13:17:05 +00:00
|
|
|
* @see plugin_set_key_group().
|
|
|
|
**/
|
2006-05-19 17:18:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "geany.h"
|
2009-08-25 16:55:56 +00:00
|
|
|
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2006-05-19 17:18:06 +00:00
|
|
|
#include "keybindings.h"
|
|
|
|
#include "support.h"
|
|
|
|
#include "utils.h"
|
2006-09-05 14:24:47 +00:00
|
|
|
#include "ui_utils.h"
|
2006-05-19 17:18:06 +00:00
|
|
|
#include "document.h"
|
2009-02-05 19:10:57 +00:00
|
|
|
#include "documentprivate.h"
|
2007-08-15 15:37:21 +00:00
|
|
|
#include "filetypes.h"
|
2006-05-19 17:18:06 +00:00
|
|
|
#include "callbacks.h"
|
2006-07-11 14:15:56 +00:00
|
|
|
#include "prefs.h"
|
2006-05-19 17:18:06 +00:00
|
|
|
#include "msgwindow.h"
|
2007-05-28 16:07:30 +00:00
|
|
|
#include "editor.h"
|
2006-05-19 17:18:06 +00:00
|
|
|
#include "sciwrappers.h"
|
2006-10-18 19:35:42 +00:00
|
|
|
#include "build.h"
|
2007-02-25 14:26:55 +00:00
|
|
|
#include "tools.h"
|
2007-06-03 16:03:46 +00:00
|
|
|
#include "navqueue.h"
|
2007-09-25 12:39:41 +00:00
|
|
|
#include "symbols.h"
|
2007-09-26 16:22:20 +00:00
|
|
|
#include "vte.h"
|
2008-12-06 11:10:06 +00:00
|
|
|
#include "toolbar.h"
|
2009-09-28 11:16:59 +00:00
|
|
|
#include "sidebar.h"
|
2009-01-02 13:37:40 +00:00
|
|
|
#include "geanywraplabel.h"
|
2009-03-26 20:31:55 +00:00
|
|
|
#include "main.h"
|
2009-07-10 15:17:27 +00:00
|
|
|
#include "search.h"
|
2010-07-29 18:28:37 +00:00
|
|
|
#ifdef HAVE_VTE
|
|
|
|
# include "vte.h"
|
|
|
|
#endif
|
2006-05-19 17:18:06 +00:00
|
|
|
|
|
|
|
|
2008-08-08 18:05:53 +00:00
|
|
|
GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */
|
2008-02-20 11:24:23 +00:00
|
|
|
|
2008-03-12 17:07:43 +00:00
|
|
|
/* keyfile group name for non-plugin KB groups */
|
2010-08-10 12:43:30 +00:00
|
|
|
static const gchar keybindings_keyfile_group_name[] = "Bindings";
|
|
|
|
|
|
|
|
/* core keybindings */
|
|
|
|
static GeanyKeyBinding binding_ids[GEANY_KEYS_COUNT];
|
2008-02-20 11:24:23 +00:00
|
|
|
|
2008-03-14 13:11:46 +00:00
|
|
|
static GtkAccelGroup *kb_accel_group = NULL;
|
2007-09-27 11:13:59 +00:00
|
|
|
static const gboolean swap_alt_tab_order = FALSE;
|
2006-11-23 12:23:36 +00:00
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
static const gsize MAX_MRU_DOCS = 20;
|
2009-01-03 12:54:13 +00:00
|
|
|
static GQueue *mru_docs = NULL;
|
2009-05-13 15:37:28 +00:00
|
|
|
static guint mru_pos = 0;
|
2009-01-03 12:54:13 +00:00
|
|
|
|
2010-06-10 11:37:39 +00:00
|
|
|
static gboolean switch_in_progress = FALSE;
|
2009-01-02 13:37:40 +00:00
|
|
|
static GtkWidget *switch_dialog = NULL;
|
|
|
|
static GtkWidget *switch_dialog_label = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* central keypress event handler, almost all keypress events go to this function */
|
|
|
|
static gboolean on_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
|
|
|
|
static gboolean on_key_release_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
static gboolean check_current_word(GeanyDocument *doc);
|
|
|
|
static gboolean read_current_word(GeanyDocument *doc);
|
2009-09-16 12:13:50 +00:00
|
|
|
static gchar *get_current_word_or_sel(GeanyDocument *doc);
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_file_action(guint key_id);
|
|
|
|
static gboolean cb_func_project_action(guint key_id);
|
|
|
|
static gboolean cb_func_editor_action(guint key_id);
|
|
|
|
static gboolean cb_func_select_action(guint key_id);
|
|
|
|
static gboolean cb_func_format_action(guint key_id);
|
|
|
|
static gboolean cb_func_insert_action(guint key_id);
|
|
|
|
static gboolean cb_func_search_action(guint key_id);
|
|
|
|
static gboolean cb_func_goto_action(guint key_id);
|
|
|
|
static gboolean cb_func_switch_action(guint key_id);
|
|
|
|
static gboolean cb_func_clipboard_action(guint key_id);
|
|
|
|
static gboolean cb_func_build_action(guint key_id);
|
|
|
|
static gboolean cb_func_document_action(guint key_id);
|
|
|
|
static gboolean cb_func_view_action(guint key_id);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-01-02 14:01:24 +00:00
|
|
|
/* note: new keybindings should normally use per group callbacks */
|
2007-07-04 14:41:58 +00:00
|
|
|
static void cb_func_menu_help(guint key_id);
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_menu_preferences(guint key_id);
|
2007-05-03 16:13:30 +00:00
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_menu_fullscreen(guint key_id);
|
|
|
|
static void cb_func_menu_messagewindow(guint key_id);
|
2007-05-03 16:13:30 +00:00
|
|
|
|
|
|
|
static void cb_func_menu_opencolorchooser(guint key_id);
|
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_switch_tableft(guint key_id);
|
|
|
|
static void cb_func_switch_tabright(guint key_id);
|
2007-03-13 17:00:12 +00:00
|
|
|
static void cb_func_switch_tablastused(guint key_id);
|
2007-09-07 12:34:57 +00:00
|
|
|
static void cb_func_move_tab(guint key_id);
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
static void add_popup_menu_accels(void);
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2007-05-05 16:35:59 +00:00
|
|
|
|
2010-03-12 18:15:48 +00:00
|
|
|
/** Looks up a keybinding item.
|
2009-08-25 16:55:56 +00:00
|
|
|
* @param group Group.
|
|
|
|
* @param key_id Keybinding index for the group.
|
|
|
|
* @return The keybinding.
|
|
|
|
* @since 0.19. */
|
|
|
|
GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id)
|
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
if (group->plugin)
|
|
|
|
{
|
|
|
|
g_assert(key_id < group->plugin_key_count);
|
|
|
|
return &group->plugin_keys[key_id];
|
|
|
|
}
|
|
|
|
g_assert(key_id < GEANY_KEYS_COUNT);
|
|
|
|
return &binding_ids[key_id];
|
2009-08-25 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-18 13:57:07 +00:00
|
|
|
/* This is used to set default keybindings on startup.
|
|
|
|
* Menu accels are set in apply_kb_accel(). */
|
2010-03-12 18:15:48 +00:00
|
|
|
/** Fills a GeanyKeyBinding struct item.
|
2009-07-27 11:06:50 +00:00
|
|
|
* @param group Group.
|
|
|
|
* @param key_id Keybinding index for the group.
|
2009-10-12 11:50:45 +00:00
|
|
|
* @param callback Function to call when activated, or @c NULL to use the group callback.
|
|
|
|
* Usually it's better to use the group callback instead - see plugin_set_key_group().
|
2009-07-27 11:06:50 +00:00
|
|
|
* @param key (Lower case) default key, e.g. @c GDK_j, but usually 0 for unset.
|
|
|
|
* @param mod Default modifier, e.g. @c GDK_CONTROL_MASK, but usually 0 for unset.
|
2009-08-25 16:55:56 +00:00
|
|
|
* @param kf_name Key name for the configuration file, such as @c "menu_new".
|
2009-10-29 11:59:55 +00:00
|
|
|
* @param label Label used in the preferences dialog keybindings tab. May contain
|
|
|
|
* underscores - these won't be displayed.
|
2009-08-25 16:55:56 +00:00
|
|
|
* @param menu_item Optional widget to set an accelerator for, or @c NULL.
|
|
|
|
* @return The keybinding - normally this is ignored. */
|
|
|
|
GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
|
2008-08-08 18:05:53 +00:00
|
|
|
GeanyKeyCallback callback, guint key, GdkModifierType mod,
|
2010-04-22 12:25:20 +00:00
|
|
|
const gchar *kf_name, const gchar *label, GtkWidget *menu_item)
|
2008-02-29 19:30:28 +00:00
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
GeanyKeyBinding *kb;
|
|
|
|
|
|
|
|
g_assert(group->name);
|
|
|
|
kb = keybindings_get_item(group, key_id);
|
|
|
|
g_assert(!kb->name);
|
|
|
|
g_ptr_array_add(group->key_items, kb);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-08-25 16:55:56 +00:00
|
|
|
if (group->plugin)
|
|
|
|
{
|
|
|
|
/* some plugins e.g. GeanyLua need these fields duplicated */
|
|
|
|
setptr(kb->name, g_strdup(kf_name));
|
|
|
|
setptr(kb->label, g_strdup(label));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
/* we don't touch these strings unless group->plugin is set, const cast is safe */
|
2010-04-22 12:25:20 +00:00
|
|
|
kb->name = (gchar *)kf_name;
|
|
|
|
kb->label = (gchar *)label;
|
2009-08-25 16:55:56 +00:00
|
|
|
}
|
2008-02-29 19:30:28 +00:00
|
|
|
kb->key = key;
|
|
|
|
kb->mods = mod;
|
2008-03-10 13:23:57 +00:00
|
|
|
kb->callback = callback;
|
|
|
|
kb->menu_item = menu_item;
|
2010-08-10 12:43:30 +00:00
|
|
|
kb->id = key_id;
|
2009-08-25 16:55:56 +00:00
|
|
|
return kb;
|
2008-02-29 19:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-08 18:05:53 +00:00
|
|
|
static GeanyKeyGroup *add_kb_group(GeanyKeyGroup *group,
|
2010-08-10 12:43:30 +00:00
|
|
|
const gchar *name, const gchar *label, GeanyKeyGroupCallback callback, gboolean plugin)
|
2008-02-29 19:30:28 +00:00
|
|
|
{
|
|
|
|
g_ptr_array_add(keybinding_groups, group);
|
|
|
|
|
|
|
|
group->name = name;
|
|
|
|
group->label = label;
|
2009-10-12 11:50:45 +00:00
|
|
|
group->callback = callback;
|
2010-08-10 12:43:30 +00:00
|
|
|
group->plugin = plugin;
|
|
|
|
group->key_items = g_ptr_array_new();
|
2008-02-29 19:30:28 +00:00
|
|
|
return group;
|
|
|
|
}
|
2006-05-24 13:18:42 +00:00
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* Lookup a widget in the main window */
|
|
|
|
#define LW(widget_name) \
|
2008-12-18 21:21:53 +00:00
|
|
|
ui_lookup_widget(main_widgets.window, G_STRINGIFY(widget_name))
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
/* Expansion for group_id = FILE:
|
2010-08-10 12:43:30 +00:00
|
|
|
* add_kb_group(&groups[GEANY_KEY_GROUP_FILE],
|
|
|
|
* keybindings_keyfile_group_name, _("File menu"), callback); */
|
2009-10-12 11:50:45 +00:00
|
|
|
#define ADD_KB_GROUP(group_id, label, callback) \
|
2010-08-10 12:43:30 +00:00
|
|
|
add_kb_group(&groups[GEANY_KEY_GROUP_ ## group_id],\
|
|
|
|
keybindings_keyfile_group_name, label, callback, FALSE)
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* Init all fields of keys with default values.
|
|
|
|
* The menu_item field is always the main menu item, popup menu accelerators are
|
|
|
|
* set in add_popup_menu_accels(). */
|
2008-02-20 11:24:23 +00:00
|
|
|
static void init_default_kb(void)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2008-08-08 18:05:53 +00:00
|
|
|
static GeanyKeyGroup groups[GEANY_KEY_GROUP_COUNT];
|
|
|
|
GeanyKeyGroup *group;
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(FILE, _("File"), cb_func_file_action);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_NEW, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_n, GDK_CONTROL_MASK, "menu_new", _("New"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_OPEN, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_o, GDK_CONTROL_MASK, "menu_open", _("Open"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_OPENSELECTED, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_o, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "menu_open_selected",
|
|
|
|
_("Open selected file"), LW(menu_open_selected_file1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_SAVE, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_s, GDK_CONTROL_MASK, "menu_save", _("Save"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_SAVEAS, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_saveas", _("Save as"), LW(menu_save_as1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_SAVEALL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_S, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "menu_saveall", _("Save all"),
|
|
|
|
LW(menu_save_all1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_PRINT, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_p, GDK_CONTROL_MASK, "menu_print", _("Print"), LW(print1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_CLOSE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_w, GDK_CONTROL_MASK, "menu_close", _("Close"), LW(menu_close1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_CLOSEALL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_w, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "menu_closeall", _("Close all"),
|
|
|
|
LW(menu_close_all1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_RELOAD, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_r, GDK_CONTROL_MASK, "menu_reloadfile", _("Reload file"), LW(menu_reload1));
|
2010-01-01 23:20:21 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FILE_OPENLASTTAB, NULL,
|
|
|
|
0, 0, "file_openlasttab", _("Re-open last closed tab"), NULL);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(PROJECT, _("Project"), cb_func_project_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_PROJECT_PROPERTIES, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "project_properties", _("Project properties"), LW(project_properties1));
|
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(EDITOR, _("Editor"), cb_func_editor_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_UNDO, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_z, GDK_CONTROL_MASK, "menu_undo", _("Undo"), LW(menu_undo2));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_REDO, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_y, GDK_CONTROL_MASK, "menu_redo", _("Redo"), LW(menu_redo2));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_DUPLICATELINE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
GDK_d, GDK_CONTROL_MASK, "edit_duplicateline", _("_Duplicate Line or Selection"),
|
2009-10-27 17:47:23 +00:00
|
|
|
LW(duplicate_line_or_selection1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_DELETELINE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
GDK_k, GDK_CONTROL_MASK, "edit_deleteline", _("_Delete Current Line(s)"),
|
2009-10-27 17:47:23 +00:00
|
|
|
LW(delete_current_line_s_1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_DELETELINETOEND, NULL,
|
2009-06-29 19:46:49 +00:00
|
|
|
GDK_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "edit_deletelinetoend",
|
|
|
|
_("Delete to line end"), NULL);
|
2009-10-28 11:33:11 +00:00
|
|
|
/* transpose may fit better in format group */
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_TRANSPOSELINE, NULL,
|
2009-10-29 11:59:55 +00:00
|
|
|
GDK_t, GDK_CONTROL_MASK, "edit_transposeline", _("_Transpose Current Line"),
|
2009-10-28 11:33:11 +00:00
|
|
|
LW(transpose_current_line1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_SCROLLTOLINE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_l, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "edit_scrolltoline", _("Scroll to current line"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_SCROLLLINEUP, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_Up, GDK_MOD1_MASK, "edit_scrolllineup", _("Scroll up the view by one line"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_SCROLLLINEDOWN, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_Down, GDK_MOD1_MASK, "edit_scrolllinedown", _("Scroll down the view by one line"), NULL);
|
2009-01-26 18:21:53 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_COMPLETESNIPPET, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_Tab, 0, "edit_completesnippet", _("Complete snippet"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR, NULL,
|
2009-01-11 21:05:03 +00:00
|
|
|
0, 0, "move_snippetnextcursor", _("Move cursor in snippet"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "edit_suppresssnippetcompletion", _("Suppress snippet completion"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_CONTEXTACTION, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "popup_contextaction", _("Context Action"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_AUTOCOMPLETE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_space, GDK_CONTROL_MASK, "edit_autocomplete", _("Complete word"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_CALLTIP, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_space, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "edit_calltip", _("Show calltip"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_MACROLIST, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_Return, GDK_CONTROL_MASK, "edit_macrolist", _("Show macro list"), NULL);
|
2009-10-20 15:35:44 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, NULL,
|
|
|
|
GDK_Tab, 0, "edit_wordpartcompletion", _("Word part completion"), NULL);
|
2009-10-22 11:28:59 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_MOVELINEUP, NULL,
|
|
|
|
0, 0, "edit_movelineup", _("Move line(s) up"), NULL);
|
|
|
|
keybindings_set_item(group, GEANY_KEYS_EDITOR_MOVELINEDOWN, NULL,
|
|
|
|
0, 0, "edit_movelinedown", _("Move line(s) down"), NULL);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(CLIPBOARD, _("Clipboard"), cb_func_clipboard_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_CUT, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_x, GDK_CONTROL_MASK, "menu_cut", _("Cut"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_COPY, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_c, GDK_CONTROL_MASK, "menu_copy", _("Copy"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_PASTE, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_v, GDK_CONTROL_MASK, "menu_paste", _("Paste"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_COPYLINE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
GDK_c, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "edit_copyline", _("_Copy Current Line(s)"),
|
2010-05-03 14:38:25 +00:00
|
|
|
LW(copy_current_line_s_1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_CUTLINE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
GDK_x, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "edit_cutline", _("_Cut Current Line(s)"),
|
2010-05-03 14:38:25 +00:00
|
|
|
LW(cut_current_line_s_1));
|
2007-05-03 15:38:02 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(SELECT, _("Select"), cb_func_select_action);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SELECT_ALL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_a, GDK_CONTROL_MASK, "menu_selectall", _("Select All"), LW(menu_select_all1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SELECT_WORD, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_w, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectword", _("Select current word"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SELECT_LINE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
GDK_l, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectline", _("_Select Current Line(s)"),
|
2009-10-27 17:47:23 +00:00
|
|
|
LW(select_current_line_s_1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SELECT_PARAGRAPH, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
GDK_p, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectparagraph", _("_Select Current Paragraph"),
|
2009-10-27 17:47:23 +00:00
|
|
|
LW(select_current_paragraph1));
|
2009-10-20 16:01:07 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SELECT_WORDPARTLEFT, NULL,
|
|
|
|
0, 0, "edit_selectwordpartleft", _("Select to previous word part"), NULL);
|
|
|
|
keybindings_set_item(group, GEANY_KEYS_SELECT_WORDPARTRIGHT, NULL,
|
|
|
|
0, 0, "edit_selectwordpartright", _("Select to next word part"), NULL);
|
2007-05-03 15:38:02 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(FORMAT, _("Format"), cb_func_format_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_TOGGLECASE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_u, GDK_CONTROL_MASK | GDK_MOD1_MASK, "edit_togglecase",
|
|
|
|
_("Toggle Case of Selection"), LW(menu_toggle_case2));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_COMMENTLINETOGGLE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_e, GDK_CONTROL_MASK, "edit_commentlinetoggle", _("Toggle line commentation"),
|
|
|
|
LW(menu_toggle_line_commentation1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_COMMENTLINE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "edit_commentline", _("Comment line(s)"), LW(menu_comment_line1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_UNCOMMENTLINE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "edit_uncommentline", _("Uncomment line(s)"), LW(menu_uncomment_line1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_INCREASEINDENT, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_i, GDK_CONTROL_MASK, "edit_increaseindent", _("Increase indent"),
|
|
|
|
LW(menu_increase_indent1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_DECREASEINDENT, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_u, GDK_CONTROL_MASK, "edit_decreaseindent", _("Decrease indent"),
|
|
|
|
LW(menu_decrease_indent1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "edit_increaseindentbyspace", _("Increase indent by one space"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "edit_decreaseindentbyspace", _("Decrease indent by one space"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_AUTOINDENT, NULL,
|
2009-10-29 11:59:55 +00:00
|
|
|
0, 0, "edit_autoindent", _("_Smart Line Indent"), LW(smart_line_indent1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOCMD1, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_1, GDK_CONTROL_MASK, "edit_sendtocmd1", _("Send to Custom Command 1"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOCMD2, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_2, GDK_CONTROL_MASK, "edit_sendtocmd2", _("Send to Custom Command 2"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOCMD3, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_3, GDK_CONTROL_MASK, "edit_sendtocmd3", _("Send to Custom Command 3"), NULL);
|
2009-12-09 17:16:54 +00:00
|
|
|
/* may fit better in editor group */
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOVTE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
0, 0, "edit_sendtovte", _("_Send Selection to Terminal"), LW(send_selection_to_vte1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FORMAT_REFLOWPARAGRAPH, NULL,
|
2009-10-29 11:59:55 +00:00
|
|
|
GDK_j, GDK_CONTROL_MASK, "format_reflowparagraph", _("_Reflow Lines/Block"),
|
2009-10-28 11:33:11 +00:00
|
|
|
LW(reflow_lines_block1));
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(INSERT, _("Insert"), cb_func_insert_action);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_INSERT_DATE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_d, GDK_SHIFT_MASK | GDK_MOD1_MASK, "menu_insert_date", _("Insert date"),
|
|
|
|
LW(insert_date_custom1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_INSERT_ALTWHITESPACE, NULL,
|
2009-12-09 17:16:54 +00:00
|
|
|
0, 0, "edit_insertwhitespace", _("_Insert Alternative White Space"),
|
2009-10-27 17:47:23 +00:00
|
|
|
LW(insert_alternative_white_space1));
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(SETTINGS, _("Settings"), NULL);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SETTINGS_PREFERENCES, cb_func_menu_preferences,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_p, GDK_CONTROL_MASK | GDK_MOD1_MASK, "menu_preferences", _("Preferences"),
|
|
|
|
LW(preferences1));
|
2009-10-28 18:06:16 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SETTINGS_PLUGINPREFERENCES, cb_func_menu_preferences,
|
|
|
|
0, 0, "menu_pluginpreferences", _("P_lugin Preferences"), LW(plugin_preferences1));
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(SEARCH, _("Search"), cb_func_search_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FIND, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_f, GDK_CONTROL_MASK, "menu_find", _("Find"), LW(find1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDNEXT, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_g, GDK_CONTROL_MASK, "menu_findnext", _("Find Next"), LW(find_next1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDPREVIOUS, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_g, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "menu_findprevious", _("Find Previous"),
|
|
|
|
LW(find_previous1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDNEXTSEL, NULL,
|
2008-04-03 15:12:54 +00:00
|
|
|
0, 0, "menu_findnextsel", _("Find Next Selection"), LW(find_nextsel1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDPREVSEL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_findprevsel", _("Find Previous Selection"), LW(find_prevsel1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_REPLACE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_h, GDK_CONTROL_MASK, "menu_replace", _("Replace"), LW(replace1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDINFILES, NULL, GDK_f,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_CONTROL_MASK | GDK_SHIFT_MASK, "menu_findinfiles", _("Find in Files"),
|
|
|
|
LW(find_in_files1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_NEXTMESSAGE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_nextmessage", _("Next Message"), LW(next_message1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_PREVIOUSMESSAGE, NULL,
|
2008-06-26 16:39:41 +00:00
|
|
|
0, 0, "menu_previousmessage", _("Previous Message"), LW(previous_message1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDUSAGE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "popup_findusage", _("Find Usage"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, NULL,
|
2008-07-17 16:42:03 +00:00
|
|
|
0, 0, "popup_finddocumentusage", _("Find Document Usage"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_SEARCH_MARKALL, NULL,
|
2009-07-10 15:17:27 +00:00
|
|
|
GDK_m, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "find_markall", _("Mark All"), NULL);
|
2007-07-04 14:41:58 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(GOTO, _("Go to"), cb_func_goto_action);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_BACK, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "nav_back", _("Navigate back a location"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_FORWARD, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "nav_forward", _("Navigate forward a location"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_LINE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_l, GDK_CONTROL_MASK, "menu_gotoline", _("Go to Line"), LW(go_to_line1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_MATCHINGBRACE, NULL,
|
2007-07-09 13:53:27 +00:00
|
|
|
GDK_b, GDK_CONTROL_MASK, "edit_gotomatchingbrace",
|
2008-03-12 13:37:39 +00:00
|
|
|
_("Go to matching brace"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_TOGGLEMARKER, NULL,
|
2007-03-15 13:14:04 +00:00
|
|
|
GDK_m, GDK_CONTROL_MASK, "edit_togglemarker",
|
2008-03-12 13:37:39 +00:00
|
|
|
_("Toggle marker"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_NEXTMARKER, NULL,
|
2007-03-15 12:52:16 +00:00
|
|
|
GDK_period, GDK_CONTROL_MASK, "edit_gotonextmarker",
|
2009-12-09 17:16:54 +00:00
|
|
|
_("_Go to Next Marker"), LW(go_to_next_marker1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_PREVIOUSMARKER, NULL,
|
2007-03-15 12:52:16 +00:00
|
|
|
GDK_comma, GDK_CONTROL_MASK, "edit_gotopreviousmarker",
|
2009-12-09 17:16:54 +00:00
|
|
|
_("_Go to Previous Marker"), LW(go_to_previous_marker1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_TAGDEFINITION, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "popup_gototagdefinition", _("Go to Tag Definition"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_TAGDECLARATION, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "popup_gototagdeclaration", _("Go to Tag Declaration"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_LINESTART, NULL,
|
2008-06-27 17:54:36 +00:00
|
|
|
GDK_Home, 0, "edit_gotolinestart", _("Go to Start of Line"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_LINEEND, NULL,
|
2008-06-27 17:54:36 +00:00
|
|
|
GDK_End, 0, "edit_gotolineend", _("Go to End of Line"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_LINEENDVISUAL, NULL,
|
2009-06-29 19:46:49 +00:00
|
|
|
GDK_End, GDK_MOD1_MASK, "edit_gotolineendvisual", _("Go to End of Display Line"), NULL);
|
2009-10-20 15:45:07 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_PREVWORDPART, NULL,
|
2008-09-26 18:29:42 +00:00
|
|
|
GDK_slash, GDK_CONTROL_MASK, "edit_prevwordstart", _("Go to Previous Word Part"), NULL);
|
2009-10-20 15:45:07 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_GOTO_NEXTWORDPART, NULL,
|
2008-09-26 18:29:42 +00:00
|
|
|
GDK_backslash, GDK_CONTROL_MASK, "edit_nextwordstart", _("Go to Next Word Part"), NULL);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(VIEW, _("View"), cb_func_view_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_TOGGLEALL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_toggleall", _("Toggle All Additional Widgets"),
|
|
|
|
LW(menu_toggle_all_additional_widgets1));
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_FULLSCREEN, cb_func_menu_fullscreen,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F11, 0, "menu_fullscreen", _("Fullscreen"), LW(menu_fullscreen1));
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_MESSAGEWINDOW, cb_func_menu_messagewindow,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_messagewindow", _("Toggle Messages Window"),
|
|
|
|
LW(menu_show_messages_window1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_SIDEBAR, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "toggle_sidebar", _("Toggle Sidebar"), LW(menu_show_sidebar1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_ZOOMIN, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_plus, GDK_CONTROL_MASK, "menu_zoomin", _("Zoom In"), LW(menu_zoom_in1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_ZOOMOUT, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_minus, GDK_CONTROL_MASK, "menu_zoomout", _("Zoom Out"), LW(menu_zoom_out1));
|
2010-03-25 22:18:00 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_VIEW_ZOOMRESET, NULL,
|
|
|
|
GDK_0, GDK_CONTROL_MASK, "normal_size", _("Zoom Reset"), LW(normal_size1));
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(FOCUS, _("Focus"), cb_func_switch_action);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_EDITOR, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_F2, 0, "switch_editor", _("Switch to Editor"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_SEARCHBAR, NULL,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_F7, 0, "switch_search_bar", _("Switch to Search Bar"), NULL);
|
2010-08-10 16:34:51 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_MESSAGE_WINDOW, NULL,
|
|
|
|
0, 0, "switch_message_window", _("Switch to Message Window"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_COMPILER, NULL,
|
2008-07-03 17:37:00 +00:00
|
|
|
0, 0, "switch_compiler", _("Switch to Compiler"), NULL);
|
2009-10-20 16:59:00 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_MESSAGES, NULL,
|
|
|
|
0, 0, "switch_messages", _("Switch to Messages"), NULL);
|
2010-08-10 16:34:51 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_SCRIBBLE, NULL,
|
|
|
|
GDK_F6, 0, "switch_scribble", _("Switch to Scribble"), NULL);
|
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_VTE, NULL,
|
|
|
|
GDK_F4, 0, "switch_vte", _("Switch to VTE"), NULL);
|
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_SIDEBAR, NULL,
|
|
|
|
0, 0, "switch_sidebar", _("Switch to Sidebar"), NULL);
|
2010-02-21 18:06:42 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST, NULL,
|
|
|
|
0, 0, "switch_sidebar_symbol_list", _("Switch to Sidebar Symbol List"), NULL);
|
2010-08-10 16:34:51 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST, NULL,
|
|
|
|
0, 0, "switch_sidebar_doc_list", _("Switch to Sidebar Document List"), NULL);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(NOTEBOOK, _("Notebook tab"), NULL);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT, cb_func_switch_tableft,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_Page_Up, GDK_CONTROL_MASK, "switch_tableft", _("Switch to left document"), NULL);
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT, cb_func_switch_tabright,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_Page_Down, GDK_CONTROL_MASK, "switch_tabright", _("Switch to right document"), NULL);
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED, cb_func_switch_tablastused,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_Tab, GDK_CONTROL_MASK, "switch_tablastused", _("Switch to last used document"), NULL);
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_MOVETABLEFT, cb_func_move_tab,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_Page_Up, GDK_MOD1_MASK, "move_tableft", _("Move document left"), NULL);
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_MOVETABRIGHT, cb_func_move_tab,
|
2008-03-10 13:23:57 +00:00
|
|
|
GDK_Page_Down, GDK_MOD1_MASK, "move_tabright", _("Move document right"), NULL);
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_MOVETABFIRST, cb_func_move_tab,
|
2008-03-10 13:23:57 +00:00
|
|
|
0, 0, "move_tabfirst", _("Move document first"), NULL);
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_NOTEBOOK_MOVETABLAST, cb_func_move_tab,
|
2008-03-10 13:23:57 +00:00
|
|
|
0, 0, "move_tablast", _("Move document last"), NULL);
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(DOCUMENT, _("Document"), cb_func_document_action);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_LINEWRAP, NULL,
|
2008-06-19 15:58:10 +00:00
|
|
|
0, 0, "menu_linewrap", _("Toggle Line wrapping"), LW(menu_line_wrapping1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_LINEBREAK, NULL,
|
2008-06-19 15:58:10 +00:00
|
|
|
0, 0, "menu_linebreak", _("Toggle Line breaking"), LW(line_breaking1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_REPLACETABS, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_replacetabs", _("Replace tabs by space"), LW(menu_replace_tabs));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_REPLACESPACES, NULL,
|
2008-06-19 15:58:10 +00:00
|
|
|
0, 0, "menu_replacespaces", _("Replace spaces by tabs"), LW(menu_replace_spaces));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_TOGGLEFOLD, NULL,
|
2008-06-19 15:58:10 +00:00
|
|
|
0, 0, "menu_togglefold", _("Toggle current fold"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_FOLDALL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_foldall", _("Fold all"), LW(menu_fold_all1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_UNFOLDALL, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_unfoldall", _("Unfold all"), LW(menu_unfold_all1));
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_RELOADTAGLIST, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_r, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "reloadtaglist", _("Reload symbol list"), NULL);
|
2010-04-17 14:55:14 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_REMOVE_MARKERS, NULL,
|
|
|
|
0, 0, "remove_markers", _("Remove Markers"), LW(remove_markers1));
|
|
|
|
keybindings_set_item(group, GEANY_KEYS_DOCUMENT_REMOVE_ERROR_INDICATORS, NULL,
|
|
|
|
0, 0, "remove_error_indicators", _("Remove Error Indicators"), LW(menu_remove_indicators1));
|
2007-03-25 20:51:45 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(BUILD, _("Build"), cb_func_build_action);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_COMPILE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F8, 0, "build_compile", _("Compile"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_LINK, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F9, 0, "build_link", _("Build"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_MAKE, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F9, GDK_SHIFT_MASK, "build_make", _("Make all"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_MAKEOWNTARGET, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F9, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "build_makeowntarget",
|
|
|
|
_("Make custom target"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_MAKEOBJECT, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "build_makeobject", _("Make object"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_NEXTERROR, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "build_nexterror", _("Next error"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_PREVIOUSERROR, NULL,
|
2008-06-26 16:39:41 +00:00
|
|
|
0, 0, "build_previouserror", _("Previous error"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_RUN, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F5, 0, "build_run", _("Run"), NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_BUILD_OPTIONS, NULL,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "build_options", _("Build options"), NULL);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(TOOLS, _("Tools"), NULL);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_TOOLS_OPENCOLORCHOOSER, cb_func_menu_opencolorchooser,
|
2008-03-12 13:37:39 +00:00
|
|
|
0, 0, "menu_opencolorchooser", _("Show Color Chooser"), LW(menu_choose_color1));
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
group = ADD_KB_GROUP(HELP, _("Help"), NULL);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2008-08-08 15:15:50 +00:00
|
|
|
keybindings_set_item(group, GEANY_KEYS_HELP_HELP, cb_func_menu_help,
|
2008-03-12 13:37:39 +00:00
|
|
|
GDK_F1, 0, "menu_help", _("Help"), LW(help1));
|
2007-09-27 11:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-03 12:54:13 +00:00
|
|
|
/* before the tab changes, add the current document to the MRU list */
|
2009-01-11 18:29:39 +00:00
|
|
|
static void on_notebook_switch_page(void)
|
2009-01-03 12:54:13 +00:00
|
|
|
{
|
|
|
|
GeanyDocument *old = document_get_current();
|
|
|
|
|
2009-05-22 14:50:34 +00:00
|
|
|
/* when closing current doc, old is NULL.
|
|
|
|
* Don't add to the mru list when switch dialog is visible. */
|
2010-06-10 11:37:39 +00:00
|
|
|
if (old && !switch_in_progress)
|
2009-01-03 12:54:13 +00:00
|
|
|
{
|
2009-05-22 14:50:34 +00:00
|
|
|
g_queue_remove(mru_docs, old);
|
2009-01-03 12:54:13 +00:00
|
|
|
g_queue_push_head(mru_docs, old);
|
|
|
|
|
|
|
|
if (g_queue_get_length(mru_docs) > MAX_MRU_DOCS)
|
|
|
|
g_queue_pop_tail(mru_docs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* really this should be just after a document was closed, not idle */
|
|
|
|
static gboolean on_idle_close(gpointer data)
|
|
|
|
{
|
|
|
|
GeanyDocument *current;
|
|
|
|
|
|
|
|
current = document_get_current();
|
2009-05-22 14:50:34 +00:00
|
|
|
if (current && g_queue_peek_head(mru_docs) == current)
|
2009-01-03 12:54:13 +00:00
|
|
|
g_queue_pop_head(mru_docs);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void on_document_close(GObject *obj, GeanyDocument *doc)
|
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! main_status.quitting)
|
2009-03-26 20:31:55 +00:00
|
|
|
{
|
2009-05-22 14:50:34 +00:00
|
|
|
g_queue_remove(mru_docs, doc);
|
2009-03-26 20:31:55 +00:00
|
|
|
g_idle_add(on_idle_close, NULL);
|
|
|
|
}
|
2009-01-03 12:54:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-14 13:11:46 +00:00
|
|
|
void keybindings_init(void)
|
|
|
|
{
|
2009-01-03 12:54:13 +00:00
|
|
|
mru_docs = g_queue_new();
|
|
|
|
g_signal_connect(main_widgets.notebook, "switch-page",
|
|
|
|
G_CALLBACK(on_notebook_switch_page), NULL);
|
|
|
|
g_signal_connect(geany_object, "document-close",
|
|
|
|
G_CALLBACK(on_document_close), NULL);
|
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
memset(binding_ids, 0, sizeof binding_ids);
|
2008-03-14 13:11:46 +00:00
|
|
|
keybinding_groups = g_ptr_array_sized_new(GEANY_KEY_GROUP_COUNT);
|
2008-04-03 15:12:54 +00:00
|
|
|
kb_accel_group = gtk_accel_group_new();
|
|
|
|
|
2008-03-14 13:11:46 +00:00
|
|
|
init_default_kb();
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(main_widgets.window), kb_accel_group);
|
2009-01-02 13:37:40 +00:00
|
|
|
|
|
|
|
g_signal_connect(main_widgets.window, "key-press-event", G_CALLBACK(on_key_press_event), NULL);
|
|
|
|
/* in case the switch dialog misses an event while drawing the dialog */
|
|
|
|
g_signal_connect(main_widgets.window, "key-release-event", G_CALLBACK(on_key_release_event), NULL);
|
2008-03-14 13:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-08 18:05:53 +00:00
|
|
|
typedef void (*KBItemCallback) (GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_data);
|
2008-02-29 19:30:28 +00:00
|
|
|
|
|
|
|
static void keybindings_foreach(KBItemCallback cb, gpointer user_data)
|
2007-09-27 11:13:59 +00:00
|
|
|
{
|
2008-02-29 19:30:28 +00:00
|
|
|
gsize g, i;
|
2009-04-05 21:07:40 +00:00
|
|
|
GeanyKeyGroup *group;
|
|
|
|
GeanyKeyBinding *kb;
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(group, g, keybinding_groups)
|
2008-02-29 19:30:28 +00:00
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(kb, i, group->key_items)
|
2008-02-29 19:30:28 +00:00
|
|
|
cb(group, kb, user_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-08 18:05:53 +00:00
|
|
|
static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_data)
|
2008-02-29 19:30:28 +00:00
|
|
|
{
|
|
|
|
GKeyFile *config = user_data;
|
2007-09-27 11:13:59 +00:00
|
|
|
gchar *val;
|
|
|
|
guint key;
|
|
|
|
GdkModifierType mods;
|
2008-02-29 19:30:28 +00:00
|
|
|
|
|
|
|
val = g_key_file_get_string(config, group->name, kb->name, NULL);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (val != NULL)
|
2008-02-29 19:30:28 +00:00
|
|
|
{
|
|
|
|
gtk_accelerator_parse(val, &key, &mods);
|
|
|
|
kb->key = key;
|
|
|
|
kb->mods = mods;
|
2009-04-05 21:07:40 +00:00
|
|
|
g_free(val);
|
2008-02-29 19:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void load_user_kb(void)
|
|
|
|
{
|
|
|
|
gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL);
|
2007-09-27 11:13:59 +00:00
|
|
|
GKeyFile *config = g_key_file_new();
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* now load user defined keys */
|
2006-05-19 17:18:06 +00:00
|
|
|
if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
|
|
|
|
{
|
2008-03-14 13:11:46 +00:00
|
|
|
keybindings_foreach(load_kb, config);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
2007-09-27 11:13:59 +00:00
|
|
|
g_free(configfile);
|
|
|
|
g_key_file_free(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-18 13:57:07 +00:00
|
|
|
static void apply_kb_accel(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_data)
|
|
|
|
{
|
|
|
|
if (kb->key != 0 && kb->menu_item)
|
|
|
|
{
|
|
|
|
gtk_widget_add_accelerator(kb->menu_item, "activate", kb_accel_group,
|
|
|
|
kb->key, kb->mods, GTK_ACCEL_VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-10 13:54:47 +00:00
|
|
|
void keybindings_load_keyfile(void)
|
|
|
|
{
|
2007-09-27 11:13:59 +00:00
|
|
|
load_user_kb();
|
2008-03-12 13:37:39 +00:00
|
|
|
add_popup_menu_accels();
|
2008-07-20 17:12:34 +00:00
|
|
|
|
2009-08-18 13:57:07 +00:00
|
|
|
/* set menu accels now, after user keybindings have been read */
|
2008-07-20 17:12:34 +00:00
|
|
|
keybindings_foreach(apply_kb_accel, NULL);
|
2006-05-24 16:56:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-18 14:23:49 +00:00
|
|
|
static void add_menu_accel(GeanyKeyGroup *group, guint kb_id, GtkWidget *menuitem)
|
2008-03-04 16:11:59 +00:00
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
GeanyKeyBinding *kb = keybindings_get_item(group, kb_id);
|
2008-03-04 16:11:59 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (kb->key != 0)
|
2009-08-18 14:23:49 +00:00
|
|
|
gtk_widget_add_accelerator(menuitem, "activate", kb_accel_group,
|
2008-03-04 16:11:59 +00:00
|
|
|
kb->key, kb->mods, GTK_ACCEL_VISIBLE);
|
|
|
|
}
|
2006-05-24 16:56:14 +00:00
|
|
|
|
2006-06-17 21:08:47 +00:00
|
|
|
|
2008-03-04 16:11:59 +00:00
|
|
|
#define GEANY_ADD_POPUP_ACCEL(kb_id, wid) \
|
2009-08-18 14:23:49 +00:00
|
|
|
add_menu_accel(group, kb_id, ui_lookup_widget(main_widgets.editor_menu, G_STRINGIFY(wid)))
|
2008-03-04 16:11:59 +00:00
|
|
|
|
|
|
|
/* set the menu item accelerator shortcuts (just for visibility, they are handled anyway) */
|
2008-03-12 13:37:39 +00:00
|
|
|
static void add_popup_menu_accels(void)
|
2006-05-24 16:56:14 +00:00
|
|
|
{
|
2008-08-08 18:05:53 +00:00
|
|
|
GeanyKeyGroup *group;
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_EDITOR);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_EDITOR_UNDO, undo1);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_EDITOR_REDO, redo1);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_EDITOR_CONTEXTACTION, context_action1);
|
|
|
|
|
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_SELECT);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SELECT_ALL, menu_select_all2);
|
|
|
|
|
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_INSERT);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_INSERT_DATE, insert_date_custom2);
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_FILE);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_FILE_OPENSELECTED, menu_open_selected_file2);
|
|
|
|
|
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_SEARCH);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SEARCH_FINDUSAGE, find_usage1);
|
2008-07-17 16:42:03 +00:00
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, find_document_usage1);
|
2008-03-12 13:37:39 +00:00
|
|
|
|
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_GOTO);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_GOTO_LINE, go_to_line);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_GOTO_TAGDEFINITION, goto_tag_definition1);
|
|
|
|
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_GOTO_TAGDECLARATION, goto_tag_declaration1);
|
|
|
|
|
2009-10-27 18:10:39 +00:00
|
|
|
/* Format and Commands share the menu bar submenus */
|
|
|
|
/* Build menu items are set if the build menus are created */
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-08 18:05:53 +00:00
|
|
|
static void set_keyfile_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_data)
|
2008-02-29 19:30:28 +00:00
|
|
|
{
|
|
|
|
GKeyFile *config = user_data;
|
|
|
|
gchar *val;
|
|
|
|
|
|
|
|
val = gtk_accelerator_name(kb->key, kb->mods);
|
|
|
|
g_key_file_set_string(config, group->name, kb->name, val);
|
|
|
|
g_free(val);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* just write the content of the keys array to the config file */
|
|
|
|
void keybindings_write_to_file(void)
|
|
|
|
{
|
|
|
|
gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL);
|
2008-02-29 19:30:28 +00:00
|
|
|
gchar *data;
|
2006-05-19 17:18:06 +00:00
|
|
|
GKeyFile *config = g_key_file_new();
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* add comment if the file is newly created */
|
2006-05-19 17:18:06 +00:00
|
|
|
if (! g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
|
|
|
|
{
|
2009-01-26 18:21:53 +00:00
|
|
|
g_key_file_set_comment(config, NULL, NULL,
|
|
|
|
"Keybindings for Geany\nThe format looks like \"<Control>a\" or \"<Shift><Alt>F1\".\n"
|
|
|
|
"But you can also change the keys in Geany's preferences dialog.", NULL);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
keybindings_foreach(set_keyfile_kb, config);
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* write the file */
|
2006-05-19 17:18:06 +00:00
|
|
|
data = g_key_file_to_data(config, NULL, NULL);
|
|
|
|
utils_write_file(configfile, data);
|
|
|
|
|
|
|
|
g_free(data);
|
|
|
|
g_free(configfile);
|
|
|
|
g_key_file_free(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void keybindings_free(void)
|
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
GeanyKeyGroup *group;
|
|
|
|
gsize g;
|
|
|
|
|
|
|
|
foreach_ptr_array(group, g, keybinding_groups)
|
|
|
|
keybindings_free_group(group);
|
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
g_ptr_array_free(keybinding_groups, TRUE);
|
2009-01-03 12:54:13 +00:00
|
|
|
g_queue_free(mru_docs);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-29 11:59:55 +00:00
|
|
|
gchar *keybindings_get_label(GeanyKeyBinding *kb)
|
|
|
|
{
|
|
|
|
return utils_str_remove_chars(g_strdup(kb->label), "_");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
static void fill_shortcut_labels_treeview(GtkWidget *tree)
|
2007-03-23 16:34:54 +00:00
|
|
|
{
|
2008-03-03 17:54:59 +00:00
|
|
|
gsize g, i;
|
2008-10-17 16:51:22 +00:00
|
|
|
GeanyKeyBinding *kb;
|
|
|
|
GeanyKeyGroup *group;
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkTreeIter iter;
|
2007-03-29 14:39:04 +00:00
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, PANGO_TYPE_WEIGHT);
|
2007-03-29 14:39:04 +00:00
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(group, g, keybinding_groups)
|
2007-03-29 14:39:04 +00:00
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
if (g > 0)
|
2007-03-29 14:39:04 +00:00
|
|
|
{
|
2008-10-17 16:51:22 +00:00
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter, -1);
|
2007-03-29 14:39:04 +00:00
|
|
|
}
|
2008-10-17 16:51:22 +00:00
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter, 0, group->label, 2, PANGO_WEIGHT_BOLD, -1);
|
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(kb, i, group->key_items)
|
2008-03-03 17:54:59 +00:00
|
|
|
{
|
2009-10-29 11:59:55 +00:00
|
|
|
gchar *shortcut, *label;
|
|
|
|
|
|
|
|
label = keybindings_get_label(kb);
|
2008-03-03 17:54:59 +00:00
|
|
|
shortcut = gtk_accelerator_get_label(kb->key, kb->mods);
|
2008-10-17 16:51:22 +00:00
|
|
|
|
|
|
|
gtk_list_store_append(store, &iter);
|
2009-10-29 11:59:55 +00:00
|
|
|
gtk_list_store_set(store, &iter, 0, label, 1, shortcut, 2, PANGO_WEIGHT_NORMAL, -1);
|
2008-10-17 16:51:22 +00:00
|
|
|
|
2008-03-03 17:54:59 +00:00
|
|
|
g_free(shortcut);
|
2009-10-29 11:59:55 +00:00
|
|
|
g_free(label);
|
2008-03-03 17:54:59 +00:00
|
|
|
}
|
2007-03-29 14:39:04 +00:00
|
|
|
}
|
2008-10-17 16:51:22 +00:00
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store));
|
|
|
|
g_object_unref(store);
|
2007-03-29 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-24 12:25:23 +00:00
|
|
|
static GtkWidget *create_dialog(void)
|
2007-03-29 14:39:04 +00:00
|
|
|
{
|
2008-10-17 16:51:22 +00:00
|
|
|
GtkWidget *dialog, *tree, *label, *swin, *vbox;
|
|
|
|
GtkCellRenderer *text_renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
dialog = gtk_dialog_new_with_buttons(_("Keyboard Shortcuts"), GTK_WINDOW(main_widgets.window),
|
2007-03-23 16:34:54 +00:00
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_STOCK_EDIT, GTK_RESPONSE_APPLY,
|
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL);
|
|
|
|
vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog));
|
|
|
|
gtk_box_set_spacing(GTK_BOX(vbox), 6);
|
2007-05-15 15:16:16 +00:00
|
|
|
gtk_widget_set_name(dialog, "GeanyDialog");
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2010-03-20 16:20:55 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(dialog), -1, GEANY_DEFAULT_DIALOG_HEIGHT);
|
2008-04-03 15:38:16 +00:00
|
|
|
|
2007-03-23 16:34:54 +00:00
|
|
|
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
|
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
label = gtk_label_new(_("The following keyboard shortcuts are configurable:"));
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
tree = gtk_tree_view_new();
|
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE);
|
|
|
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
text_renderer = gtk_cell_renderer_text_new();
|
|
|
|
/* we can't use "weight-set", see http://bugzilla.gnome.org/show_bug.cgi?id=355214 */
|
|
|
|
column = gtk_tree_view_column_new_with_attributes(
|
|
|
|
NULL, text_renderer, "text", 0, "weight", 2, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
text_renderer = gtk_cell_renderer_text_new();
|
2010-06-10 11:37:39 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes(NULL, text_renderer, "text", 1, NULL);
|
2008-10-17 16:51:22 +00:00
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
|
2007-03-29 14:39:04 +00:00
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
fill_shortcut_labels_treeview(tree);
|
2007-03-23 16:34:54 +00:00
|
|
|
|
|
|
|
swin = gtk_scrolled_window_new(NULL, NULL);
|
2008-04-03 15:38:16 +00:00
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_NEVER,
|
2007-03-23 16:34:54 +00:00
|
|
|
GTK_POLICY_AUTOMATIC);
|
2008-10-17 16:51:22 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_container_add(GTK_CONTAINER(swin), tree);
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-10-17 16:51:22 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 6);
|
2007-03-23 16:34:54 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
|
2009-04-05 21:07:40 +00:00
|
|
|
|
2008-06-24 12:25:23 +00:00
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-06-24 12:25:23 +00:00
|
|
|
/* non-modal keyboard shortcuts dialog, so user can edit whilst seeing the shortcuts */
|
|
|
|
static GtkWidget *key_dialog = NULL;
|
|
|
|
|
|
|
|
static void on_dialog_response(GtkWidget *dialog, gint response, gpointer user_data)
|
|
|
|
{
|
2007-03-23 16:34:54 +00:00
|
|
|
if (response == GTK_RESPONSE_APPLY)
|
|
|
|
{
|
|
|
|
GtkWidget *wid;
|
|
|
|
|
2007-03-23 16:47:27 +00:00
|
|
|
prefs_show_dialog();
|
2008-02-27 13:17:29 +00:00
|
|
|
/* select the KB page */
|
2008-12-18 21:21:53 +00:00
|
|
|
wid = ui_lookup_widget(ui_widgets.prefs_dialog, "frame22");
|
2007-03-23 16:34:54 +00:00
|
|
|
if (wid != NULL)
|
|
|
|
{
|
2008-12-18 21:21:53 +00:00
|
|
|
GtkNotebook *nb = GTK_NOTEBOOK(ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2"));
|
2007-03-23 16:34:54 +00:00
|
|
|
|
|
|
|
if (nb != NULL)
|
|
|
|
gtk_notebook_set_current_page(nb, gtk_notebook_page_num(nb, wid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_widget_destroy(dialog);
|
2008-06-24 12:25:23 +00:00
|
|
|
key_dialog = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void keybindings_show_shortcuts(void)
|
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
if (key_dialog)
|
2008-06-24 12:25:23 +00:00
|
|
|
gtk_widget_destroy(key_dialog); /* in case the key_dialog is still visible */
|
|
|
|
|
|
|
|
key_dialog = create_dialog();
|
|
|
|
g_signal_connect(key_dialog, "response", G_CALLBACK(on_dialog_response), NULL);
|
|
|
|
gtk_widget_show_all(key_dialog);
|
2007-03-23 16:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-12 15:49:54 +00:00
|
|
|
static gboolean check_fixed_kb(guint keyval, guint state)
|
2006-11-23 12:23:36 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* check alt-0 to alt-9 for setting current notebook page */
|
2008-02-12 15:49:54 +00:00
|
|
|
if (state & GDK_MOD1_MASK && keyval >= GDK_0 && keyval <= GDK_9)
|
2006-11-23 12:23:36 +00:00
|
|
|
{
|
2008-02-12 15:49:54 +00:00
|
|
|
gint page = keyval - GDK_0 - 1;
|
2008-05-22 14:41:28 +00:00
|
|
|
gint npages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
|
2006-11-23 12:23:36 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* alt-0 is for the rightmost tab */
|
2008-02-12 15:49:54 +00:00
|
|
|
if (keyval == GDK_0)
|
2006-11-23 12:23:36 +00:00
|
|
|
page = npages - 1;
|
2008-02-27 13:17:29 +00:00
|
|
|
/* invert the order if tabs are added on the other side */
|
2008-05-16 12:08:39 +00:00
|
|
|
if (swap_alt_tab_order && ! file_prefs.tab_order_ltr)
|
2006-11-23 12:23:36 +00:00
|
|
|
page = (npages - 1) - page;
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), page);
|
2006-11-23 12:23:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-02-12 15:49:54 +00:00
|
|
|
if (keyval == GDK_Page_Up || keyval == GDK_Page_Down)
|
2007-09-07 12:34:57 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* switch to first or last document */
|
2008-02-12 15:49:54 +00:00
|
|
|
if (state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
|
2007-09-07 12:34:57 +00:00
|
|
|
{
|
2008-02-12 15:49:54 +00:00
|
|
|
if (keyval == GDK_Page_Up)
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), 0);
|
2008-02-12 15:49:54 +00:00
|
|
|
if (keyval == GDK_Page_Down)
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
|
|
|
gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) - 1);
|
2007-09-07 12:34:57 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2006-11-23 12:23:36 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean check_snippet_completion(GeanyDocument *doc)
|
2007-03-27 15:48:16 +00:00
|
|
|
{
|
2009-10-12 11:50:45 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2007-03-27 15:48:16 +00:00
|
|
|
|
2009-07-23 17:11:31 +00:00
|
|
|
g_return_val_if_fail(doc, FALSE);
|
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
/* keybinding only valid when scintilla widget has focus */
|
|
|
|
if (focusw == GTK_WIDGET(doc->editor->sci))
|
2007-03-27 15:48:16 +00:00
|
|
|
{
|
2009-10-12 11:50:45 +00:00
|
|
|
ScintillaObject *sci = doc->editor->sci;
|
|
|
|
gint pos = sci_get_current_position(sci);
|
2007-03-27 15:48:16 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
if (editor_prefs.complete_snippets)
|
|
|
|
return editor_complete_snippet(doc->editor, pos);
|
2007-03-27 15:48:16 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-05 19:10:57 +00:00
|
|
|
/* Transforms a GdkEventKey event into a GdkEventButton event */
|
|
|
|
static void trigger_button_event(GtkWidget *widget, guint32 event_time)
|
|
|
|
{
|
|
|
|
GdkEventButton *event;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
event = g_new0(GdkEventButton, 1);
|
|
|
|
|
|
|
|
if (GTK_IS_TEXT_VIEW(widget))
|
|
|
|
event->window = gtk_text_view_get_window(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT);
|
|
|
|
else
|
|
|
|
event->window = widget->window;
|
|
|
|
event->time = event_time;
|
|
|
|
event->type = GDK_BUTTON_PRESS;
|
|
|
|
event->button = 3;
|
|
|
|
|
|
|
|
g_signal_emit_by_name(widget, "button-press-event", event, &ret);
|
|
|
|
g_signal_emit_by_name(widget, "button-release-event", event, &ret);
|
|
|
|
|
|
|
|
g_free(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Special case for the Menu key and Shift-F10 to show the right-click popup menu for various
|
|
|
|
* widgets. Without this special handling, the notebook tab list of the documents' notebook
|
|
|
|
* would be shown. As a very special case, we differentiate between the Menu key and Shift-F10
|
|
|
|
* if pressed in the editor widget: the Menu key opens the popup menu, Shift-F10 opens the
|
|
|
|
* notebook tab list. */
|
2009-04-05 21:07:40 +00:00
|
|
|
static gboolean check_menu_key(GeanyDocument *doc, guint keyval, guint state, guint32 event_time)
|
2009-02-05 19:10:57 +00:00
|
|
|
{
|
|
|
|
if ((keyval == GDK_Menu && state == 0) || (keyval == GDK_F10 && state == GDK_SHIFT_MASK))
|
|
|
|
{
|
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc != NULL)
|
2009-02-05 19:10:57 +00:00
|
|
|
{
|
|
|
|
if (focusw == doc->priv->tag_tree)
|
|
|
|
{
|
|
|
|
trigger_button_event(focusw, event_time);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (focusw == GTK_WIDGET(doc->editor->sci))
|
|
|
|
{
|
|
|
|
if (keyval == GDK_Menu)
|
|
|
|
{ /* show editor popup menu */
|
|
|
|
trigger_button_event(focusw, event_time);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
2009-04-24 19:28:55 +00:00
|
|
|
{ /* show tab bar menu */
|
|
|
|
trigger_button_event(main_widgets.notebook, event_time);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-02-05 19:10:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (focusw == tv.tree_openfiles
|
|
|
|
|| focusw == msgwindow.tree_status
|
|
|
|
|| focusw == msgwindow.tree_compiler
|
|
|
|
|| focusw == msgwindow.tree_msg
|
2009-12-20 20:07:04 +00:00
|
|
|
|| focusw == msgwindow.scribble
|
2009-02-05 19:10:57 +00:00
|
|
|
#ifdef HAVE_VTE
|
|
|
|
|| (vte_info.have_vte && focusw == vc->vte)
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
trigger_button_event(focusw, event_time);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-29 18:21:12 +00:00
|
|
|
#ifdef HAVE_VTE
|
2008-07-03 17:04:12 +00:00
|
|
|
static gboolean on_menu_expose_event(GtkWidget *widget, GdkEventExpose *event,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_SENSITIVE(widget))
|
|
|
|
gtk_widget_set_sensitive(GTK_WIDGET(widget), TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-26 16:22:20 +00:00
|
|
|
static gboolean set_sensitive(gpointer widget)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive(GTK_WIDGET(widget), TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-08 16:58:20 +00:00
|
|
|
static gboolean check_vte(GdkModifierType state, guint keyval)
|
2007-09-26 16:22:20 +00:00
|
|
|
{
|
2007-11-06 16:59:01 +00:00
|
|
|
guint i;
|
2010-08-10 12:43:30 +00:00
|
|
|
GeanyKeyBinding *kb;
|
|
|
|
GeanyKeyGroup *group;
|
2007-09-28 10:54:56 +00:00
|
|
|
GtkWidget *widget;
|
2007-09-26 16:22:20 +00:00
|
|
|
|
2007-10-02 16:20:44 +00:00
|
|
|
if (! vc->enable_bash_keys)
|
2007-09-26 16:22:20 +00:00
|
|
|
return FALSE;
|
2008-05-22 14:41:28 +00:00
|
|
|
if (gtk_window_get_focus(GTK_WINDOW(main_widgets.window)) != vc->vte)
|
2007-09-26 16:22:20 +00:00
|
|
|
return FALSE;
|
2008-02-27 13:17:29 +00:00
|
|
|
/* prevent menubar flickering: */
|
2007-12-18 13:35:51 +00:00
|
|
|
if (state == GDK_SHIFT_MASK && (keyval >= GDK_a && keyval <= GDK_z))
|
|
|
|
return FALSE;
|
2008-02-27 13:17:29 +00:00
|
|
|
if (state == 0 && (keyval < GDK_F1 || keyval > GDK_F35)) /* e.g. backspace */
|
2007-12-18 13:35:51 +00:00
|
|
|
return FALSE;
|
2007-09-26 16:22:20 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* make focus commands override any bash commands */
|
2010-08-10 12:43:30 +00:00
|
|
|
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_FOCUS);
|
|
|
|
foreach_ptr_array(kb, i, group->key_items)
|
2007-09-26 16:22:20 +00:00
|
|
|
{
|
2008-03-03 17:28:15 +00:00
|
|
|
if (state == kb->mods && keyval == kb->key)
|
2007-09-26 16:22:20 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-28 10:54:56 +00:00
|
|
|
|
|
|
|
/* Temporarily disable the menus to prevent conflicting menu accelerators
|
|
|
|
* from overriding the VTE bash shortcuts.
|
2008-07-03 17:04:12 +00:00
|
|
|
* Note: maybe there's a better way of doing this ;-) */
|
2008-12-18 21:21:53 +00:00
|
|
|
widget = ui_lookup_widget(main_widgets.window, "menubar1");
|
2007-09-28 10:54:56 +00:00
|
|
|
gtk_widget_set_sensitive(widget, FALSE);
|
2008-07-03 17:04:12 +00:00
|
|
|
{
|
|
|
|
/* make the menubar sensitive before it is redrawn */
|
|
|
|
static gboolean connected = FALSE;
|
|
|
|
if (!connected)
|
|
|
|
g_signal_connect(widget, "expose-event", G_CALLBACK(on_menu_expose_event), NULL);
|
|
|
|
}
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
widget = main_widgets.editor_menu;
|
2007-09-28 10:54:56 +00:00
|
|
|
gtk_widget_set_sensitive(widget, FALSE);
|
2008-07-03 17:04:12 +00:00
|
|
|
g_idle_add(set_sensitive, widget);
|
2007-09-26 16:22:20 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2007-10-02 16:20:44 +00:00
|
|
|
#endif
|
2007-09-26 16:22:20 +00:00
|
|
|
|
|
|
|
|
2009-08-17 22:04:13 +00:00
|
|
|
/* Map the keypad keys to their equivalent functions (taken from ScintillaGTK.cxx) */
|
|
|
|
static guint key_kp_translate(guint key_in)
|
|
|
|
{
|
|
|
|
switch (key_in)
|
|
|
|
{
|
|
|
|
case GDK_KP_Down:
|
|
|
|
return GDK_Down;
|
|
|
|
case GDK_KP_Up:
|
|
|
|
return GDK_Up;
|
|
|
|
case GDK_KP_Left:
|
|
|
|
return GDK_Left;
|
|
|
|
case GDK_KP_Right:
|
|
|
|
return GDK_Right;
|
|
|
|
case GDK_KP_Home:
|
|
|
|
return GDK_Home;
|
|
|
|
case GDK_KP_End:
|
|
|
|
return GDK_End;
|
|
|
|
case GDK_KP_Page_Up:
|
|
|
|
return GDK_Page_Up;
|
|
|
|
case GDK_KP_Page_Down:
|
|
|
|
return GDK_Page_Down;
|
|
|
|
case GDK_KP_Delete:
|
|
|
|
return GDK_Delete;
|
|
|
|
case GDK_KP_Insert:
|
|
|
|
return GDK_Insert;
|
|
|
|
default:
|
|
|
|
return key_in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-23 22:25:11 +00:00
|
|
|
/* Stripped down version of the main keypress event handler which can be used
|
|
|
|
* to process foreign events. Instead of executing the keybinding, a pointer to the
|
|
|
|
* keybinding structure is returned.
|
|
|
|
* Additionally, the group_id and binding_id are filled with the appropriate indexes
|
|
|
|
* if non-NULL. */
|
|
|
|
const GeanyKeyBinding *keybindings_check_event(GdkEventKey *ev, gint *group_id, gint *binding_id)
|
|
|
|
{
|
|
|
|
guint state, keyval;
|
|
|
|
gsize g, i;
|
|
|
|
GeanyKeyGroup *group;
|
|
|
|
GeanyKeyBinding *kb;
|
|
|
|
|
|
|
|
if (ev->keyval == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
keyval = ev->keyval;
|
|
|
|
state = ev->state & gtk_accelerator_get_default_mod_mask();
|
|
|
|
/* hack to get around that CTRL+Shift+r results in GDK_R not GDK_r */
|
|
|
|
if ((ev->state & GDK_SHIFT_MASK) || (ev->state & GDK_LOCK_MASK))
|
|
|
|
if (keyval >= GDK_A && keyval <= GDK_Z)
|
|
|
|
keyval += GDK_a - GDK_A;
|
|
|
|
|
|
|
|
if (keyval >= GDK_KP_Space && keyval < GDK_KP_Equal)
|
|
|
|
keyval = key_kp_translate(keyval);
|
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(group, g, keybinding_groups)
|
2009-11-23 22:25:11 +00:00
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(kb, i, group->key_items)
|
2009-11-23 22:25:11 +00:00
|
|
|
{
|
|
|
|
if (keyval == kb->key && state == kb->mods)
|
|
|
|
{
|
|
|
|
if (group_id != NULL)
|
|
|
|
*group_id = g;
|
|
|
|
if (binding_id != NULL)
|
2010-08-10 12:43:30 +00:00
|
|
|
*binding_id = kb->id;
|
2009-11-23 22:25:11 +00:00
|
|
|
return kb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-19 17:18:06 +00:00
|
|
|
/* central keypress event handler, almost all keypress events go to this function */
|
2009-01-02 13:37:40 +00:00
|
|
|
static gboolean on_key_press_event(GtkWidget *widget, GdkEventKey *ev, gpointer user_data)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2008-02-29 19:30:28 +00:00
|
|
|
guint state, keyval;
|
|
|
|
gsize g, i;
|
2009-04-05 21:07:40 +00:00
|
|
|
GeanyDocument *doc;
|
|
|
|
GeanyKeyGroup *group;
|
|
|
|
GeanyKeyBinding *kb;
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
if (ev->keyval == 0)
|
2007-08-28 10:50:18 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
doc = document_get_current();
|
2009-07-23 17:11:31 +00:00
|
|
|
if (doc)
|
|
|
|
document_check_disk_status(doc, FALSE);
|
2008-03-27 17:16:53 +00:00
|
|
|
|
2008-02-12 15:49:54 +00:00
|
|
|
keyval = ev->keyval;
|
2009-11-23 22:25:11 +00:00
|
|
|
state = ev->state & gtk_accelerator_get_default_mod_mask();
|
2008-02-27 13:17:29 +00:00
|
|
|
/* hack to get around that CTRL+Shift+r results in GDK_R not GDK_r */
|
2008-02-27 14:21:34 +00:00
|
|
|
if ((ev->state & GDK_SHIFT_MASK) || (ev->state & GDK_LOCK_MASK))
|
2007-08-30 14:07:49 +00:00
|
|
|
if (keyval >= GDK_A && keyval <= GDK_Z)
|
|
|
|
keyval += GDK_a - GDK_A;
|
2007-03-24 16:10:20 +00:00
|
|
|
|
2009-08-17 22:04:13 +00:00
|
|
|
if (keyval >= GDK_KP_Space && keyval < GDK_KP_Equal)
|
|
|
|
keyval = key_kp_translate(keyval);
|
|
|
|
|
2008-02-27 14:21:34 +00:00
|
|
|
/*geany_debug("%d (%d) %d (%d)", keyval, ev->keyval, state, ev->state);*/
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* special cases */
|
2007-10-02 16:20:44 +00:00
|
|
|
#ifdef HAVE_VTE
|
2008-02-12 15:49:54 +00:00
|
|
|
if (vte_info.have_vte && check_vte(state, keyval))
|
2007-09-26 16:22:20 +00:00
|
|
|
return FALSE;
|
2007-10-02 16:20:44 +00:00
|
|
|
#endif
|
2009-04-05 21:07:40 +00:00
|
|
|
if (check_menu_key(doc, keyval, state, ev->time))
|
2009-02-05 19:10:57 +00:00
|
|
|
return TRUE;
|
2009-10-12 11:50:45 +00:00
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(group, g, keybinding_groups)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_ptr_array(kb, i, group->key_items)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2008-02-29 19:30:28 +00:00
|
|
|
if (keyval == kb->key && state == kb->mods)
|
|
|
|
{
|
|
|
|
/* call the corresponding callback function for this shortcut */
|
2009-10-12 11:50:45 +00:00
|
|
|
if (kb->callback)
|
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
kb->callback(kb->id);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (group->callback)
|
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
if (group->callback(kb->id))
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
continue; /* not handled */
|
|
|
|
}
|
|
|
|
g_warning("No callback for keybinding %s: %s!", group->name, kb->name);
|
2008-02-29 19:30:28 +00:00
|
|
|
}
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-29 19:30:28 +00:00
|
|
|
/* fixed keybindings can be overridden by user bindings, so check them last */
|
2008-02-12 15:49:54 +00:00
|
|
|
if (check_fixed_kb(keyval, state))
|
2007-09-07 12:34:57 +00:00
|
|
|
return TRUE;
|
2006-05-19 17:18:06 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-02 13:37:40 +00:00
|
|
|
static gboolean is_modifier_key(guint keyval)
|
|
|
|
{
|
|
|
|
switch (keyval)
|
|
|
|
{
|
|
|
|
case GDK_Shift_L:
|
|
|
|
case GDK_Shift_R:
|
|
|
|
case GDK_Control_L:
|
|
|
|
case GDK_Control_R:
|
|
|
|
case GDK_Meta_L:
|
|
|
|
case GDK_Meta_R:
|
|
|
|
case GDK_Alt_L:
|
|
|
|
case GDK_Alt_R:
|
|
|
|
case GDK_Super_L:
|
|
|
|
case GDK_Super_R:
|
|
|
|
case GDK_Hyper_L:
|
|
|
|
case GDK_Hyper_R:
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-08 18:05:53 +00:00
|
|
|
GeanyKeyBinding *keybindings_lookup_item(guint group_id, guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2008-08-08 18:05:53 +00:00
|
|
|
GeanyKeyGroup *group;
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_val_if_fail(group_id < keybinding_groups->len, NULL);
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
group = g_ptr_array_index(keybinding_groups, group_id);
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_val_if_fail(group, NULL);
|
2010-08-10 12:43:30 +00:00
|
|
|
return keybindings_get_item(group, key_id);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-12 18:15:48 +00:00
|
|
|
/** Mimics a (built-in only) keybinding action.
|
2008-03-12 13:37:39 +00:00
|
|
|
* Example: @code keybindings_send_command(GEANY_KEY_GROUP_FILE, GEANY_KEYS_FILE_OPEN); @endcode
|
2010-08-10 12:43:30 +00:00
|
|
|
* @param group_id @ref GeanyKeyGroupID keybinding group index that contains the @a key_id keybinding.
|
|
|
|
* @param key_id @ref GeanyKeyBindingID keybinding index. */
|
2008-03-10 13:29:35 +00:00
|
|
|
void keybindings_send_command(guint group_id, guint key_id)
|
2007-07-18 15:35:52 +00:00
|
|
|
{
|
2008-08-08 18:05:53 +00:00
|
|
|
GeanyKeyBinding *kb;
|
2008-03-07 17:24:36 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(group_id < GEANY_KEY_GROUP_COUNT); /* can't use this for plugin groups */
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2008-03-10 13:23:57 +00:00
|
|
|
kb = keybindings_lookup_item(group_id, key_id);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (kb)
|
2009-10-12 11:50:45 +00:00
|
|
|
{
|
|
|
|
if (kb->callback)
|
|
|
|
kb->callback(key_id);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GeanyKeyGroup *group = g_ptr_array_index(keybinding_groups, group_id);
|
|
|
|
|
|
|
|
if (group->callback)
|
|
|
|
group->callback(key_id);
|
|
|
|
}
|
|
|
|
}
|
2007-07-18 15:35:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-03 15:38:02 +00:00
|
|
|
/* These are the callback functions, either each group or each shortcut has it's
|
|
|
|
* own function. */
|
|
|
|
|
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_file_action(guint key_id)
|
2007-05-03 15:38:02 +00:00
|
|
|
{
|
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_NEW:
|
2007-09-03 16:09:53 +00:00
|
|
|
document_new_file(NULL, NULL, NULL);
|
2007-05-03 16:13:30 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_OPEN:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_open1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_OPENSELECTED:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_menu_open_selected_file1_activate(NULL, NULL);
|
|
|
|
break;
|
2010-01-01 23:20:21 +00:00
|
|
|
case GEANY_KEYS_FILE_OPENLASTTAB:
|
|
|
|
{
|
|
|
|
gchar *utf8_filename = g_queue_peek_head(ui_prefs.recent_queue);
|
|
|
|
gchar *locale_filename = utils_get_locale_from_utf8(utf8_filename);
|
|
|
|
document_open_file(locale_filename, FALSE, NULL, NULL);
|
|
|
|
g_free(locale_filename);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_SAVE:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_save1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_SAVEAS:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_save_as1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_SAVEALL:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_save_all1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_CLOSE:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_close1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_CLOSEALL:
|
2007-05-03 16:13:30 +00:00
|
|
|
on_close_all1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_RELOAD:
|
2008-09-08 14:22:39 +00:00
|
|
|
on_toolbutton_reload_clicked(NULL, NULL);
|
2007-05-03 16:13:30 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FILE_PRINT:
|
|
|
|
on_print1_activate(NULL, NULL);
|
2007-05-03 15:38:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-05-03 15:38:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_project_action(guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_PROJECT_PROPERTIES:
|
|
|
|
if (app->project)
|
|
|
|
on_project_properties1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2006-07-01 14:12:05 +00:00
|
|
|
|
2009-10-28 18:06:16 +00:00
|
|
|
static void cb_func_menu_preferences(guint key_id)
|
2006-05-24 13:18:42 +00:00
|
|
|
{
|
2009-10-28 18:06:16 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_SETTINGS_PREFERENCES:
|
|
|
|
on_preferences1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_SETTINGS_PLUGINPREFERENCES:
|
|
|
|
on_plugin_preferences1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-24 13:18:42 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 14:13:38 +00:00
|
|
|
|
2007-07-04 14:41:58 +00:00
|
|
|
static void cb_func_menu_help(G_GNUC_UNUSED guint key_id)
|
|
|
|
{
|
|
|
|
on_help1_activate(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-16 14:13:38 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_search_action(guint key_id)
|
2006-12-09 17:03:03 +00:00
|
|
|
{
|
2009-07-10 15:17:27 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
ScintillaObject *sci;
|
|
|
|
|
2009-10-14 14:07:28 +00:00
|
|
|
if (key_id == GEANY_KEYS_SEARCH_FINDINFILES)
|
|
|
|
{
|
|
|
|
on_find_in_files1_activate(NULL, NULL); /* works without docs too */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-07-10 15:17:27 +00:00
|
|
|
if (!doc)
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2009-07-10 15:17:27 +00:00
|
|
|
sci = doc->editor->sci;
|
2009-04-05 21:07:40 +00:00
|
|
|
|
2007-09-13 16:40:19 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FIND:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_find1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FINDNEXT:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_find_next1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FINDPREVIOUS:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_find_previous1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FINDPREVSEL:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_find_prevsel1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FINDNEXTSEL:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_find_nextsel1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_REPLACE:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_replace1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_NEXTMESSAGE:
|
2007-09-13 16:40:19 +00:00
|
|
|
on_next_message1_activate(NULL, NULL); break;
|
2008-06-26 16:39:41 +00:00
|
|
|
case GEANY_KEYS_SEARCH_PREVIOUSMESSAGE:
|
|
|
|
on_previous_message1_activate(NULL, NULL); break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FINDUSAGE:
|
2009-04-05 21:07:40 +00:00
|
|
|
read_current_word(doc);
|
2008-12-19 17:15:52 +00:00
|
|
|
on_find_usage1_activate(NULL, NULL);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
2008-07-17 16:42:03 +00:00
|
|
|
case GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE:
|
2009-04-05 21:07:40 +00:00
|
|
|
read_current_word(doc);
|
2008-12-19 17:15:52 +00:00
|
|
|
on_find_document_usage1_activate(NULL, NULL);
|
2008-07-17 16:42:03 +00:00
|
|
|
break;
|
2009-07-10 15:17:27 +00:00
|
|
|
case GEANY_KEYS_SEARCH_MARKALL:
|
2009-09-16 12:13:50 +00:00
|
|
|
{
|
|
|
|
gchar *text = get_current_word_or_sel(doc);
|
2009-07-10 15:17:27 +00:00
|
|
|
|
2009-09-16 12:13:50 +00:00
|
|
|
if (sci_has_selection(sci))
|
2009-07-10 15:17:27 +00:00
|
|
|
search_mark_all(doc, text, SCFIND_MATCHCASE);
|
|
|
|
else
|
|
|
|
{
|
2009-09-16 12:13:50 +00:00
|
|
|
/* clears markers if text is null */
|
|
|
|
search_mark_all(doc, text, SCFIND_MATCHCASE | SCFIND_WHOLEWORD);
|
2009-07-10 15:17:27 +00:00
|
|
|
}
|
2009-09-16 12:13:50 +00:00
|
|
|
g_free(text);
|
2009-07-10 15:17:27 +00:00
|
|
|
break;
|
2009-09-16 12:13:50 +00:00
|
|
|
}
|
2007-09-13 16:40:19 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 12:13:50 +00:00
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_menu_opencolorchooser(G_GNUC_UNUSED guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2006-07-27 20:57:13 +00:00
|
|
|
on_show_color_chooser1_activate(NULL, NULL);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 14:01:24 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_view_action(guint key_id)
|
2009-01-02 14:01:24 +00:00
|
|
|
{
|
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_VIEW_TOGGLEALL:
|
|
|
|
on_menu_toggle_all_additional_widgets1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_VIEW_SIDEBAR:
|
|
|
|
on_menu_show_sidebar1_toggled(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_VIEW_ZOOMIN:
|
|
|
|
on_zoom_in1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_VIEW_ZOOMOUT:
|
|
|
|
on_zoom_out1_activate(NULL, NULL);
|
|
|
|
break;
|
2010-03-25 22:18:00 +00:00
|
|
|
case GEANY_KEYS_VIEW_ZOOMRESET:
|
|
|
|
on_normal_size1_activate(NULL, NULL);
|
|
|
|
break;
|
2009-01-02 14:01:24 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2009-01-02 14:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_menu_fullscreen(G_GNUC_UNUSED guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2009-01-26 18:21:53 +00:00
|
|
|
GtkCheckMenuItem *c = GTK_CHECK_MENU_ITEM(
|
|
|
|
ui_lookup_widget(main_widgets.window, "menu_fullscreen1"));
|
2006-05-19 17:18:06 +00:00
|
|
|
|
|
|
|
gtk_check_menu_item_set_active(c, ! gtk_check_menu_item_get_active(c));
|
|
|
|
}
|
|
|
|
|
2009-09-16 14:13:38 +00:00
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_menu_messagewindow(G_GNUC_UNUSED guint key_id)
|
2006-05-21 14:02:55 +00:00
|
|
|
{
|
2009-01-26 18:21:53 +00:00
|
|
|
GtkCheckMenuItem *c = GTK_CHECK_MENU_ITEM(
|
|
|
|
ui_lookup_widget(main_widgets.window, "menu_show_messages_window1"));
|
2006-05-21 14:02:55 +00:00
|
|
|
|
|
|
|
gtk_check_menu_item_set_active(c, ! gtk_check_menu_item_get_active(c));
|
|
|
|
}
|
|
|
|
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_build_action(guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2006-11-29 10:29:34 +00:00
|
|
|
GtkWidget *item;
|
2006-11-30 15:42:52 +00:00
|
|
|
BuildMenuItems *menu_items;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-10-12 11:50:45 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2009-07-23 14:39:03 +00:00
|
|
|
if (!GTK_WIDGET_IS_SENSITIVE(ui_lookup_widget(main_widgets.window, "menu_build1")))
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2009-07-23 14:39:03 +00:00
|
|
|
menu_items = build_get_menu_items(doc->file_type->id);
|
2010-08-10 16:34:51 +00:00
|
|
|
/* TODO make it a table??*/
|
2006-11-29 10:29:34 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_BUILD_COMPILE:
|
2009-07-30 02:04:08 +00:00
|
|
|
item = menu_items->menu_item[GEANY_GBG_FT][GBO_TO_CMD(GEANY_GBO_COMPILE)];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-11-29 10:29:34 +00:00
|
|
|
case GEANY_KEYS_BUILD_LINK:
|
2009-07-30 02:04:08 +00:00
|
|
|
item = menu_items->menu_item[GEANY_GBG_FT][GBO_TO_CMD(GEANY_GBO_BUILD)];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-11-29 10:29:34 +00:00
|
|
|
case GEANY_KEYS_BUILD_MAKE:
|
2009-08-27 13:50:12 +00:00
|
|
|
item = menu_items->menu_item[GEANY_GBG_NON_FT][GBO_TO_CMD(GEANY_GBO_MAKE_ALL)];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-11-29 10:29:34 +00:00
|
|
|
case GEANY_KEYS_BUILD_MAKEOWNTARGET:
|
2009-08-27 13:50:12 +00:00
|
|
|
item = menu_items->menu_item[GEANY_GBG_NON_FT][GBO_TO_CMD(GEANY_GBO_CUSTOM)];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-11-29 10:29:34 +00:00
|
|
|
case GEANY_KEYS_BUILD_MAKEOBJECT:
|
2009-08-27 13:50:12 +00:00
|
|
|
item = menu_items->menu_item[GEANY_GBG_NON_FT][GBO_TO_CMD(GEANY_GBO_MAKE_OBJECT)];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-12-09 17:03:03 +00:00
|
|
|
case GEANY_KEYS_BUILD_NEXTERROR:
|
2009-07-09 06:49:42 +00:00
|
|
|
item = menu_items->menu_item[GBG_FIXED][GBF_NEXT_ERROR];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2008-06-26 16:39:41 +00:00
|
|
|
case GEANY_KEYS_BUILD_PREVIOUSERROR:
|
2009-07-09 06:49:42 +00:00
|
|
|
item = menu_items->menu_item[GBG_FIXED][GBF_PREV_ERROR];
|
2008-06-26 16:39:41 +00:00
|
|
|
break;
|
2006-11-29 10:29:34 +00:00
|
|
|
case GEANY_KEYS_BUILD_RUN:
|
2009-07-30 02:04:08 +00:00
|
|
|
item = menu_items->menu_item[GEANY_GBG_EXEC][GBO_TO_CMD(GEANY_GBO_EXEC)];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-11-30 15:42:52 +00:00
|
|
|
case GEANY_KEYS_BUILD_OPTIONS:
|
2009-07-09 06:49:42 +00:00
|
|
|
item = menu_items->menu_item[GBG_FIXED][GBF_COMMANDS];
|
2007-05-05 16:35:59 +00:00
|
|
|
break;
|
2006-11-29 10:29:34 +00:00
|
|
|
default:
|
2007-05-05 16:35:59 +00:00
|
|
|
item = NULL;
|
2006-11-29 10:29:34 +00:00
|
|
|
}
|
2008-01-10 13:41:58 +00:00
|
|
|
/* Note: For Build menu items it's OK (at the moment) to assume they are in the correct
|
|
|
|
* sensitive state, but some other menus don't update the sensitive status until
|
|
|
|
* they are redrawn. */
|
2006-11-29 10:29:34 +00:00
|
|
|
if (item && GTK_WIDGET_IS_SENSITIVE(item))
|
|
|
|
gtk_menu_item_activate(GTK_MENU_ITEM(item));
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2008-12-19 17:15:52 +00:00
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
static gboolean read_current_word(GeanyDocument *doc)
|
2006-06-17 21:08:47 +00:00
|
|
|
{
|
2006-06-18 17:14:32 +00:00
|
|
|
gint pos;
|
2006-06-17 21:08:47 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2008-03-12 13:37:39 +00:00
|
|
|
return FALSE;
|
2006-06-29 17:14:52 +00:00
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
pos = sci_get_current_position(doc->editor->sci);
|
2006-06-18 17:14:32 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_find_current_word(doc->editor, pos,
|
2007-01-24 19:20:12 +00:00
|
|
|
editor_info.current_word, GEANY_MAX_WORD_LENGTH, NULL);
|
2006-06-17 21:08:47 +00:00
|
|
|
|
2008-12-19 17:15:52 +00:00
|
|
|
return (*editor_info.current_word != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
static gboolean check_current_word(GeanyDocument *doc)
|
2008-12-19 17:15:52 +00:00
|
|
|
{
|
2009-04-05 21:07:40 +00:00
|
|
|
if (!read_current_word(doc))
|
2008-03-12 13:37:39 +00:00
|
|
|
{
|
2006-06-17 21:08:47 +00:00
|
|
|
utils_beep();
|
2008-03-12 13:37:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-06-17 21:08:47 +00:00
|
|
|
}
|
|
|
|
|
2006-05-19 17:18:06 +00:00
|
|
|
|
2009-09-16 12:13:50 +00:00
|
|
|
static gchar *get_current_word_or_sel(GeanyDocument *doc)
|
|
|
|
{
|
|
|
|
ScintillaObject *sci = doc->editor->sci;
|
|
|
|
|
|
|
|
if (sci_has_selection(sci))
|
|
|
|
return sci_get_selection_contents(sci);
|
|
|
|
|
|
|
|
return read_current_word(doc) ? g_strdup(editor_info.current_word) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-04 13:54:59 +00:00
|
|
|
static void focus_sidebar(void)
|
2008-03-23 16:32:36 +00:00
|
|
|
{
|
|
|
|
if (ui_prefs.sidebar_visible)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
gint page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.sidebar_notebook));
|
|
|
|
GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(main_widgets.sidebar_notebook), page_num);
|
2008-03-23 16:32:36 +00:00
|
|
|
|
2008-05-19 14:33:50 +00:00
|
|
|
/* gtk_widget_grab_focus() won't work because of the scrolled window containers */
|
|
|
|
gtk_widget_child_focus(page, GTK_DIR_TAB_FORWARD);
|
2008-03-23 16:32:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-04 13:54:59 +00:00
|
|
|
|
2010-02-21 18:06:42 +00:00
|
|
|
static void focus_msgwindow(void)
|
|
|
|
{
|
|
|
|
if (ui_prefs.msgwindow_visible)
|
|
|
|
{
|
|
|
|
gint page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK(msgwindow.notebook));
|
|
|
|
GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(msgwindow.notebook), page_num);
|
|
|
|
|
|
|
|
gtk_widget_grab_focus(gtk_bin_get_child(GTK_BIN(page)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_switch_action(guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2008-07-04 13:54:59 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_FOCUS_EDITOR:
|
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc != NULL)
|
2010-02-24 15:08:41 +00:00
|
|
|
{
|
|
|
|
GtkWidget *sci = GTK_WIDGET(doc->editor->sci);
|
|
|
|
if (GTK_WIDGET_HAS_FOCUS(sci))
|
|
|
|
ui_update_statusbar(doc, -1);
|
|
|
|
else
|
|
|
|
gtk_widget_grab_focus(sci);
|
|
|
|
}
|
2008-07-04 13:54:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GEANY_KEYS_FOCUS_SCRIBBLE:
|
|
|
|
msgwin_switch_tab(MSG_SCRATCH, TRUE);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_FOCUS_SEARCHBAR:
|
2008-12-06 11:10:06 +00:00
|
|
|
if (toolbar_prefs.visible)
|
|
|
|
{
|
|
|
|
GtkWidget *search_entry = toolbar_get_widget_child_by_name("SearchEntry");
|
|
|
|
if (search_entry != NULL)
|
|
|
|
gtk_widget_grab_focus(search_entry);
|
|
|
|
}
|
2008-07-04 13:54:59 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_FOCUS_SIDEBAR:
|
|
|
|
focus_sidebar();
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_FOCUS_VTE:
|
|
|
|
msgwin_switch_tab(MSG_VTE, TRUE);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_FOCUS_COMPILER:
|
|
|
|
msgwin_switch_tab(MSG_COMPILER, TRUE);
|
|
|
|
break;
|
2009-10-20 16:59:00 +00:00
|
|
|
case GEANY_KEYS_FOCUS_MESSAGES:
|
|
|
|
msgwin_switch_tab(MSG_MESSAGE, TRUE);
|
|
|
|
break;
|
2010-02-21 18:06:42 +00:00
|
|
|
case GEANY_KEYS_FOCUS_MESSAGE_WINDOW:
|
|
|
|
focus_msgwindow();
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST:
|
|
|
|
sidebar_focus_openfiles_tab();
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST:
|
|
|
|
sidebar_focus_symbols_tab();
|
|
|
|
break;
|
2008-07-04 13:54:59 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
|
2009-08-09 11:17:00 +00:00
|
|
|
static void switch_notebook_page(gint direction)
|
2008-05-22 14:41:28 +00:00
|
|
|
{
|
2009-08-09 11:17:00 +00:00
|
|
|
gint page_count, cur_page;
|
|
|
|
gboolean parent_is_notebook = FALSE;
|
|
|
|
GtkNotebook *notebook;
|
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
|
|
|
|
|
|
|
/* check whether the current widget is a GtkNotebook or a child of a GtkNotebook */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
parent_is_notebook = GTK_IS_NOTEBOOK(focusw);
|
|
|
|
}
|
|
|
|
while (! parent_is_notebook && (focusw = gtk_widget_get_parent(focusw)) != NULL);
|
|
|
|
|
|
|
|
/* if we found a GtkNotebook widget, use it. Otherwise fallback to the documents notebook */
|
|
|
|
if (parent_is_notebook)
|
|
|
|
notebook = GTK_NOTEBOOK(focusw);
|
|
|
|
else
|
|
|
|
notebook = GTK_NOTEBOOK(main_widgets.notebook);
|
|
|
|
|
|
|
|
/* now switch pages */
|
|
|
|
page_count = gtk_notebook_get_n_pages(notebook);
|
|
|
|
cur_page = gtk_notebook_get_current_page(notebook);
|
2008-05-22 14:41:28 +00:00
|
|
|
|
2009-07-04 09:18:01 +00:00
|
|
|
if (direction == GTK_DIR_LEFT)
|
2008-05-22 14:41:28 +00:00
|
|
|
{
|
|
|
|
if (cur_page > 0)
|
2009-08-09 11:17:00 +00:00
|
|
|
gtk_notebook_set_current_page(notebook, cur_page - 1);
|
2008-05-22 14:41:28 +00:00
|
|
|
else
|
2009-08-09 11:17:00 +00:00
|
|
|
gtk_notebook_set_current_page(notebook, page_count - 1);
|
2008-05-22 14:41:28 +00:00
|
|
|
}
|
2009-07-04 09:18:01 +00:00
|
|
|
else if (direction == GTK_DIR_RIGHT)
|
2008-05-22 14:41:28 +00:00
|
|
|
{
|
|
|
|
if (cur_page < page_count - 1)
|
2009-08-09 11:17:00 +00:00
|
|
|
gtk_notebook_set_current_page(notebook, cur_page + 1);
|
2008-05-22 14:41:28 +00:00
|
|
|
else
|
2009-08-09 11:17:00 +00:00
|
|
|
gtk_notebook_set_current_page(notebook, 0);
|
2008-05-22 14:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_switch_tableft(G_GNUC_UNUSED guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2009-08-09 11:17:00 +00:00
|
|
|
switch_notebook_page(GTK_DIR_LEFT);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2009-08-09 11:17:00 +00:00
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
static void cb_func_switch_tabright(G_GNUC_UNUSED guint key_id)
|
2006-05-19 17:18:06 +00:00
|
|
|
{
|
2009-08-09 11:17:00 +00:00
|
|
|
switch_notebook_page(GTK_DIR_RIGHT);
|
2006-05-19 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 13:37:40 +00:00
|
|
|
|
|
|
|
static gboolean on_key_release_event(GtkWidget *widget, GdkEventKey *ev, gpointer user_data)
|
|
|
|
{
|
|
|
|
/* user may have rebound keybinding to a different modifier than Ctrl, so check all */
|
2010-06-10 11:37:39 +00:00
|
|
|
if (switch_in_progress && is_modifier_key(ev->keyval))
|
2009-01-02 13:37:40 +00:00
|
|
|
{
|
2010-06-10 11:37:39 +00:00
|
|
|
switch_in_progress = FALSE;
|
2009-01-02 13:37:40 +00:00
|
|
|
|
2010-06-10 11:37:39 +00:00
|
|
|
if (switch_dialog)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy(switch_dialog);
|
|
|
|
switch_dialog = NULL;
|
|
|
|
}
|
2009-05-13 15:37:28 +00:00
|
|
|
|
|
|
|
mru_pos = 0;
|
2009-01-02 13:37:40 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *ui_minimal_dialog_new(GtkWindow *parent, const gchar *title)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
|
|
|
|
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
|
|
|
|
}
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), title);
|
|
|
|
gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
|
|
|
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
|
|
|
|
|
|
|
|
gtk_widget_set_name(dialog, "GeanyDialog");
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *create_switch_dialog(void)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog, *widget, *vbox;
|
|
|
|
|
|
|
|
dialog = ui_minimal_dialog_new(GTK_WINDOW(main_widgets.window), _("Switch to Document"));
|
|
|
|
gtk_window_set_decorated(GTK_WINDOW(dialog), FALSE);
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(dialog), 150, -1);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 6);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
|
|
|
gtk_container_add(GTK_CONTAINER(dialog), vbox);
|
|
|
|
|
|
|
|
widget = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_container_add(GTK_CONTAINER(vbox), widget);
|
|
|
|
|
|
|
|
widget = geany_wrap_label_new(NULL);
|
|
|
|
gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER);
|
|
|
|
gtk_container_add(GTK_CONTAINER(vbox), widget);
|
|
|
|
switch_dialog_label = widget;
|
|
|
|
|
|
|
|
g_signal_connect(dialog, "key-release-event", G_CALLBACK(on_key_release_event), NULL);
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-10 11:37:39 +00:00
|
|
|
static void update_filename_label()
|
2009-01-02 13:37:40 +00:00
|
|
|
{
|
2010-06-10 11:37:39 +00:00
|
|
|
if (!switch_dialog)
|
2009-05-13 15:37:28 +00:00
|
|
|
{
|
2009-01-02 13:37:40 +00:00
|
|
|
switch_dialog = create_switch_dialog();
|
2010-06-10 11:37:39 +00:00
|
|
|
gtk_widget_show_all(switch_dialog);
|
|
|
|
}
|
2009-01-02 13:37:40 +00:00
|
|
|
|
|
|
|
geany_wrap_label_set_text(GTK_LABEL(switch_dialog_label),
|
|
|
|
DOC_FILENAME(document_get_current()));
|
2010-06-10 11:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean on_switch_timeout(G_GNUC_UNUSED gpointer data)
|
|
|
|
{
|
|
|
|
if (!switch_in_progress || switch_dialog)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_filename_label();
|
2009-01-02 13:37:40 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-13 17:00:12 +00:00
|
|
|
static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
|
|
|
|
{
|
2009-05-13 15:37:28 +00:00
|
|
|
GeanyDocument *last_doc = g_queue_peek_nth(mru_docs, mru_pos);
|
2007-03-13 17:00:12 +00:00
|
|
|
|
2009-05-13 15:37:28 +00:00
|
|
|
if (! DOC_VALID(last_doc))
|
|
|
|
{
|
2009-05-22 14:50:34 +00:00
|
|
|
utils_beep();
|
2009-05-13 15:37:28 +00:00
|
|
|
mru_pos = 0;
|
|
|
|
last_doc = g_queue_peek_nth(mru_docs, mru_pos);
|
|
|
|
}
|
2009-04-05 21:07:40 +00:00
|
|
|
if (! DOC_VALID(last_doc))
|
2009-01-02 13:37:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
|
|
|
document_get_notebook_page(last_doc));
|
|
|
|
|
|
|
|
/* if there's a modifier key, we can switch back in MRU order each time unless
|
|
|
|
* the key is released */
|
2010-06-10 11:37:39 +00:00
|
|
|
if (!switch_in_progress)
|
2009-01-02 13:37:40 +00:00
|
|
|
{
|
2010-06-10 11:37:39 +00:00
|
|
|
switch_in_progress = TRUE;
|
|
|
|
|
|
|
|
/* because switch_in_progress was not set when we called
|
|
|
|
* gtk_notebook_set_current_page() above, this function inserted last_doc
|
|
|
|
* into the queue => on mru_pos = 0 there is last_doc, on mru_pos = 1
|
|
|
|
* there is the currently displayed doc, so we want to continue from 2
|
|
|
|
* next time this function is called */
|
|
|
|
mru_pos = 2;
|
2009-01-02 13:37:40 +00:00
|
|
|
|
|
|
|
/* delay showing dialog to give user time to let go of any modifier keys */
|
|
|
|
g_timeout_add(600, on_switch_timeout, NULL);
|
|
|
|
}
|
2010-06-10 11:37:39 +00:00
|
|
|
else
|
|
|
|
{
|
2010-06-10 11:55:39 +00:00
|
|
|
update_filename_label();
|
2010-06-10 11:37:39 +00:00
|
|
|
mru_pos += 1;
|
|
|
|
}
|
2007-03-13 17:00:12 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 13:37:40 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* move document left/right/first/last */
|
2007-09-07 12:34:57 +00:00
|
|
|
static void cb_func_move_tab(guint key_id)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GtkWidget *sci;
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkNotebook *nb = GTK_NOTEBOOK(main_widgets.notebook);
|
2007-09-07 12:34:57 +00:00
|
|
|
gint cur_page = gtk_notebook_get_current_page(nb);
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-09-07 12:34:57 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2007-09-07 12:34:57 +00:00
|
|
|
return;
|
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
sci = GTK_WIDGET(doc->editor->sci);
|
2008-06-15 13:35:48 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
switch (key_id)
|
2007-09-07 12:34:57 +00:00
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_NOTEBOOK_MOVETABLEFT:
|
|
|
|
gtk_notebook_reorder_child(nb, sci, cur_page - 1); /* notebook wraps around by default */
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_NOTEBOOK_MOVETABRIGHT:
|
|
|
|
{
|
|
|
|
gint npage = cur_page + 1;
|
2007-09-07 12:34:57 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
if (npage == gtk_notebook_get_n_pages(nb))
|
|
|
|
npage = 0; /* wraparound */
|
|
|
|
gtk_notebook_reorder_child(nb, sci, npage);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GEANY_KEYS_NOTEBOOK_MOVETABFIRST:
|
2008-05-16 12:08:39 +00:00
|
|
|
gtk_notebook_reorder_child(nb, sci, (file_prefs.tab_order_ltr) ? 0 : -1);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_NOTEBOOK_MOVETABLAST:
|
2008-05-16 12:08:39 +00:00
|
|
|
gtk_notebook_reorder_child(nb, sci, (file_prefs.tab_order_ltr) ? -1 : 0);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
2007-12-16 16:54:47 +00:00
|
|
|
}
|
2007-09-07 12:34:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-04 16:59:00 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
static void goto_matching_brace(GeanyDocument *doc)
|
2006-10-11 22:01:26 +00:00
|
|
|
{
|
|
|
|
gint pos, new_pos;
|
2010-05-08 13:32:23 +00:00
|
|
|
gint after_brace;
|
2006-10-11 22:01:26 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2008-06-15 13:35:48 +00:00
|
|
|
return;
|
2006-10-11 22:01:26 +00:00
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
pos = sci_get_current_position(doc->editor->sci);
|
2010-05-08 13:32:23 +00:00
|
|
|
after_brace = pos > 0 && utils_isbrace(sci_get_char_at(doc->editor->sci, pos - 1), TRUE);
|
|
|
|
pos -= after_brace; /* set pos to the brace */
|
2006-10-11 22:01:26 +00:00
|
|
|
|
2008-09-17 18:02:55 +00:00
|
|
|
new_pos = sci_find_matching_brace(doc->editor->sci, pos);
|
2006-10-11 22:01:26 +00:00
|
|
|
if (new_pos != -1)
|
2010-05-08 13:32:23 +00:00
|
|
|
{ /* set the cursor at/after the brace */
|
|
|
|
sci_set_current_position(doc->editor->sci, new_pos + (!after_brace), FALSE);
|
2008-07-08 13:53:08 +00:00
|
|
|
editor_display_current_line(doc->editor, 0.5F);
|
2006-10-11 22:01:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_clipboard_action(guint key_id)
|
2007-12-25 14:00:18 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2007-12-25 14:00:18 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_CLIPBOARD_CUT:
|
2008-01-10 13:27:26 +00:00
|
|
|
on_cut1_activate(NULL, NULL);
|
2007-12-25 14:00:18 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_CLIPBOARD_COPY:
|
2008-01-10 13:27:26 +00:00
|
|
|
on_copy1_activate(NULL, NULL);
|
2007-12-25 14:00:18 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_CLIPBOARD_PASTE:
|
2008-01-10 13:27:26 +00:00
|
|
|
on_paste1_activate(NULL, NULL);
|
2007-12-25 14:00:18 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_CLIPBOARD_COPYLINE:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_LINECOPY);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_CLIPBOARD_CUTLINE:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_LINECUT);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
2007-12-25 14:00:18 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-12-25 14:00:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-16 12:13:50 +00:00
|
|
|
static void goto_tag(GeanyDocument *doc, gboolean definition)
|
|
|
|
{
|
|
|
|
gchar *text = get_current_word_or_sel(doc);
|
|
|
|
|
|
|
|
if (text)
|
|
|
|
symbols_goto_tag(text, definition);
|
|
|
|
else
|
|
|
|
utils_beep();
|
|
|
|
|
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* Common function for goto keybindings, useful even when sci doesn't have focus. */
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_goto_action(guint key_id)
|
2007-05-05 16:35:59 +00:00
|
|
|
{
|
|
|
|
gint cur_line;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-05-05 16:35:59 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-05-05 16:35:59 +00:00
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
cur_line = sci_get_current_line(doc->editor->sci);
|
2007-05-05 16:35:59 +00:00
|
|
|
|
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_BACK:
|
|
|
|
navqueue_go_back();
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_FORWARD:
|
|
|
|
navqueue_go_forward();
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_LINE:
|
2009-09-21 17:11:42 +00:00
|
|
|
{
|
2009-09-27 10:51:44 +00:00
|
|
|
if (toolbar_prefs.visible)
|
|
|
|
{
|
|
|
|
GtkWidget *wid = toolbar_get_widget_child_by_name("GotoEntry");
|
2009-09-21 17:11:42 +00:00
|
|
|
|
2010-07-12 17:09:57 +00:00
|
|
|
/* use toolbar item if shown & not in the drop down overflow menu */
|
|
|
|
if (wid && GTK_WIDGET_MAPPED(wid))
|
2009-09-27 10:51:44 +00:00
|
|
|
{
|
|
|
|
gtk_widget_grab_focus(wid);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2009-09-27 10:51:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
on_go_to_line_activate(NULL, NULL);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2009-09-21 17:11:42 +00:00
|
|
|
}
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_MATCHINGBRACE:
|
2008-06-15 13:35:48 +00:00
|
|
|
goto_matching_brace(doc);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_TOGGLEMARKER:
|
2007-05-05 16:35:59 +00:00
|
|
|
{
|
2009-09-12 17:39:49 +00:00
|
|
|
sci_toggle_marker_at_line(doc->editor->sci, cur_line, 1);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_NEXTMARKER:
|
2007-05-05 16:35:59 +00:00
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
gint mline = sci_marker_next(doc->editor->sci, cur_line + 1, 1 << 1, TRUE);
|
2007-05-05 16:35:59 +00:00
|
|
|
|
|
|
|
if (mline != -1)
|
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_set_current_line(doc->editor->sci, mline);
|
2008-07-08 13:53:08 +00:00
|
|
|
editor_display_current_line(doc->editor, 0.5F);
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_PREVIOUSMARKER:
|
2007-05-05 16:35:59 +00:00
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
gint mline = sci_marker_previous(doc->editor->sci, cur_line - 1, 1 << 1, TRUE);
|
2007-05-05 16:35:59 +00:00
|
|
|
|
|
|
|
if (mline != -1)
|
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_set_current_line(doc->editor->sci, mline);
|
2008-07-08 13:53:08 +00:00
|
|
|
editor_display_current_line(doc->editor, 0.5F);
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_TAGDEFINITION:
|
2009-09-16 12:13:50 +00:00
|
|
|
goto_tag(doc, TRUE);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_GOTO_TAGDECLARATION:
|
2009-09-16 12:13:50 +00:00
|
|
|
goto_tag(doc, FALSE);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-07-02 11:58:01 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
/* only check editor-sensitive keybindings when editor has focus so home,end still
|
|
|
|
* work in other widgets */
|
2008-07-14 11:13:54 +00:00
|
|
|
if (gtk_window_get_focus(GTK_WINDOW(main_widgets.window)) != GTK_WIDGET(doc->editor->sci))
|
2009-10-12 11:50:45 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2008-07-02 11:58:01 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-06-27 17:54:36 +00:00
|
|
|
case GEANY_KEYS_GOTO_LINESTART:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, editor_prefs.smart_home_key ? SCI_VCHOME : SCI_HOME);
|
2008-06-27 17:54:36 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_GOTO_LINEEND:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_LINEEND);
|
2008-06-27 17:54:36 +00:00
|
|
|
break;
|
2009-06-29 19:46:49 +00:00
|
|
|
case GEANY_KEYS_GOTO_LINEENDVISUAL:
|
|
|
|
sci_send_command(doc->editor->sci, SCI_LINEENDDISPLAY);
|
|
|
|
break;
|
2009-10-20 15:45:07 +00:00
|
|
|
case GEANY_KEYS_GOTO_PREVWORDPART:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_WORDPARTLEFT);
|
2008-09-26 18:29:42 +00:00
|
|
|
break;
|
2009-10-20 15:45:07 +00:00
|
|
|
case GEANY_KEYS_GOTO_NEXTWORDPART:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_WORDPARTRIGHT);
|
2008-09-26 18:29:42 +00:00
|
|
|
break;
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-05-05 16:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
static void duplicate_lines(GeanyEditor *editor)
|
2007-09-21 16:39:21 +00:00
|
|
|
{
|
2008-09-25 18:28:37 +00:00
|
|
|
if (sci_get_lines_selected(editor->sci) > 1)
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* ignore extra_line because of selecting lines from the line number column */
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_select_lines(editor, FALSE);
|
|
|
|
sci_selection_duplicate(editor->sci);
|
2007-09-21 16:39:21 +00:00
|
|
|
}
|
2008-09-25 18:28:37 +00:00
|
|
|
else if (sci_has_selection(editor->sci))
|
|
|
|
sci_selection_duplicate(editor->sci);
|
2007-09-21 16:39:21 +00:00
|
|
|
else
|
2008-09-25 18:28:37 +00:00
|
|
|
sci_line_duplicate(editor->sci);
|
2007-09-21 16:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
static void delete_lines(GeanyEditor *editor)
|
2007-09-22 11:11:24 +00:00
|
|
|
{
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_select_lines(editor, TRUE); /* include last line (like cut lines, copy lines do) */
|
|
|
|
sci_clear(editor->sci); /* (SCI_LINEDELETE only does 1 line) */
|
2007-09-22 11:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-22 11:28:59 +00:00
|
|
|
static void move_lines(GeanyEditor *editor, gboolean down)
|
|
|
|
{
|
|
|
|
ScintillaObject *sci = editor->sci;
|
|
|
|
gchar *text;
|
|
|
|
gint pos, line, len;
|
|
|
|
|
|
|
|
sci_start_undo_action(sci);
|
2009-11-05 18:11:10 +00:00
|
|
|
editor_select_lines(editor, FALSE);
|
2009-10-22 11:28:59 +00:00
|
|
|
len = sci_get_selected_text_length(sci);
|
|
|
|
|
|
|
|
pos = sci_get_selection_start(sci);
|
|
|
|
line = sci_get_line_from_position(sci, pos);
|
|
|
|
if (down)
|
|
|
|
line++;
|
|
|
|
else
|
|
|
|
line--;
|
|
|
|
|
|
|
|
text = sci_get_selection_contents(sci);
|
|
|
|
sci_clear(sci);
|
|
|
|
|
|
|
|
pos = sci_get_position_from_line(sci, line);
|
|
|
|
sci_insert_text(sci, pos, text);
|
|
|
|
g_free(text);
|
|
|
|
|
|
|
|
sci_set_current_position(sci, pos, TRUE);
|
2009-11-05 18:11:10 +00:00
|
|
|
sci_set_selection_end(sci, pos + len - 1);
|
2009-10-22 11:28:59 +00:00
|
|
|
|
|
|
|
sci_end_undo_action(sci);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* common function for editor keybindings, only valid when scintilla has focus. */
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_editor_action(guint key_id)
|
2006-09-12 08:32:52 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* edit keybindings only valid when scintilla widget has focus */
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
|
2009-10-12 11:50:45 +00:00
|
|
|
return FALSE; /* also makes tab work outside editor */
|
2006-10-26 15:22:27 +00:00
|
|
|
|
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_UNDO:
|
|
|
|
on_undo1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_EDITOR_REDO:
|
|
|
|
on_redo1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_EDITOR_SCROLLTOLINE:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_scroll_to_line(doc->editor, -1, 0.5F);
|
2007-07-17 16:27:49 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_SCROLLLINEUP:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_LINESCROLLUP);
|
2007-09-05 18:55:51 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_SCROLLLINEDOWN:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_LINESCROLLDOWN);
|
2007-09-05 18:55:51 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_DUPLICATELINE:
|
2008-09-25 18:28:37 +00:00
|
|
|
duplicate_lines(doc->editor);
|
2006-10-26 15:22:27 +00:00
|
|
|
break;
|
2009-01-18 18:19:09 +00:00
|
|
|
case GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR:
|
2009-09-14 17:28:07 +00:00
|
|
|
editor_goto_next_snippet_cursor(doc->editor);
|
2009-01-11 21:05:03 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_DELETELINE:
|
2008-09-25 18:28:37 +00:00
|
|
|
delete_lines(doc->editor);
|
2007-08-10 11:29:37 +00:00
|
|
|
break;
|
2009-06-29 19:46:49 +00:00
|
|
|
case GEANY_KEYS_EDITOR_DELETELINETOEND:
|
|
|
|
sci_send_command(doc->editor->sci, SCI_DELLINERIGHT);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_TRANSPOSELINE:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_LINETRANSPOSE);
|
2007-07-07 15:12:13 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_AUTOCOMPLETE:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_start_auto_complete(doc->editor, sci_get_current_position(doc->editor->sci), TRUE);
|
2006-10-26 15:22:27 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_CALLTIP:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_show_calltip(doc->editor, -1);
|
2006-10-26 15:22:27 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_MACROLIST:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_show_macro_list(doc->editor);
|
2006-10-26 15:22:27 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_CONTEXTACTION:
|
2009-04-05 21:07:40 +00:00
|
|
|
if (check_current_word(doc))
|
2008-12-18 21:21:53 +00:00
|
|
|
on_context_action1_activate(GTK_MENU_ITEM(ui_lookup_widget(main_widgets.editor_menu,
|
2008-03-12 13:37:39 +00:00
|
|
|
"context_action1")), NULL);
|
2007-03-22 15:51:39 +00:00
|
|
|
break;
|
2009-10-12 11:50:45 +00:00
|
|
|
case GEANY_KEYS_EDITOR_COMPLETESNIPPET:
|
|
|
|
/* allow tab to be overloaded */
|
|
|
|
return check_snippet_completion(doc);
|
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION:
|
|
|
|
{
|
2008-08-08 18:05:53 +00:00
|
|
|
GeanyKeyBinding *kb = keybindings_lookup_item(GEANY_KEY_GROUP_EDITOR,
|
2008-03-12 13:37:39 +00:00
|
|
|
GEANY_KEYS_EDITOR_COMPLETESNIPPET);
|
2007-03-27 15:48:16 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
switch (kb->key)
|
2007-03-27 15:48:16 +00:00
|
|
|
{
|
|
|
|
case GDK_space:
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_add_text(doc->editor->sci, " ");
|
2007-03-27 15:48:16 +00:00
|
|
|
break;
|
|
|
|
case GDK_Tab:
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(doc->editor->sci, SCI_TAB);
|
2007-03-27 15:48:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-10-26 15:22:27 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
}
|
2009-10-20 15:35:44 +00:00
|
|
|
case GEANY_KEYS_EDITOR_WORDPARTCOMPLETION:
|
|
|
|
return editor_complete_word_part(doc->editor);
|
2009-10-22 11:28:59 +00:00
|
|
|
|
|
|
|
case GEANY_KEYS_EDITOR_MOVELINEUP:
|
|
|
|
move_lines(doc->editor, FALSE);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_EDITOR_MOVELINEDOWN:
|
|
|
|
move_lines(doc->editor, TRUE);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
}
|
2007-03-27 15:48:16 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
|
2009-07-24 15:44:14 +00:00
|
|
|
static void join_lines(GeanyEditor *editor)
|
|
|
|
{
|
|
|
|
gint start, end, i;
|
|
|
|
|
|
|
|
start = sci_get_line_from_position(editor->sci,
|
|
|
|
sci_get_selection_start(editor->sci));
|
|
|
|
end = sci_get_line_from_position(editor->sci,
|
|
|
|
sci_get_selection_end(editor->sci));
|
|
|
|
|
|
|
|
/* if there is only one line in selection, join it with the following one */
|
|
|
|
if (end == start)
|
|
|
|
end = start + 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove trailing spaces for every line except the last one
|
|
|
|
* so that these spaces won't appear within text after joining
|
|
|
|
*/
|
|
|
|
for (i = start; i < end; i++)
|
|
|
|
editor_strip_line_trailing_spaces(editor, i);
|
|
|
|
|
|
|
|
/* remove starting spaces from second and following lines due to the same reason */
|
2009-09-16 14:13:38 +00:00
|
|
|
for (i = start + 1; i <= end; i++)
|
2009-07-24 15:44:14 +00:00
|
|
|
sci_set_line_indentation(editor->sci, i, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCI_LINESJOIN automatically adds spaces between joined lines, including
|
|
|
|
* empty ones. We should drop empty lines if we want only one space to be
|
|
|
|
* inserted (see also example below). I don't think we should care of that.
|
|
|
|
*/
|
|
|
|
|
2009-07-29 17:54:48 +00:00
|
|
|
sci_set_target_start(editor->sci,
|
2009-07-24 15:44:14 +00:00
|
|
|
sci_get_position_from_line(editor->sci, start));
|
2009-07-29 17:54:48 +00:00
|
|
|
sci_set_target_end(editor->sci,
|
2009-07-24 15:44:14 +00:00
|
|
|
sci_get_position_from_line(editor->sci, end));
|
|
|
|
sci_lines_join(editor->sci);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Example: joining
|
|
|
|
*
|
|
|
|
* [TAB]if (something_wrong)
|
|
|
|
* [TAB]{
|
|
|
|
* [TAB][TAB]
|
|
|
|
* [TAB][TAB]exit(1);[SPACE][SPACE]
|
|
|
|
* [TAB]}[SPACE]
|
|
|
|
*
|
|
|
|
* gives
|
|
|
|
*
|
|
|
|
* [TAB]if (something_wrong) { exit(1); }[SPACE]
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-24 11:26:59 +00:00
|
|
|
static void split_lines(GeanyEditor *editor, gint column)
|
2009-07-24 15:44:14 +00:00
|
|
|
{
|
2009-10-14 11:46:56 +00:00
|
|
|
gint start, indent, linescount, i, end;
|
|
|
|
gchar c;
|
|
|
|
ScintillaObject *sci = editor->sci;
|
|
|
|
|
|
|
|
/* don't include trailing newlines */
|
|
|
|
end = sci_get_selection_end(sci);
|
|
|
|
while ((c = sci_get_char_at(sci, end - 1)) == '\n' || c == '\r') end--;
|
|
|
|
sci_set_selection_end(sci, end);
|
2009-07-24 15:44:14 +00:00
|
|
|
|
|
|
|
start = sci_get_line_from_position(editor->sci,
|
|
|
|
sci_get_selection_start(editor->sci));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If several lines are selected, first join them.
|
|
|
|
* This allows to reformat text paragraphs easily.
|
|
|
|
*/
|
|
|
|
if (sci_get_lines_selected(editor->sci) > 1)
|
|
|
|
join_lines(editor);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this line is short enough, just return
|
|
|
|
*/
|
2009-09-24 11:26:59 +00:00
|
|
|
if (column > sci_get_line_end_position(editor->sci, start) -
|
2009-07-24 15:44:14 +00:00
|
|
|
sci_get_position_from_line(editor->sci, start))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to manipulate line indentation so that indentation
|
|
|
|
* of the resulting lines would be consistent. For example,
|
|
|
|
* the result of splitting "[TAB]very long content":
|
|
|
|
*
|
|
|
|
* +-------------+-------------+
|
|
|
|
* | proper | wrong |
|
|
|
|
* +-------------+-------------+
|
|
|
|
* | [TAB]very | [TAB]very |
|
|
|
|
* | [TAB]long | long |
|
|
|
|
* | [TAB]content| content |
|
|
|
|
* +-------------+-------------+
|
|
|
|
*/
|
|
|
|
indent = sci_get_line_indentation(editor->sci, start);
|
|
|
|
sci_set_line_indentation(editor->sci, start, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use sci_get_line_count() to determine how many new lines
|
|
|
|
* appeared during splitting. SCI_LINESSPLIT should better return
|
|
|
|
* this value itself...
|
|
|
|
*/
|
|
|
|
sci_target_from_selection(editor->sci);
|
|
|
|
linescount = sci_get_line_count(editor->sci);
|
|
|
|
sci_lines_split(editor->sci,
|
2009-09-24 11:26:59 +00:00
|
|
|
(column - indent) * sci_text_width(editor->sci, STYLE_DEFAULT, " "));
|
2009-07-24 15:44:14 +00:00
|
|
|
linescount = sci_get_line_count(editor->sci) - linescount;
|
|
|
|
|
|
|
|
/* Fix indentation. */
|
|
|
|
for (i = start; i <= start + linescount; i++)
|
|
|
|
sci_set_line_indentation(editor->sci, i, indent);
|
2010-02-13 16:30:09 +00:00
|
|
|
|
|
|
|
/* Remove trailing spaces. */
|
|
|
|
if (editor_prefs.newline_strip || file_prefs.strip_trailing_spaces)
|
|
|
|
{
|
|
|
|
for (i = start; i <= start + linescount; i++)
|
|
|
|
editor_strip_line_trailing_spaces(editor, i);
|
|
|
|
}
|
2009-07-24 15:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-12 15:46:05 +00:00
|
|
|
/* if cursor < anchor, swap them */
|
|
|
|
static void sci_fix_selection(ScintillaObject *sci)
|
|
|
|
{
|
|
|
|
gint start, end;
|
|
|
|
|
|
|
|
start = sci_get_selection_start(sci);
|
|
|
|
end = sci_get_selection_end(sci);
|
|
|
|
sci_set_selection(sci, start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-24 15:44:14 +00:00
|
|
|
static void reflow_paragraph(GeanyEditor *editor)
|
|
|
|
{
|
|
|
|
ScintillaObject *sci = editor->sci;
|
|
|
|
gboolean sel;
|
2009-09-24 11:26:59 +00:00
|
|
|
gint column = -1;
|
2009-07-24 15:44:14 +00:00
|
|
|
|
2009-09-24 11:26:59 +00:00
|
|
|
if (editor->line_breaking)
|
|
|
|
{
|
|
|
|
/* use line break column if enabled */
|
|
|
|
column = editor_prefs.line_break_column;
|
|
|
|
}
|
2010-03-10 16:20:34 +00:00
|
|
|
else if (editor_get_long_line_type() != 2)
|
2009-09-24 11:26:59 +00:00
|
|
|
{
|
|
|
|
/* use long line if enabled */
|
2010-03-10 16:20:34 +00:00
|
|
|
column = editor_get_long_line_column();
|
2009-09-24 11:26:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* do nothing if no column is defined */
|
|
|
|
utils_beep();
|
|
|
|
return;
|
|
|
|
}
|
2009-07-24 15:44:14 +00:00
|
|
|
sci_start_undo_action(sci);
|
|
|
|
sel = sci_has_selection(sci);
|
|
|
|
if (!sel)
|
|
|
|
{
|
|
|
|
gint line, pos;
|
|
|
|
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_PARAGRAPH);
|
|
|
|
/* deselect last line break */
|
|
|
|
pos = sci_get_selection_end(sci);
|
|
|
|
line = sci_get_line_from_position(sci, pos);
|
2009-09-13 11:23:14 +00:00
|
|
|
if (line < sci_get_line_count(sci) - 1)
|
|
|
|
{
|
|
|
|
/* not last line */
|
|
|
|
pos = sci_get_line_end_position(sci, line - 1);
|
|
|
|
sci_set_selection_end(sci, pos);
|
|
|
|
}
|
2009-07-24 15:44:14 +00:00
|
|
|
}
|
2009-11-12 15:46:05 +00:00
|
|
|
sci_fix_selection(sci);
|
2009-09-24 11:26:59 +00:00
|
|
|
split_lines(editor, column);
|
2009-07-24 15:44:14 +00:00
|
|
|
if (!sel)
|
|
|
|
sci_set_anchor(sci, -1);
|
2009-09-24 11:26:59 +00:00
|
|
|
|
2009-07-24 15:44:14 +00:00
|
|
|
sci_end_undo_action(sci);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* common function for format keybindings, only valid when scintilla has focus. */
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_format_action(guint key_id)
|
2008-03-12 13:37:39 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2008-03-12 13:37:39 +00:00
|
|
|
|
|
|
|
/* keybindings only valid when scintilla widget has focus */
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
|
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_FORMAT_COMMENTLINETOGGLE:
|
|
|
|
on_menu_toggle_line_commentation1_activate(NULL, NULL);
|
2007-07-07 15:12:13 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_COMMENTLINE:
|
|
|
|
on_menu_comment_line1_activate(NULL, NULL);
|
2007-07-06 10:16:51 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_UNCOMMENTLINE:
|
|
|
|
on_menu_uncomment_line1_activate(NULL, NULL);
|
2007-03-25 20:51:45 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_INCREASEINDENT:
|
2006-10-26 15:22:27 +00:00
|
|
|
on_menu_increase_indent1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_DECREASEINDENT:
|
2006-10-26 15:22:27 +00:00
|
|
|
on_menu_decrease_indent1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_indentation_by_one_space(doc->editor, -1, FALSE);
|
2007-07-16 15:42:12 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_indentation_by_one_space(doc->editor, -1, TRUE);
|
2007-07-16 15:42:12 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_AUTOINDENT:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_smart_line_indentation(doc->editor, -1);
|
2007-07-16 15:42:12 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_TOGGLECASE:
|
2007-09-07 19:01:55 +00:00
|
|
|
on_toggle_case1_activate(NULL, NULL);
|
2006-10-26 15:22:27 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_SENDTOCMD1:
|
2007-08-23 11:34:06 +00:00
|
|
|
if (ui_prefs.custom_commands && g_strv_length(ui_prefs.custom_commands) > 0)
|
2008-06-15 13:35:48 +00:00
|
|
|
tools_execute_custom_command(doc, ui_prefs.custom_commands[0]);
|
2007-02-25 14:26:55 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_SENDTOCMD2:
|
2007-08-23 11:34:06 +00:00
|
|
|
if (ui_prefs.custom_commands && g_strv_length(ui_prefs.custom_commands) > 1)
|
2008-06-15 13:35:48 +00:00
|
|
|
tools_execute_custom_command(doc, ui_prefs.custom_commands[1]);
|
2007-02-25 14:26:55 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_FORMAT_SENDTOCMD3:
|
2007-08-23 11:34:06 +00:00
|
|
|
if (ui_prefs.custom_commands && g_strv_length(ui_prefs.custom_commands) > 2)
|
2008-06-15 13:35:48 +00:00
|
|
|
tools_execute_custom_command(doc, ui_prefs.custom_commands[2]);
|
2007-02-25 14:26:55 +00:00
|
|
|
break;
|
2009-02-25 23:28:01 +00:00
|
|
|
case GEANY_KEYS_FORMAT_SENDTOVTE:
|
|
|
|
on_send_selection_to_vte1_activate(NULL, NULL);
|
|
|
|
break;
|
2009-07-24 15:44:14 +00:00
|
|
|
case GEANY_KEYS_FORMAT_REFLOWPARAGRAPH:
|
|
|
|
reflow_paragraph(doc->editor);
|
|
|
|
break;
|
2006-10-26 15:22:27 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-09-12 08:32:52 +00:00
|
|
|
}
|
|
|
|
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* common function for select keybindings, only valid when scintilla has focus. */
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_select_action(guint key_id)
|
2006-09-12 08:32:52 +00:00
|
|
|
{
|
2009-04-05 21:07:40 +00:00
|
|
|
GeanyDocument *doc;
|
2009-10-20 16:01:07 +00:00
|
|
|
ScintillaObject *sci;
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2010-02-13 16:13:00 +00:00
|
|
|
GtkWidget *toolbar_search_entry = toolbar_get_widget_child_by_name("SearchEntry");
|
|
|
|
GtkWidget *toolbar_goto_entry = toolbar_get_widget_child_by_name("GotoEntry");
|
2008-04-27 15:43:47 +00:00
|
|
|
|
|
|
|
/* special case for Select All in the scribble widget */
|
2009-12-20 20:07:04 +00:00
|
|
|
if (key_id == GEANY_KEYS_SELECT_ALL && focusw == msgwindow.scribble)
|
2008-04-27 15:43:47 +00:00
|
|
|
{
|
2009-12-20 20:07:04 +00:00
|
|
|
g_signal_emit_by_name(msgwindow.scribble, "select-all", TRUE);
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-04-27 15:43:47 +00:00
|
|
|
}
|
2010-07-29 18:28:37 +00:00
|
|
|
/* special case for Select All in the VTE widget */
|
|
|
|
#ifdef HAVE_VTE
|
|
|
|
else if (key_id == GEANY_KEYS_SELECT_ALL && vte_info.load_vte && focusw == vc->vte)
|
|
|
|
{
|
|
|
|
vte_select_all();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
2010-02-13 16:13:00 +00:00
|
|
|
/* special case for Select All in the toolbar search widget */
|
|
|
|
else if (key_id == GEANY_KEYS_SELECT_ALL && focusw == toolbar_search_entry)
|
|
|
|
{
|
|
|
|
gtk_editable_select_region(GTK_EDITABLE(toolbar_search_entry), 0, -1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (key_id == GEANY_KEYS_SELECT_ALL && focusw == toolbar_goto_entry)
|
|
|
|
{
|
|
|
|
gtk_editable_select_region(GTK_EDITABLE(toolbar_goto_entry), 0, -1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-10-26 15:22:27 +00:00
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
doc = document_get_current();
|
2008-03-12 13:37:39 +00:00
|
|
|
/* keybindings only valid when scintilla widget has focus */
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2009-10-20 16:01:07 +00:00
|
|
|
sci = doc->editor->sci;
|
2006-12-13 00:46:14 +00:00
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
switch (key_id)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SELECT_ALL:
|
|
|
|
on_menu_select_all1_activate(NULL, NULL);
|
2008-02-29 19:30:28 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SELECT_WORD:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_select_word(doc->editor);
|
2008-02-29 19:30:28 +00:00
|
|
|
break;
|
2008-03-12 13:37:39 +00:00
|
|
|
case GEANY_KEYS_SELECT_LINE:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_select_lines(doc->editor, FALSE);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_SELECT_PARAGRAPH:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_select_paragraph(doc->editor);
|
2008-02-29 19:30:28 +00:00
|
|
|
break;
|
2009-10-20 16:01:07 +00:00
|
|
|
case GEANY_KEYS_SELECT_WORDPARTLEFT:
|
|
|
|
sci_send_command(sci, SCI_WORDPARTLEFTEXTEND);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_SELECT_WORDPARTRIGHT:
|
|
|
|
sci_send_command(sci, SCI_WORDPARTRIGHTEXTEND);
|
|
|
|
break;
|
2008-02-29 19:30:28 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2006-12-13 00:46:14 +00:00
|
|
|
}
|
2007-03-23 16:34:54 +00:00
|
|
|
|
2008-02-29 19:30:28 +00:00
|
|
|
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_document_action(guint key_id)
|
2007-06-03 16:03:46 +00:00
|
|
|
{
|
2008-06-19 15:58:10 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-10-12 11:50:45 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL)
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-06-19 15:58:10 +00:00
|
|
|
|
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_DOCUMENT_REPLACETABS:
|
|
|
|
on_replace_tabs_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_REPLACESPACES:
|
|
|
|
on_replace_spaces_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_LINEBREAK:
|
|
|
|
on_line_breaking1_activate(NULL, NULL);
|
2008-11-23 16:24:16 +00:00
|
|
|
ui_document_show_hide(doc);
|
2008-06-19 15:58:10 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_LINEWRAP:
|
|
|
|
on_line_wrapping1_toggled(NULL, NULL);
|
2008-11-23 16:24:16 +00:00
|
|
|
ui_document_show_hide(doc);
|
2008-06-19 15:58:10 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_RELOADTAGLIST:
|
|
|
|
document_update_tag_list(doc, TRUE);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_FOLDALL:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_fold_all(doc->editor);
|
2008-06-19 15:58:10 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_UNFOLDALL:
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_unfold_all(doc->editor);
|
2008-06-19 15:58:10 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_TOGGLEFOLD:
|
|
|
|
if (editor_prefs.folding)
|
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
gint line = sci_get_current_line(doc->editor->sci);
|
2010-01-24 16:30:29 +00:00
|
|
|
editor_toggle_fold(doc->editor, line, 0);
|
2008-06-19 15:58:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-04-17 14:55:14 +00:00
|
|
|
case GEANY_KEYS_DOCUMENT_REMOVE_MARKERS:
|
|
|
|
on_remove_markers1_activate(NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GEANY_KEYS_DOCUMENT_REMOVE_ERROR_INDICATORS:
|
|
|
|
on_menu_remove_indicators1_activate(NULL, NULL);
|
|
|
|
break;
|
2008-06-19 15:58:10 +00:00
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-06-03 16:03:46 +00:00
|
|
|
}
|
|
|
|
|
2006-12-13 00:46:14 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* common function for insert keybindings, only valid when scintilla has focus. */
|
2009-10-12 11:50:45 +00:00
|
|
|
static gboolean cb_func_insert_action(guint key_id)
|
2007-06-03 16:03:46 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2007-06-03 16:03:46 +00:00
|
|
|
|
2008-03-12 13:37:39 +00:00
|
|
|
/* keybindings only valid when scintilla widget has focus */
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2008-03-12 13:37:39 +00:00
|
|
|
|
|
|
|
switch (key_id)
|
|
|
|
{
|
|
|
|
case GEANY_KEYS_INSERT_ALTWHITESPACE:
|
2008-07-08 13:53:08 +00:00
|
|
|
editor_insert_alternative_whitespace(doc->editor);
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
|
|
|
case GEANY_KEYS_INSERT_DATE:
|
2009-01-26 18:21:53 +00:00
|
|
|
gtk_menu_item_activate(GTK_MENU_ITEM(
|
|
|
|
ui_lookup_widget(main_widgets.window, "insert_date_custom1")));
|
2008-03-12 13:37:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-10-12 11:50:45 +00:00
|
|
|
return TRUE;
|
2007-06-03 16:03:46 +00:00
|
|
|
}
|
2007-07-18 15:35:52 +00:00
|
|
|
|
2009-08-18 13:57:07 +00:00
|
|
|
|
|
|
|
/* update key combination */
|
|
|
|
void keybindings_update_combo(GeanyKeyBinding *kb, guint key, GdkModifierType mods)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = kb->menu_item;
|
|
|
|
|
|
|
|
if (widget && kb->key)
|
|
|
|
gtk_widget_remove_accelerator(widget, kb_accel_group, kb->key, kb->mods);
|
|
|
|
|
|
|
|
kb->key = key;
|
|
|
|
kb->mods = mods;
|
|
|
|
|
|
|
|
if (widget && kb->key)
|
|
|
|
gtk_widget_add_accelerator(widget, "activate", kb_accel_group,
|
|
|
|
kb->key, kb->mods, GTK_ACCEL_VISIBLE);
|
|
|
|
}
|
|
|
|
|
2009-08-25 16:55:56 +00:00
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
/* used for plugins, can be called repeatedly. */
|
2009-08-25 16:55:56 +00:00
|
|
|
GeanyKeyGroup *keybindings_set_group(GeanyKeyGroup *group, const gchar *section_name,
|
|
|
|
const gchar *label, gsize count, GeanyKeyGroupCallback callback)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail(section_name, NULL);
|
|
|
|
g_return_val_if_fail(count, NULL);
|
|
|
|
|
|
|
|
/* prevent conflict with core bindings */
|
|
|
|
g_return_val_if_fail(!g_str_equal(section_name, keybindings_keyfile_group_name), NULL);
|
|
|
|
|
|
|
|
if (!group)
|
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
group = g_new0(GeanyKeyGroup, 1);
|
|
|
|
add_kb_group(group, section_name, label, callback, TRUE);
|
2009-08-25 16:55:56 +00:00
|
|
|
}
|
2010-08-10 12:43:30 +00:00
|
|
|
g_free(group->plugin_keys);
|
|
|
|
group->plugin_keys = g_new0(GeanyKeyBinding, count);
|
|
|
|
group->plugin_key_count = count;
|
|
|
|
g_ptr_array_set_size(group->key_items, 0);
|
2009-08-25 16:55:56 +00:00
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void keybindings_free_group(GeanyKeyGroup *group)
|
|
|
|
{
|
|
|
|
GeanyKeyBinding *kb;
|
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
g_ptr_array_free(group->key_items, TRUE);
|
2009-08-25 16:55:56 +00:00
|
|
|
|
2010-08-10 12:43:30 +00:00
|
|
|
if (group->plugin)
|
2009-08-25 16:55:56 +00:00
|
|
|
{
|
2010-08-10 12:43:30 +00:00
|
|
|
foreach_c_array(kb, group->plugin_keys, group->plugin_key_count)
|
|
|
|
{
|
|
|
|
g_free(kb->name);
|
|
|
|
g_free(kb->label);
|
|
|
|
}
|
|
|
|
g_free(group->plugin_keys);
|
|
|
|
g_ptr_array_remove_fast(keybinding_groups, group);
|
|
|
|
g_free(group);
|
2009-08-25 16:55:56 +00:00
|
|
|
}
|
|
|
|
}
|