diff options
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | src/app.c | 5 | ||||
-rw-r--r-- | src/macos.m | 16 | ||||
-rw-r--r-- | src/ui/inputwidget.c | 30 | ||||
-rw-r--r-- | src/ui/window.c | 2 |
5 files changed, 42 insertions, 18 deletions
@@ -77,11 +77,12 @@ Once you have compiled a working binary under MSYS2, there is still an additiona | |||
77 | 77 | ||
78 | ### Compiling on Raspberry Pi | 78 | ### Compiling on Raspberry Pi |
79 | 79 | ||
80 | You should use a version of SDL that is compiled to take advantage of the Broadcom VideoCore OpenGL ES hardware. This provides the best performance when running Lagrange in a console. | 80 | On Raspberry Pi 4/400, you can compile and run Lagrange just like on a regular desktop PC. Accelerated OpenGL graphics should work fine under X11. |
81 | 81 | ||
82 | At present time, OpenGL under X11 on Raspberry Pi is still quite slow/experimental. When running under X11, software rendering is the best choice and the SDL from Raspbian etc. is sufficient. | 82 | On Raspberry Pi 3 or earlier, you should use a version of SDL that is compiled to take advantage of the Broadcom VideoCore OpenGL ES hardware. This provides the best performance when running Lagrange in a console. OpenGL under X11 on Raspberry Pi 2/3 is quite |
83 | slow/experimental. When running under X11, software rendering is the best choice and the SDL from Raspbian etc. is sufficient. | ||
83 | 84 | ||
84 | The following build options are recommended on Raspberry Pi: | 85 | The following build options are recommended on Raspberry Pi 2/3: |
85 | 86 | ||
86 | * `ENABLE_KERNING=NO`: faster text rendering without noticeable loss of quality | 87 | * `ENABLE_KERNING=NO`: faster text rendering without noticeable loss of quality |
87 | * `ENABLE_WINDOWPOS_FIX=YES`: workaround for window position restore issues (SDL bug) | 88 | * `ENABLE_WINDOWPOS_FIX=YES`: workaround for window position restore issues (SDL bug) |
@@ -415,8 +415,9 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
415 | for (size_t i = 1; i < size_StringList(args_CommandLine(&d->args)); i++) { | 415 | for (size_t i = 1; i < size_StringList(args_CommandLine(&d->args)); i++) { |
416 | const iString *arg = constAt_StringList(args_CommandLine(&d->args), i); | 416 | const iString *arg = constAt_StringList(args_CommandLine(&d->args), i); |
417 | const iBool isKnownScheme = | 417 | const iBool isKnownScheme = |
418 | startsWithCase_String(arg, "gemini:") || startsWithCase_String(arg, "file:") || | 418 | startsWithCase_String(arg, "gemini:") || startsWithCase_String(arg, "gopher:") || |
419 | startsWithCase_String(arg, "data:") || startsWithCase_String(arg, "about:"); | 419 | startsWithCase_String(arg, "file:") || startsWithCase_String(arg, "data:") || |
420 | startsWithCase_String(arg, "about:"); | ||
420 | if (isKnownScheme || fileExists_FileInfo(arg)) { | 421 | if (isKnownScheme || fileExists_FileInfo(arg)) { |
421 | postCommandf_App("open newtab:%d url:%s", | 422 | postCommandf_App("open newtab:%d url:%s", |
422 | newTab, | 423 | newTab, |
diff --git a/src/macos.m b/src/macos.m index 1d972ebd..28ebcc43 100644 --- a/src/macos.m +++ b/src/macos.m | |||
@@ -25,6 +25,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
25 | #include "ui/command.h" | 25 | #include "ui/command.h" |
26 | #include "ui/widget.h" | 26 | #include "ui/widget.h" |
27 | #include "ui/color.h" | 27 | #include "ui/color.h" |
28 | #include "ui/window.h" | ||
29 | |||
30 | #include <SDL_timer.h> | ||
28 | 31 | ||
29 | #import <AppKit/AppKit.h> | 32 | #import <AppKit/AppKit.h> |
30 | 33 | ||
@@ -217,7 +220,6 @@ static void appearanceChanged_MacOS_(NSString *name) { | |||
217 | } | 220 | } |
218 | } | 221 | } |
219 | 222 | ||
220 | #if 1 | ||
221 | - (NSTouchBar *)makeTouchBar { | 223 | - (NSTouchBar *)makeTouchBar { |
222 | NSTouchBar *bar = [[NSTouchBar alloc] init]; | 224 | NSTouchBar *bar = [[NSTouchBar alloc] init]; |
223 | bar.delegate = self; | 225 | bar.delegate = self; |
@@ -235,7 +237,6 @@ static void appearanceChanged_MacOS_(NSString *name) { | |||
235 | } | 237 | } |
236 | return bar; | 238 | return bar; |
237 | } | 239 | } |
238 | #endif | ||
239 | 240 | ||
240 | - (void)showPreferences { | 241 | - (void)showPreferences { |
241 | postCommand_App("preferences"); | 242 | postCommand_App("preferences"); |
@@ -249,6 +250,11 @@ static void appearanceChanged_MacOS_(NSString *name) { | |||
249 | NSString *command = [menuCommands objectForKey:[(NSMenuItem *)sender title]]; | 250 | NSString *command = [menuCommands objectForKey:[(NSMenuItem *)sender title]]; |
250 | if (command) { | 251 | if (command) { |
251 | postCommand_App([command cStringUsingEncoding:NSUTF8StringEncoding]); | 252 | postCommand_App([command cStringUsingEncoding:NSUTF8StringEncoding]); |
253 | /* Shouldn't double-activate menu items in case the same key is used in our widgets. | ||
254 | SDL ignores menu key equivalents so the keydown events will be posted regardless. | ||
255 | This is quite a kludge, but we can achieve this by taking advantage of Window's | ||
256 | focus-acquisition threshold for ignoring key events. */ | ||
257 | get_Window()->focusGainedAt = SDL_GetTicks(); | ||
252 | } | 258 | } |
253 | } | 259 | } |
254 | 260 | ||
@@ -513,6 +519,12 @@ void insertMenuItems_MacOS(const char *menuLabel, int atIndex, const iMenuItem * | |||
513 | else if (items[i].key == SDLK_RIGHT) { | 519 | else if (items[i].key == SDLK_RIGHT) { |
514 | appendChar_String(&key, 0x2192); | 520 | appendChar_String(&key, 0x2192); |
515 | } | 521 | } |
522 | else if (items[i].key == SDLK_UP) { | ||
523 | appendChar_String(&key, 0x2191); | ||
524 | } | ||
525 | else if (items[i].key == SDLK_DOWN) { | ||
526 | appendChar_String(&key, 0x2193); | ||
527 | } | ||
516 | else if (items[i].key) { | 528 | else if (items[i].key) { |
517 | appendChar_String(&key, items[i].key); | 529 | appendChar_String(&key, items[i].key); |
518 | } | 530 | } |
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 537afb00..fbcbd4c2 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -479,6 +479,21 @@ static size_t coordIndex_InputWidget_(const iInputWidget *d, iInt2 coord) { | |||
479 | return index; | 479 | return index; |
480 | } | 480 | } |
481 | 481 | ||
482 | static iBool copy_InputWidget_(iInputWidget *d, iBool doCut) { | ||
483 | if (!isEmpty_Range(&d->mark)) { | ||
484 | const iRanges m = mark_InputWidget_(d); | ||
485 | SDL_SetClipboardText(cstrCollect_String( | ||
486 | newUnicodeN_String(constAt_Array(&d->text, m.start), size_Range(&m)))); | ||
487 | if (doCut) { | ||
488 | pushUndo_InputWidget_(d); | ||
489 | deleteMarked_InputWidget_(d); | ||
490 | contentsWereChanged_InputWidget_(d); | ||
491 | } | ||
492 | return iTrue; | ||
493 | } | ||
494 | return iFalse; | ||
495 | } | ||
496 | |||
482 | static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | 497 | static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { |
483 | iWidget *w = as_Widget(d); | 498 | iWidget *w = as_Widget(d); |
484 | if (isCommand_Widget(w, ev, "focus.gained")) { | 499 | if (isCommand_Widget(w, ev, "focus.gained")) { |
@@ -495,6 +510,10 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
495 | } | 510 | } |
496 | return iFalse; | 511 | return iFalse; |
497 | } | 512 | } |
513 | else if (isFocused_Widget(d) && isCommand_UserEvent(ev, "copy")) { | ||
514 | copy_InputWidget_(d, iFalse); | ||
515 | return iTrue; | ||
516 | } | ||
498 | switch (processEvent_Click(&d->click, ev)) { | 517 | switch (processEvent_Click(&d->click, ev)) { |
499 | case none_ClickResult: | 518 | case none_ClickResult: |
500 | break; | 519 | break; |
@@ -531,16 +550,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
531 | switch (key) { | 550 | switch (key) { |
532 | case 'c': | 551 | case 'c': |
533 | case 'x': | 552 | case 'x': |
534 | if (!isEmpty_Range(&d->mark)) { | 553 | copy_InputWidget_(d, key == 'x'); |
535 | const iRanges m = mark_InputWidget_(d); | ||
536 | SDL_SetClipboardText(cstrCollect_String( | ||
537 | newUnicodeN_String(constAt_Array(&d->text, m.start), size_Range(&m)))); | ||
538 | if (key == 'x') { | ||
539 | pushUndo_InputWidget_(d); | ||
540 | deleteMarked_InputWidget_(d); | ||
541 | contentsWereChanged_InputWidget_(d); | ||
542 | } | ||
543 | } | ||
544 | return iTrue; | 554 | return iTrue; |
545 | case 'v': | 555 | case 'v': |
546 | if (SDL_HasClipboardText()) { | 556 | if (SDL_HasClipboardText()) { |
diff --git a/src/ui/window.c b/src/ui/window.c index 2b2dae46..115dd04b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -125,7 +125,7 @@ static const iMenuItem fileMenuItems[] = { | |||
125 | }; | 125 | }; |
126 | 126 | ||
127 | static const iMenuItem editMenuItems[] = { | 127 | static const iMenuItem editMenuItems[] = { |
128 | { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" }, | 128 | { "Copy", SDLK_c, KMOD_PRIMARY, "copy" }, |
129 | { "Copy Link to Page", SDLK_c, KMOD_PRIMARY | KMOD_SHIFT, "document.copylink" }, | 129 | { "Copy Link to Page", SDLK_c, KMOD_PRIMARY | KMOD_SHIFT, "document.copylink" }, |
130 | { "---", 0, 0, NULL }, | 130 | { "---", 0, 0, NULL }, |
131 | { "Find", SDLK_f, KMOD_PRIMARY, "focus.set id:find.input" }, | 131 | { "Find", SDLK_f, KMOD_PRIMARY, "focus.set id:find.input" }, |