=> 3def602e8b7b6f45003cb95f7a74979118ae0e4a
[1mdiff --git a/src/macos.h b/src/macos.h[m [1mindex f948a0db..a59351e6 100644[m [1m--- a/src/macos.h[m [1m+++ b/src/macos.h[m [36m@@ -33,4 +33,6 @@[m [mvoid registerURLHandler_MacOS (void);[m void setupApplication_MacOS (void);[m void insertMenuItems_MacOS (const char *menuLabel, int atIndex, const iMenuItem *items, size_t count);[m void enableMenu_MacOS (const char *menuLabel, iBool enable);[m [32m+[m[32mvoid enableMenuItem_MacOS (const char *menuItemCommand, iBool enable);[m [32m+[m[32mvoid enableMenuItemsByKey_MacOS (int key, int kmods, iBool enable);[m void handleCommand_MacOS (const char *cmd);[m [1mdiff --git a/src/macos.m b/src/macos.m[m [1mindex c8793eac..4e214923 100644[m [1m--- a/src/macos.m[m [1m+++ b/src/macos.m[m [36m@@ -367,40 +367,86 @@[m [mvoid enableMenu_MacOS(const char *menuLabel, iBool enable) {[m [label release];[m }[m [m [31m-static void setShortcut_NSMenuItem_(NSMenuItem *item, int key, int kmods) {[m [31m- iString str;[m [31m- init_String(&str);[m [32m+[m[32mvoid enableMenuItem_MacOS(const char *menuItemCommand, iBool enable) {[m [32m+[m[32m NSApplication *app = [NSApplication sharedApplication];[m [32m+[m[32m NSMenu *appMenu = [app mainMenu];[m [32m+[m[32m MyDelegate *myDel = (MyDelegate *) app.delegate;[m [32m+[m[32m for (NSMenuItem *mainMenuItem in appMenu.itemArray) {[m [32m+[m[32m NSMenu *menu = mainMenuItem.submenu;[m [32m+[m[32m if (menu) {[m [32m+[m[32m for (NSMenuItem *menuItem in menu.itemArray) {[m [32m+[m[32m NSString *command = [myDel commandForItem:menuItem];[m [32m+[m[32m if (command) {[m [32m+[m[32m if (!iCmpStr([command cStringUsingEncoding:NSUTF8StringEncoding],[m [32m+[m[32m menuItemCommand)) {[m [32m+[m[32m [menuItem setEnabled:enable];[m [32m+[m[32m return;[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m}[m [32m+[m [32m+[m[32mstatic iString *composeKeyEquivalent_(int key, int kmods, NSEventModifierFlags *modMask) {[m [32m+[m[32m iString *str = new_String();[m if (key == SDLK_LEFT) {[m [31m- appendChar_String(&str, 0x2190);[m [32m+[m[32m appendChar_String(str, 0x2190);[m }[m else if (key == SDLK_RIGHT) {[m [31m- appendChar_String(&str, 0x2192);[m [32m+[m[32m appendChar_String(str, 0x2192);[m }[m else if (key == SDLK_UP) {[m [31m- appendChar_String(&str, 0x2191);[m [32m+[m[32m appendChar_String(str, 0x2191);[m }[m else if (key == SDLK_DOWN) {[m [31m- appendChar_String(&str, 0x2193);[m [32m+[m[32m appendChar_String(str, 0x2193);[m }[m else if (key) {[m [31m- appendChar_String(&str, key);[m [32m+[m[32m appendChar_String(str, key);[m }[m [31m- NSEventModifierFlags modMask = 0;[m [32m+[m[32m *modMask = 0;[m if (kmods & KMOD_GUI) {[m [31m- modMask |= NSEventModifierFlagCommand;[m [32m+[m[32m *modMask |= NSEventModifierFlagCommand;[m }[m if (kmods & KMOD_ALT) {[m [31m- modMask |= NSEventModifierFlagOption;[m [32m+[m[32m *modMask |= NSEventModifierFlagOption;[m }[m if (kmods & KMOD_CTRL) {[m [31m- modMask |= NSEventModifierFlagControl;[m [32m+[m[32m *modMask |= NSEventModifierFlagControl;[m }[m if (kmods & KMOD_SHIFT) {[m [31m- modMask |= NSEventModifierFlagShift;[m [32m+[m[32m *modMask |= NSEventModifierFlagShift;[m }[m [32m+[m[32m return str;[m [32m+[m[32m}[m [32m+[m [32m+[m[32mvoid enableMenuItemsByKey_MacOS(int key, int kmods, iBool enable) {[m [32m+[m[32m NSApplication *app = [NSApplication sharedApplication];[m [32m+[m[32m NSMenu *appMenu = [app mainMenu];[m [32m+[m[32m NSEventModifierFlags modMask;[m [32m+[m[32m iString *keyEquiv = composeKeyEquivalent_(key, kmods, &modMask);[m [32m+[m[32m for (NSMenuItem *mainMenuItem in appMenu.itemArray) {[m [32m+[m[32m NSMenu *menu = mainMenuItem.submenu;[m [32m+[m[32m if (menu) {[m [32m+[m[32m for (NSMenuItem *menuItem in menu.itemArray) {[m [32m+[m[32m if (menuItem.keyEquivalentModifierMask == modMask &&[m [32m+[m[32m !iCmpStr([menuItem.keyEquivalent cStringUsingEncoding:NSUTF8StringEncoding],[m [32m+[m[32m cstr_String(keyEquiv))) {[m [32m+[m[32m [menuItem setEnabled:enable];[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m delete_String(keyEquiv);[m [32m+[m[32m}[m [32m+[m [32m+[m[32mstatic void setShortcut_NSMenuItem_(NSMenuItem *item, int key, int kmods) {[m [32m+[m[32m NSEventModifierFlags modMask;[m [32m+[m[32m iString *str = composeKeyEquivalent_(key, kmods, &modMask);[m [item setKeyEquivalentModifierMask:modMask];[m [31m- [item setKeyEquivalent:[NSString stringWithUTF8String:cstr_String(&str)]];[m [31m- deinit_String(&str);[m [32m+[m[32m [item setKeyEquivalent:[NSString stringWithUTF8String:cstr_String(str)]];[m [32m+[m[32m delete_String(str);[m }[m [m void insertMenuItems_MacOS(const char *menuLabel, int atIndex, const iMenuItem *items, size_t count) {[m [36m@@ -412,6 +458,7 @@[m [mvoid insertMenuItems_MacOS(const char *menuLabel, int atIndex, const iMenuItem *[m keyEquivalent:@""[m atIndex:atIndex];[m NSMenu *menu = [[NSMenu alloc] initWithTitle:[NSString stringWithUTF8String:menuLabel]];[m [32m+[m[32m [menu setAutoenablesItems:NO];[m for (size_t i = 0; i < count; ++i) {[m const char *label = items[i].label;[m if (label[0] == '\r') {[m [1mdiff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c[m [1mindex 59608151..c4c7475e 100644[m [1m--- a/src/ui/inputwidget.c[m [1m+++ b/src/ui/inputwidget.c[m [36m@@ -30,9 +30,22 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m #include[m #include [m [m [32m+[m[32m#if defined (iPlatformApple)[m [32m+[m[32m# include "macos.h"[m [32m+[m[32m#endif[m [32m+[m static const int refreshInterval_InputWidget_ = 256;[m static const size_t maxUndo_InputWidget_ = 64;[m [m [32m+[m[32mstatic void enableEditorKeysInMenus_(iBool enable) {[m [32m+[m[32m#if defined (iPlatformApple)[m [32m+[m[32m enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable);[m [32m+[m[32m enableMenuItemsByKey_MacOS(SDLK_RIGHT, KMOD_PRIMARY, enable);[m [32m+[m[32m#else[m [32m+[m[32m iUnused(enable);[m [32m+[m[32m#endif[m [32m+[m[32m}[m [32m+[m iDeclareType(InputUndo)[m [m struct Impl_InputUndo {[m [36m@@ -114,6 +127,9 @@[m [mvoid init_InputWidget(iInputWidget *d, size_t maxLen) {[m }[m [m void deinit_InputWidget(iInputWidget *d) {[m [32m+[m[32m if (isSelected_Widget(d)) {[m [32m+[m[32m enableEditorKeysInMenus_(iTrue);[m [32m+[m[32m }[m delete_TextBuf(d->buffered);[m clearUndo_InputWidget_(d);[m deinit_Array(&d->undoStack);[m [36m@@ -279,6 +295,7 @@[m [mvoid begin_InputWidget(iInputWidget *d) {[m else {[m iZap(d->mark);[m }[m [32m+[m[32m enableEditorKeysInMenus_(iFalse);[m }[m [m void end_InputWidget(iInputWidget *d, iBool accept) {[m [36m@@ -287,6 +304,7 @@[m [mvoid end_InputWidget(iInputWidget *d, iBool accept) {[m /* Was not active. */[m return;[m }[m [32m+[m[32m enableEditorKeysInMenus_(iTrue);[m if (!accept) {[m setCopy_Array(&d->text, &d->oldText);[m }[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).