summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-01-10 22:16:57 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-01-10 22:16:57 +0200
commita3a89bd8cf269953d3c41cfc9bf5e76caffe1866 (patch)
tree9693d78ef15eb74824511f4f6d0cb5d8dd678af5 /src/ui/documentwidget.c
parent2f193a8b9a151ce218cd1996cd705604c153a00b (diff)
Added a keybinding to hover on links via keyboard
Enables viewing full URLs when navigating via keyboard.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index b3235755..3373771d 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -131,6 +131,7 @@ enum iDocumentWidgetFlag {
131 selecting_DocumentWidgetFlag = iBit(1), 131 selecting_DocumentWidgetFlag = iBit(1),
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}; 135};
135 136
136enum iDocumentLinkOrdinalMode { 137enum iDocumentLinkOrdinalMode {
@@ -1786,6 +1787,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1786 else { 1787 else {
1787 d->ordinalMode = arg_Command(cmd); 1788 d->ordinalMode = arg_Command(cmd);
1788 iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iTrue); 1789 iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iTrue);
1790 iChangeFlags(d->flags, setHoverViaKeys_DocumentWidgetFlag,
1791 argLabel_Command(cmd, "hover") != 0);
1789 } 1792 }
1790 invalidateVisibleLinks_DocumentWidget_(d); 1793 invalidateVisibleLinks_DocumentWidget_(d);
1791 refresh_Widget(d); 1794 refresh_Widget(d);
@@ -2195,10 +2198,15 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2195 const iGmRun *run = i.ptr; 2198 const iGmRun *run = i.ptr;
2196 if (run->flags & decoration_GmRunFlag && 2199 if (run->flags & decoration_GmRunFlag &&
2197 visibleLinkOrdinal_DocumentWidget_(d, run->linkId) == ord) { 2200 visibleLinkOrdinal_DocumentWidget_(d, run->linkId) == ord) {
2198 postCommandf_App("open newtab:%d url:%s", 2201 if (d->flags & setHoverViaKeys_DocumentWidgetFlag) {
2199 openTabMode_Sym(SDL_GetModState()), 2202 d->hoverLink = run;
2200 cstr_String(absoluteUrl_String( 2203 }
2201 d->mod.url, linkUrl_GmDocument(d->doc, run->linkId)))); 2204 else {
2205 postCommandf_App("open newtab:%d url:%s",
2206 openTabMode_Sym(SDL_GetModState()),
2207 cstr_String(absoluteUrl_String(
2208 d->mod.url, linkUrl_GmDocument(d->doc, run->linkId))));
2209 }
2202 iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iFalse); 2210 iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iFalse);
2203 invalidateVisibleLinks_DocumentWidget_(d); 2211 invalidateVisibleLinks_DocumentWidget_(d);
2204 refresh_Widget(d); 2212 refresh_Widget(d);