diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-09 19:59:06 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-09 19:59:06 +0300 |
commit | 4ab25def835077e04cf6df19f4aadc7a2e9dc0d7 (patch) | |
tree | 670ff7734938c2dd9f5160638b72ad20852c24e9 /src/ui | |
parent | f0c3134aebd83de1712a66d59af9f2d414110f11 (diff) |
Added header file for keyboard shortcuts
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 5 | ||||
-rw-r--r-- | src/ui/keys.h | 37 | ||||
-rw-r--r-- | src/ui/window.c | 9 |
3 files changed, 47 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index f99280d7..6e10ff54 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -26,6 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
26 | #include "labelwidget.h" | 26 | #include "labelwidget.h" |
27 | #include "paint.h" | 27 | #include "paint.h" |
28 | #include "command.h" | 28 | #include "command.h" |
29 | #include "keys.h" | ||
29 | #include "util.h" | 30 | #include "util.h" |
30 | #include "history.h" | 31 | #include "history.h" |
31 | #include "app.h" | 32 | #include "app.h" |
@@ -245,8 +246,8 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
245 | #if !defined (iPlatformApple) /* in system menu */ | 246 | #if !defined (iPlatformApple) /* in system menu */ |
246 | addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close"); | 247 | addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close"); |
247 | #endif | 248 | #endif |
248 | addAction_Widget(w, SDLK_LEFT, KMOD_PRIMARY, "navigate.back"); | 249 | addAction_Widget(w, navigateBack_KeyShortcut, "navigate.back"); |
249 | addAction_Widget(w, SDLK_RIGHT, KMOD_PRIMARY, "navigate.forward"); | 250 | addAction_Widget(w, navigateForward_KeyShortcut, "navigate.forward"); |
250 | } | 251 | } |
251 | 252 | ||
252 | void deinit_DocumentWidget(iDocumentWidget *d) { | 253 | void deinit_DocumentWidget(iDocumentWidget *d) { |
diff --git a/src/ui/keys.h b/src/ui/keys.h new file mode 100644 index 00000000..cf6aad04 --- /dev/null +++ b/src/ui/keys.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* Copyright 2020 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
2 | |||
3 | Redistribution and use in source and binary forms, with or without | ||
4 | modification, are permitted provided that the following conditions are met: | ||
5 | |||
6 | 1. Redistributions of source code must retain the above copyright notice, this | ||
7 | list of conditions and the following disclaimer. | ||
8 | 2. Redistributions in binary form must reproduce the above copyright notice, | ||
9 | this list of conditions and the following disclaimer in the documentation | ||
10 | and/or other materials provided with the distribution. | ||
11 | |||
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
13 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
14 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
15 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
16 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
18 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
20 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
22 | |||
23 | #pragma once | ||
24 | |||
25 | #include <the_Foundation/defs.h> | ||
26 | |||
27 | #if defined (iPlatformApple) | ||
28 | # define prevTab_KeyShortcut SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY | ||
29 | # define nextTab_KeyShortcut SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY | ||
30 | # define navigateBack_KeyShortcut SDLK_LEFT, KMOD_PRIMARY | ||
31 | # define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_PRIMARY | ||
32 | #else | ||
33 | # define prevTab_KeyShortcut SDLK_PAGEUP, KMOD_PRIMARY | ||
34 | # define nextTab_KeyShortcut SDLK_PAGEDOWN, KMOD_PRIMARY | ||
35 | # define navigateBack_KeyShortcut SDLK_LEFT, KMOD_ALT | ||
36 | # define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_ALT | ||
37 | #endif | ||
diff --git a/src/ui/window.c b/src/ui/window.c index a419684c..8d76c68b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
31 | #include "command.h" | 31 | #include "command.h" |
32 | #include "paint.h" | 32 | #include "paint.h" |
33 | #include "util.h" | 33 | #include "util.h" |
34 | #include "keys.h" | ||
34 | #include "../app.h" | 35 | #include "../app.h" |
35 | #include "../visited.h" | 36 | #include "../visited.h" |
36 | #include "../gmcerts.h" | 37 | #include "../gmcerts.h" |
@@ -433,11 +434,15 @@ static void setupUserInterface_Window(iWindow *d) { | |||
433 | 6); | 434 | 6); |
434 | setId_Widget(tabsMenu, "doctabs.menu"); | 435 | setId_Widget(tabsMenu, "doctabs.menu"); |
435 | /* Global keyboard shortcuts. */ { | 436 | /* Global keyboard shortcuts. */ { |
436 | addAction_Widget(d->root, SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY, "tabs.prev"); | 437 | addAction_Widget(d->root, prevTab_KeyShortcut, "tabs.prev"); |
437 | addAction_Widget(d->root, SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY, "tabs.next"); | 438 | addAction_Widget(d->root, nextTab_KeyShortcut, "tabs.next"); |
438 | #if !defined (iHaveNativeMenus) | 439 | #if !defined (iHaveNativeMenus) |
439 | addAction_Widget(d->root, 'l', KMOD_PRIMARY, "focus.set id:url"); | 440 | addAction_Widget(d->root, 'l', KMOD_PRIMARY, "focus.set id:url"); |
440 | addAction_Widget(d->root, 'f', KMOD_PRIMARY, "focus.set id:find.input"); | 441 | addAction_Widget(d->root, 'f', KMOD_PRIMARY, "focus.set id:find.input"); |
442 | addAction_Widget(d->root, '1', KMOD_PRIMARY, "sidebar.mode arg:0 toggle:1"); | ||
443 | addAction_Widget(d->root, '2', KMOD_PRIMARY, "sidebar.mode arg:1 toggle:1"); | ||
444 | addAction_Widget(d->root, '3', KMOD_PRIMARY, "sidebar.mode arg:2 toggle:1"); | ||
445 | addAction_Widget(d->root, '4', KMOD_PRIMARY, "sidebar.mode arg:3 toggle:1"); | ||
441 | #endif | 446 | #endif |
442 | } | 447 | } |
443 | } | 448 | } |