Skip to content

Commit

Permalink
Add secondary actions for cut, copy, paste, zoom in/out
Browse files Browse the repository at this point in the history
  • Loading branch information
xiota committed Oct 28, 2021
1 parent 718a867 commit 24c9852
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/geany.txt
Expand Up @@ -3324,6 +3324,9 @@ The following tables list all customizable keyboard shortcuts, those
which are common to many applications are marked with (C) after the
shortcut.

Some actions are listed twice in the Preferences dialog to allow a
secondary keybinding to be set.

File keybindings
````````````````
=============================== ========================= ==================================================
Expand Down Expand Up @@ -3675,6 +3678,7 @@ Toggle all additional widgets Hide and show all addi
and the status bar.

Zoom In Ctrl-+ (C) Zooms in the text.
Ctrl-= (C)

Zoom Out Ctrl-- (C) Zooms out the text.

Expand Down
Empty file added po/.intltool-merge-cache.lock
Empty file.
25 changes: 24 additions & 1 deletion src/keybindings.c
Expand Up @@ -437,6 +437,14 @@ static void init_default_kb(void)
GDK_KEY_x, GEANY_PRIMARY_MOD_MASK | GDK_SHIFT_MASK, "edit_cutline", _("Cu_t Current Line(s)"),
"cut_current_lines1");

/* Second set of keybindings for cut/copy/paste */
add_kb(group, GEANY_KEYS_CLIPBOARD_CUT_II, NULL,
NULL, NULL, "menu_cut", _("Cut"), "menu_cut1");
add_kb(group, GEANY_KEYS_CLIPBOARD_COPY_II, NULL,
NULL, NULL, "menu_copy", _("Copy"), "menu_copy1");
add_kb(group, GEANY_KEYS_CLIPBOARD_PASTE_II, NULL,
NULL, NULL, "menu_paste", _("Paste"), "menu_paste1");

group = keybindings_get_core_group(GEANY_KEY_GROUP_SELECT);

add_kb(group, GEANY_KEYS_SELECT_ALL, NULL,
Expand Down Expand Up @@ -608,13 +616,23 @@ static void init_default_kb(void)
"menu_show_messages_window1");
add_kb(group, GEANY_KEYS_VIEW_SIDEBAR, NULL,
0, 0, "toggle_sidebar", _("Toggle Sidebar"), "menu_show_sidebar1");

add_kb(group, GEANY_KEYS_VIEW_ZOOMIN, NULL,
GDK_KEY_equal, GEANY_PRIMARY_MOD_MASK, "menu_zoomin", _("Zoom In"), "menu_zoom_in1");
GDK_KEY_plus, GEANY_PRIMARY_MOD_MASK, "menu_zoomin", _("Zoom In"), "menu_zoom_in1");
add_kb(group, GEANY_KEYS_VIEW_ZOOMOUT, NULL,
GDK_KEY_minus, GEANY_PRIMARY_MOD_MASK, "menu_zoomout", _("Zoom Out"), "menu_zoom_out1");
add_kb(group, GEANY_KEYS_VIEW_ZOOMRESET, NULL,
GDK_KEY_0, GEANY_PRIMARY_MOD_MASK, "normal_size", _("Zoom Reset"), "normal_size1");

/* Note: There are two zoom-in keybindings because some operating systems
* and keyboard layouts cannot access one or the other keybinding.
* Chromium and Firefox also recognize both keybindings.
* A second zoom-out keybinding is provided for symmetry. */
add_kb(group, GEANY_KEYS_VIEW_ZOOMIN_II, NULL,
GDK_KEY_equal, GEANY_PRIMARY_MOD_MASK, "menu_zoomin", _("Zoom In"), "menu_zoom_in1");
add_kb(group, GEANY_KEYS_VIEW_ZOOMOUT_II, NULL,
NULL, NULL, "menu_zoomout", _("Zoom Out"), "menu_zoom_out1");

group = keybindings_get_core_group(GEANY_KEY_GROUP_FOCUS);

add_kb(group, GEANY_KEYS_FOCUS_EDITOR, NULL,
Expand Down Expand Up @@ -1623,9 +1641,11 @@ static gboolean cb_func_view_action(guint key_id)
on_menu_show_sidebar1_toggled(NULL, NULL);
break;
case GEANY_KEYS_VIEW_ZOOMIN:
case GEANY_KEYS_VIEW_ZOOMIN_II:
on_zoom_in1_activate(NULL, NULL);
break;
case GEANY_KEYS_VIEW_ZOOMOUT:
case GEANY_KEYS_VIEW_ZOOMOUT_II:
on_zoom_out1_activate(NULL, NULL);
break;
case GEANY_KEYS_VIEW_ZOOMRESET:
Expand Down Expand Up @@ -1942,12 +1962,15 @@ static gboolean cb_func_clipboard_action(guint key_id)
switch (key_id)
{
case GEANY_KEYS_CLIPBOARD_CUT:
case GEANY_KEYS_CLIPBOARD_CUT_II:
on_cut1_activate(NULL, NULL);
break;
case GEANY_KEYS_CLIPBOARD_COPY:
case GEANY_KEYS_CLIPBOARD_COPY_II:
on_copy1_activate(NULL, NULL);
break;
case GEANY_KEYS_CLIPBOARD_PASTE:
case GEANY_KEYS_CLIPBOARD_PASTE_II:
on_paste1_activate(NULL, NULL);
break;
case GEANY_KEYS_CLIPBOARD_COPYLINE:
Expand Down
5 changes: 5 additions & 0 deletions src/keybindings.h
Expand Up @@ -277,6 +277,11 @@ enum GeanyKeyBindingID
* @since 1.34 (API 238) */
GEANY_KEYS_FILE_RELOAD_ALL, /**< Keybinding.
* @since 1.38 (API 240) */
GEANY_KEYS_VIEW_ZOOMIN_II, /**< Keybinding. */
GEANY_KEYS_VIEW_ZOOMOUT_II, /**< Keybinding. */
GEANY_KEYS_CLIPBOARD_CUT_II, /**< Keybinding. */
GEANY_KEYS_CLIPBOARD_COPY_II, /**< Keybinding. */
GEANY_KEYS_CLIPBOARD_PASTE_II, /**< Keybinding. */
GEANY_KEYS_COUNT /* must not be used by plugins */
};

Expand Down
2 changes: 1 addition & 1 deletion src/plugindata.h
Expand Up @@ -58,7 +58,7 @@ G_BEGIN_DECLS
* @warning You should not test for values below 200 as previously
* @c GEANY_API_VERSION was defined as an enum value, not a macro.
*/
#define GEANY_API_VERSION 240
#define GEANY_API_VERSION 241

/* hack to have a different ABI when built with different GTK major versions
* because loading plugins linked to a different one leads to crashes.
Expand Down

0 comments on commit 24c9852

Please sign in to comment.