diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-11 08:31:11 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-11 08:31:11 +0200 |
commit | 964b9f752f086f58a6aae2602e83b30833412199 (patch) | |
tree | 94d9b6b6927e5df39ee78b9c456f9925c665372e | |
parent | d52f3dfa2f81c9520b8ff1fdfe4adeac3907a7a4 (diff) |
Opening link in new tab via home row keys
Added a new keybinding for opening links via keyboard in new tab. The default binding is Shift+F.
The H key is now used for setting the hover link.
-rw-r--r-- | src/ui/documentwidget.c | 8 | ||||
-rw-r--r-- | src/ui/keys.c | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 3373771d..8f2fc437 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -132,6 +132,7 @@ enum iDocumentWidgetFlag { | |||
132 | noHoverWhileScrolling_DocumentWidgetFlag = iBit(2), | 132 | noHoverWhileScrolling_DocumentWidgetFlag = iBit(2), |
133 | showLinkNumbers_DocumentWidgetFlag = iBit(3), | 133 | showLinkNumbers_DocumentWidgetFlag = iBit(3), |
134 | setHoverViaKeys_DocumentWidgetFlag = iBit(4), | 134 | setHoverViaKeys_DocumentWidgetFlag = iBit(4), |
135 | newTabViaHomeKeys_DocumentWidgetFlag = iBit(5), | ||
135 | }; | 136 | }; |
136 | 137 | ||
137 | enum iDocumentLinkOrdinalMode { | 138 | enum iDocumentLinkOrdinalMode { |
@@ -1789,6 +1790,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1789 | iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iTrue); | 1790 | iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iTrue); |
1790 | iChangeFlags(d->flags, setHoverViaKeys_DocumentWidgetFlag, | 1791 | iChangeFlags(d->flags, setHoverViaKeys_DocumentWidgetFlag, |
1791 | argLabel_Command(cmd, "hover") != 0); | 1792 | argLabel_Command(cmd, "hover") != 0); |
1793 | iChangeFlags(d->flags, newTabViaHomeKeys_DocumentWidgetFlag, | ||
1794 | argLabel_Command(cmd, "newtab") != 0); | ||
1792 | } | 1795 | } |
1793 | invalidateVisibleLinks_DocumentWidget_(d); | 1796 | invalidateVisibleLinks_DocumentWidget_(d); |
1794 | refresh_Widget(d); | 1797 | refresh_Widget(d); |
@@ -2203,7 +2206,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2203 | } | 2206 | } |
2204 | else { | 2207 | else { |
2205 | postCommandf_App("open newtab:%d url:%s", | 2208 | postCommandf_App("open newtab:%d url:%s", |
2206 | openTabMode_Sym(SDL_GetModState()), | 2209 | d->ordinalMode == |
2210 | numbersAndAlphabet_DocumentLinkOrdinalMode | ||
2211 | ? openTabMode_Sym(SDL_GetModState()) | ||
2212 | : (d->flags & newTabViaHomeKeys_DocumentWidgetFlag ? 1 : 0), | ||
2207 | cstr_String(absoluteUrl_String( | 2213 | cstr_String(absoluteUrl_String( |
2208 | d->mod.url, linkUrl_GmDocument(d->doc, run->linkId)))); | 2214 | d->mod.url, linkUrl_GmDocument(d->doc, run->linkId)))); |
2209 | } | 2215 | } |
diff --git a/src/ui/keys.c b/src/ui/keys.c index 941dda54..a4e5c6fc 100644 --- a/src/ui/keys.c +++ b/src/ui/keys.c | |||
@@ -75,9 +75,10 @@ static const struct { int id; iMenuItem bind; int flags; } defaultBindings_[] = | |||
75 | { 32, { "Go to parent directory", navigateParent_KeyShortcut, "navigate.parent" }, 0 }, | 75 | { 32, { "Go to parent directory", navigateParent_KeyShortcut, "navigate.parent" }, 0 }, |
76 | { 33, { "Go to site root", navigateRoot_KeyShortcut, "navigate.root" }, 0 }, | 76 | { 33, { "Go to site root", navigateRoot_KeyShortcut, "navigate.root" }, 0 }, |
77 | { 35, { "Reload page", reload_KeyShortcut, "document.reload" }, 0 }, | 77 | { 35, { "Reload page", reload_KeyShortcut, "document.reload" }, 0 }, |
78 | { 40, { "Open link via home row keys", 'f', 0, "document.linkkeys arg:1" }, 0 }, | ||
79 | { 41, { "Open link via modifier key", SDLK_LALT, 0, "document.linkkeys arg:0" }, argRelease_BindFlag }, | 78 | { 41, { "Open link via modifier key", SDLK_LALT, 0, "document.linkkeys arg:0" }, argRelease_BindFlag }, |
80 | { 45, { "Hover on link via home row keys", 'f', KMOD_SHIFT, "document.linkkeys arg:1 hover:1" }, 0 }, | 79 | { 42, { "Open link via home row keys", 'f', 0, "document.linkkeys arg:1" }, 0 }, |
80 | { 45, { "Open link in new tab via home row keys", 'f', KMOD_SHIFT, "document.linkkeys arg:1 newtab:1" }, 0 }, | ||
81 | { 46, { "Hover on link via home row keys", 'h', 0, "document.linkkeys arg:1 hover:1" }, 0 }, | ||
81 | { 70, { "Zoom in", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" }, 0 }, | 82 | { 70, { "Zoom in", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" }, 0 }, |
82 | { 71, { "Zoom out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" }, 0 }, | 83 | { 71, { "Zoom out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" }, 0 }, |
83 | { 72, { "Reset zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" }, 0 }, | 84 | { 72, { "Reset zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" }, 0 }, |