From fbdb0a92a6107fc21ffcd4be6a413a6c34167c52 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 10 Sep 2020 10:40:53 +0300 Subject: Linux: Tweaking shortcut keys --- src/ui/documentwidget.c | 7 ++++--- src/ui/inputwidget.c | 9 +++++---- src/ui/keys.h | 6 ++++++ src/ui/window.c | 14 +++++++------- 4 files changed, 22 insertions(+), 14 deletions(-) (limited to 'src/ui') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 3e81b418..f5672c42 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -244,6 +244,7 @@ void init_DocumentWidget(iDocumentWidget *d) { addChild_Widget(w, iClob(d->scroll = new_ScrollWidget())); d->menu = NULL; /* created when clicking */ #if !defined (iPlatformApple) /* in system menu */ + addAction_Widget(w, reload_KeyShortcut, "navigate.reload"); addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close"); #endif addAction_Widget(w, navigateBack_KeyShortcut, "navigate.back"); @@ -1453,9 +1454,9 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e pushBackN_Array( &items, (iMenuItem[]){ - { "Go Back", SDLK_LEFT, KMOD_PRIMARY, "navigate.back" }, - { "Go Forward", SDLK_RIGHT, KMOD_PRIMARY, "navigate.forward" }, - { "Reload Page", 0, 0, "navigate.reload" }, + { "Go Back", navigateBack_KeyShortcut, "navigate.back" }, + { "Go Forward", navigateForward_KeyShortcut, "navigate.forward" }, + { "Reload Page", reload_KeyShortcut, "navigate.reload" }, { "---", 0, 0, NULL }, { d->contextLink ? "Copy Link URL" : "Copy Page URL", 0, diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 8151b759..11098c80 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c @@ -23,6 +23,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "inputwidget.h" #include "paint.h" #include "util.h" +#include "keys.h" #include "app.h" #include @@ -539,7 +540,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { deleteMarked_InputWidget_(d); contentsWereChanged_InputWidget_(d); } - else if (mods & KMOD_ALT) { + else if (mods & byWord_KeyModifier) { pushUndo_InputWidget_(d); d->mark.start = d->cursor; d->mark.end = skipWord_InputWidget_(d, d->cursor, -1); @@ -562,7 +563,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { deleteMarked_InputWidget_(d); contentsWereChanged_InputWidget_(d); } - else if (mods & KMOD_ALT) { + else if (mods & byWord_KeyModifier) { pushUndo_InputWidget_(d); d->mark.start = d->cursor; d->mark.end = skipWord_InputWidget_(d, d->cursor, +1); @@ -621,10 +622,10 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { case SDLK_LEFT: case SDLK_RIGHT: { const int dir = (key == SDLK_LEFT ? -1 : +1); - if (mods & KMOD_PRIMARY) { + if (mods & byLine_KeyModifier) { setCursor_InputWidget(d, dir < 0 ? 0 : curMax); } - else if (mods & KMOD_ALT) { + else if (mods & byWord_KeyModifier) { setCursor_InputWidget(d, skipWord_InputWidget_(d, d->cursor, dir)); } else if (!isMarking_() && !isEmpty_Range(&d->mark)) { diff --git a/src/ui/keys.h b/src/ui/keys.h index cf6aad04..a9b13df3 100644 --- a/src/ui/keys.h +++ b/src/ui/keys.h @@ -25,13 +25,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #if defined (iPlatformApple) +# define reload_KeyShortcut SDLK_r, KMOD_PRIMARY # define prevTab_KeyShortcut SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY # define nextTab_KeyShortcut SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY # define navigateBack_KeyShortcut SDLK_LEFT, KMOD_PRIMARY # define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_PRIMARY +# define byWord_KeyModifier KMOD_ALT +# define byLine_KeyModifier KMOD_PRIMARY #else +# define reload_KeyShortcut SDLK_r, KMOD_PRIMARY # define prevTab_KeyShortcut SDLK_PAGEUP, KMOD_PRIMARY # define nextTab_KeyShortcut SDLK_PAGEDOWN, KMOD_PRIMARY # define navigateBack_KeyShortcut SDLK_LEFT, KMOD_ALT # define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_ALT +# define byWord_KeyModifier KMOD_CTRL +# define byLine_KeyModifier 0 #endif diff --git a/src/ui/window.c b/src/ui/window.c index ea4d81ec..1eb0161b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -138,9 +138,9 @@ static const iMenuItem viewMenuItems[] = { { "Show Page Outline", '4', KMOD_PRIMARY, "sidebar.mode arg:3 toggle:1" }, { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, { "---", 0, 0, NULL }, - { "Go Back", SDLK_LEFTBRACKET, KMOD_PRIMARY, "navigate.back" }, - { "Go Forward", SDLK_RIGHTBRACKET, KMOD_PRIMARY, "navigate.forward" }, - { "Reload Page", 'r', KMOD_PRIMARY, "navigate.reload" }, + { "Go Back", navigateBack_KeyShortcut, "navigate.back" }, + { "Go Forward", navigateForward_KeyShortcut, "navigate.forward" }, + { "Reload Page", reload_KeyShortcut, "navigate.reload" }, { "---", 0, 0, NULL }, { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" }, { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" }, @@ -405,7 +405,7 @@ static void setupUserInterface_Window(iWindow *d) { addChildPos_Widget(content, iClob(sidebar), front_WidgetAddPos); } /* Search bar. */ { - iWidget *searchBar = new_Widget(); + iWidget *searchBar = new_Widget(); setId_Widget(searchBar, "search"); setFlags_Widget(searchBar, hidden_WidgetFlag | collapse_WidgetFlag | arrangeHeight_WidgetFlag | @@ -483,7 +483,7 @@ void init_Window(iWindow *d, iRect rect) { d->isDrawFrozen = iTrue; uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; #if defined (ENABLE_SWRENDER) - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); #elif defined (iPlatformApple) SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); #else @@ -499,7 +499,7 @@ void init_Window(iWindow *d, iRect rect) { SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); } SDL_SetWindowMinimumSize(d->win, 400, 250); - SDL_SetWindowTitle(d->win, "Lagrange"); + SDL_SetWindowTitle(d->win, "Lagrange"); /* Some info. */ { SDL_RendererInfo info; SDL_GetRendererInfo(d->render, &info); @@ -692,7 +692,7 @@ void setFreezeDraw_Window(iWindow *d, iBool freezeDraw) { d->isDrawFrozen = freezeDraw; } -void setCursor_Window(iWindow *d, int cursor) { +void setCursor_Window(iWindow *d, int cursor) { if (!d->cursors[cursor]) { d->cursors[cursor] = SDL_CreateSystemCursor(cursor); } -- cgit v1.2.3