AmendHub

jcs

/

amend

/

amendments

/

103

committer: Add Command+W shortcut to cancel commit

This requires passing through all keystrokes through focusable and
filtering on the receiver.

jcs made amendment 103 20 days ago
--- browser.c Mon Sep 12 16:02:49 2022 +++ browser.c Mon Sep 12 16:18:15 2022 @@ -43,7 +43,6 @@ void browser_update_menu(struct browser *browser); void browser_update(struct focusable *focusable, EventRecord *event); void browser_show_amendment(struct browser *browser, struct repo_amendment *amendment); -void browser_key_down(struct focusable *focusable, EventRecord *event); void browser_mouse_down(struct focusable *focusable, EventRecord *event); bool browser_handle_menu(struct focusable *focusable, short menu, short item); --- committer.c Tue Sep 6 14:13:16 2022 +++ committer.c Mon Sep 12 16:20:46 2022 @@ -286,8 +286,14 @@ committer_key_down(struct focusable *focusable, EventR { struct committer *committer = (struct committer *)focusable->cookie; char k; + + k = event->message & charCodeMask; + if ((event->modifiers & cmdKey) != 0) { + if (k == 'w') + focusable_close(focusable); + return; + } - k = (event->message & charCodeMask); TEKey(k, committer->log_te); UpdateScrollbarForTE(committer->win, committer->log_scroller, committer->log_te, false); --- main.c Tue Sep 6 19:12:14 2022 +++ main.c Mon Sep 12 16:15:05 2022 @@ -29,7 +29,7 @@ MenuHandle apple_menu, file_menu, edit_menu, repo_menu Handle amendment_list_ldef_h; bool quitting = false; -void handle_menu(long menu_id); +bool handle_menu(long menu_id); int main(void) @@ -106,9 +106,11 @@ main(void) case keyDown: case autoKey: key = event.message & charCodeMask; - if ((event.modifiers & cmdKey) != 0) - handle_menu(MenuKey(key)); - else if ((focusable = focusable_focused()) && + if ((event.modifiers & cmdKey) != 0) { + if (handle_menu(MenuKey(key))) + break; + } + if ((focusable = focusable_focused()) && focusable->key_down) focusable->key_down(focusable, &event); break; @@ -189,17 +191,18 @@ main(void) return 0; } -void +bool handle_menu(long menu_id) { struct focusable *focused; short menu, item; + bool ret = true; menu = HiWord(menu_id); item = LoWord(menu_id); - if ((focused = focusable_focused()) && focused->menu && - focused->menu(focused, menu, item)) + if (menu && item && (focused = focusable_focused()) && + focused->menu && focused->menu(focused, menu, item)) goto handled; switch (menu) { @@ -243,10 +246,13 @@ handle_menu(long menu_id) break; } break; + default: + ret = false; } handled: HiliteMenu(0); + return ret; } void