summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c7
-rw-r--r--src/ui/inputwidget.c9
-rw-r--r--src/ui/keys.h6
-rw-r--r--src/ui/window.c14
4 files changed, 22 insertions, 14 deletions
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) {
244 addChild_Widget(w, iClob(d->scroll = new_ScrollWidget())); 244 addChild_Widget(w, iClob(d->scroll = new_ScrollWidget()));
245 d->menu = NULL; /* created when clicking */ 245 d->menu = NULL; /* created when clicking */
246#if !defined (iPlatformApple) /* in system menu */ 246#if !defined (iPlatformApple) /* in system menu */
247 addAction_Widget(w, reload_KeyShortcut, "navigate.reload");
247 addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close"); 248 addAction_Widget(w, SDLK_w, KMOD_PRIMARY, "tabs.close");
248#endif 249#endif
249 addAction_Widget(w, navigateBack_KeyShortcut, "navigate.back"); 250 addAction_Widget(w, navigateBack_KeyShortcut, "navigate.back");
@@ -1453,9 +1454,9 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1453 pushBackN_Array( 1454 pushBackN_Array(
1454 &items, 1455 &items,
1455 (iMenuItem[]){ 1456 (iMenuItem[]){
1456 { "Go Back", SDLK_LEFT, KMOD_PRIMARY, "navigate.back" }, 1457 { "Go Back", navigateBack_KeyShortcut, "navigate.back" },
1457 { "Go Forward", SDLK_RIGHT, KMOD_PRIMARY, "navigate.forward" }, 1458 { "Go Forward", navigateForward_KeyShortcut, "navigate.forward" },
1458 { "Reload Page", 0, 0, "navigate.reload" }, 1459 { "Reload Page", reload_KeyShortcut, "navigate.reload" },
1459 { "---", 0, 0, NULL }, 1460 { "---", 0, 0, NULL },
1460 { d->contextLink ? "Copy Link URL" : "Copy Page URL", 1461 { d->contextLink ? "Copy Link URL" : "Copy Page URL",
1461 0, 1462 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. */
23#include "inputwidget.h" 23#include "inputwidget.h"
24#include "paint.h" 24#include "paint.h"
25#include "util.h" 25#include "util.h"
26#include "keys.h"
26#include "app.h" 27#include "app.h"
27 28
28#include <the_Foundation/array.h> 29#include <the_Foundation/array.h>
@@ -539,7 +540,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
539 deleteMarked_InputWidget_(d); 540 deleteMarked_InputWidget_(d);
540 contentsWereChanged_InputWidget_(d); 541 contentsWereChanged_InputWidget_(d);
541 } 542 }
542 else if (mods & KMOD_ALT) { 543 else if (mods & byWord_KeyModifier) {
543 pushUndo_InputWidget_(d); 544 pushUndo_InputWidget_(d);
544 d->mark.start = d->cursor; 545 d->mark.start = d->cursor;
545 d->mark.end = skipWord_InputWidget_(d, d->cursor, -1); 546 d->mark.end = skipWord_InputWidget_(d, d->cursor, -1);
@@ -562,7 +563,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
562 deleteMarked_InputWidget_(d); 563 deleteMarked_InputWidget_(d);
563 contentsWereChanged_InputWidget_(d); 564 contentsWereChanged_InputWidget_(d);
564 } 565 }
565 else if (mods & KMOD_ALT) { 566 else if (mods & byWord_KeyModifier) {
566 pushUndo_InputWidget_(d); 567 pushUndo_InputWidget_(d);
567 d->mark.start = d->cursor; 568 d->mark.start = d->cursor;
568 d->mark.end = skipWord_InputWidget_(d, d->cursor, +1); 569 d->mark.end = skipWord_InputWidget_(d, d->cursor, +1);
@@ -621,10 +622,10 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
621 case SDLK_LEFT: 622 case SDLK_LEFT:
622 case SDLK_RIGHT: { 623 case SDLK_RIGHT: {
623 const int dir = (key == SDLK_LEFT ? -1 : +1); 624 const int dir = (key == SDLK_LEFT ? -1 : +1);
624 if (mods & KMOD_PRIMARY) { 625 if (mods & byLine_KeyModifier) {
625 setCursor_InputWidget(d, dir < 0 ? 0 : curMax); 626 setCursor_InputWidget(d, dir < 0 ? 0 : curMax);
626 } 627 }
627 else if (mods & KMOD_ALT) { 628 else if (mods & byWord_KeyModifier) {
628 setCursor_InputWidget(d, skipWord_InputWidget_(d, d->cursor, dir)); 629 setCursor_InputWidget(d, skipWord_InputWidget_(d, d->cursor, dir));
629 } 630 }
630 else if (!isMarking_() && !isEmpty_Range(&d->mark)) { 631 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. */
25#include <the_Foundation/defs.h> 25#include <the_Foundation/defs.h>
26 26
27#if defined (iPlatformApple) 27#if defined (iPlatformApple)
28# define reload_KeyShortcut SDLK_r, KMOD_PRIMARY
28# define prevTab_KeyShortcut SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY 29# define prevTab_KeyShortcut SDLK_LEFTBRACKET, KMOD_SHIFT | KMOD_PRIMARY
29# define nextTab_KeyShortcut SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY 30# define nextTab_KeyShortcut SDLK_RIGHTBRACKET, KMOD_SHIFT | KMOD_PRIMARY
30# define navigateBack_KeyShortcut SDLK_LEFT, KMOD_PRIMARY 31# define navigateBack_KeyShortcut SDLK_LEFT, KMOD_PRIMARY
31# define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_PRIMARY 32# define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_PRIMARY
33# define byWord_KeyModifier KMOD_ALT
34# define byLine_KeyModifier KMOD_PRIMARY
32#else 35#else
36# define reload_KeyShortcut SDLK_r, KMOD_PRIMARY
33# define prevTab_KeyShortcut SDLK_PAGEUP, KMOD_PRIMARY 37# define prevTab_KeyShortcut SDLK_PAGEUP, KMOD_PRIMARY
34# define nextTab_KeyShortcut SDLK_PAGEDOWN, KMOD_PRIMARY 38# define nextTab_KeyShortcut SDLK_PAGEDOWN, KMOD_PRIMARY
35# define navigateBack_KeyShortcut SDLK_LEFT, KMOD_ALT 39# define navigateBack_KeyShortcut SDLK_LEFT, KMOD_ALT
36# define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_ALT 40# define navigateForward_KeyShortcut SDLK_RIGHT, KMOD_ALT
41# define byWord_KeyModifier KMOD_CTRL
42# define byLine_KeyModifier 0
37#endif 43#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[] = {
138 { "Show Page Outline", '4', KMOD_PRIMARY, "sidebar.mode arg:3 toggle:1" }, 138 { "Show Page Outline", '4', KMOD_PRIMARY, "sidebar.mode arg:3 toggle:1" },
139 { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, 139 { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" },
140 { "---", 0, 0, NULL }, 140 { "---", 0, 0, NULL },
141 { "Go Back", SDLK_LEFTBRACKET, KMOD_PRIMARY, "navigate.back" }, 141 { "Go Back", navigateBack_KeyShortcut, "navigate.back" },
142 { "Go Forward", SDLK_RIGHTBRACKET, KMOD_PRIMARY, "navigate.forward" }, 142 { "Go Forward", navigateForward_KeyShortcut, "navigate.forward" },
143 { "Reload Page", 'r', KMOD_PRIMARY, "navigate.reload" }, 143 { "Reload Page", reload_KeyShortcut, "navigate.reload" },
144 { "---", 0, 0, NULL }, 144 { "---", 0, 0, NULL },
145 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" }, 145 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" },
146 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" }, 146 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" },
@@ -405,7 +405,7 @@ static void setupUserInterface_Window(iWindow *d) {
405 addChildPos_Widget(content, iClob(sidebar), front_WidgetAddPos); 405 addChildPos_Widget(content, iClob(sidebar), front_WidgetAddPos);
406 } 406 }
407 /* Search bar. */ { 407 /* Search bar. */ {
408 iWidget *searchBar = new_Widget(); 408 iWidget *searchBar = new_Widget();
409 setId_Widget(searchBar, "search"); 409 setId_Widget(searchBar, "search");
410 setFlags_Widget(searchBar, 410 setFlags_Widget(searchBar,
411 hidden_WidgetFlag | collapse_WidgetFlag | arrangeHeight_WidgetFlag | 411 hidden_WidgetFlag | collapse_WidgetFlag | arrangeHeight_WidgetFlag |
@@ -483,7 +483,7 @@ void init_Window(iWindow *d, iRect rect) {
483 d->isDrawFrozen = iTrue; 483 d->isDrawFrozen = iTrue;
484 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; 484 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
485#if defined (ENABLE_SWRENDER) 485#if defined (ENABLE_SWRENDER)
486 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); 486 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
487#elif defined (iPlatformApple) 487#elif defined (iPlatformApple)
488 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); 488 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
489#else 489#else
@@ -499,7 +499,7 @@ void init_Window(iWindow *d, iRect rect) {
499 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); 499 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect));
500 } 500 }
501 SDL_SetWindowMinimumSize(d->win, 400, 250); 501 SDL_SetWindowMinimumSize(d->win, 400, 250);
502 SDL_SetWindowTitle(d->win, "Lagrange"); 502 SDL_SetWindowTitle(d->win, "Lagrange");
503 /* Some info. */ { 503 /* Some info. */ {
504 SDL_RendererInfo info; 504 SDL_RendererInfo info;
505 SDL_GetRendererInfo(d->render, &info); 505 SDL_GetRendererInfo(d->render, &info);
@@ -692,7 +692,7 @@ void setFreezeDraw_Window(iWindow *d, iBool freezeDraw) {
692 d->isDrawFrozen = freezeDraw; 692 d->isDrawFrozen = freezeDraw;
693} 693}
694 694
695void setCursor_Window(iWindow *d, int cursor) { 695void setCursor_Window(iWindow *d, int cursor) {
696 if (!d->cursors[cursor]) { 696 if (!d->cursors[cursor]) {
697 d->cursors[cursor] = SDL_CreateSystemCursor(cursor); 697 d->cursors[cursor] = SDL_CreateSystemCursor(cursor);
698 } 698 }