AmendHub

Download:

jcs

/

wikipedia

/

amendments

/

54

main+browser: Make cmd+click on links open them in a new window

Also add a new menu option to open a new, blank window.

jcs made amendment 54 11 months ago
--- browser.c Wed Aug 30 18:07:25 2023 +++ browser.c Mon Oct 30 17:39:25 2023 @@ -120,7 +120,7 @@ browser_idle(struct focusable *focusable, EventRecord } struct browser * -browser_init(void) +browser_init(char *query) { char title[256]; struct browser *browser; @@ -229,6 +229,14 @@ browser_init(void) focusable->atexit = browser_atexit; focusable_add(focusable); + if (query != NULL) { + TESetText(query, strlen(query), browser->input_te); + HLock(browser->input_te); + InvalRect(&(*(browser->input_te))->viewRect); + HUnlock(browser->input_te); + browser->state = BROWSER_STATE_ARTICLE_GET; + } + return browser; } @@ -408,6 +416,10 @@ browser_mouse_down(struct focusable *focusable, EventR for (n = 0; n < browser->links_count; n++) { link = &browser->links[n]; if ((link->pos <= off) && (off < link->pos + link->len)) { + if (event->modifiers & cmdKey) { + browser_init(link->link); + break; + } TESetText(link->link, strlen(link->link), browser->input_te); HLock(browser->input_te); --- browser.h Wed Aug 30 17:27:24 2023 +++ browser.h Mon Oct 30 13:20:36 2023 @@ -61,7 +61,7 @@ struct browser { char last_printed[2]; }; -struct browser *browser_init(void); +struct browser *browser_init(char *query); bool browser_print(struct browser *browser, const char *str, size_t len, unsigned long style); void browser_clear(struct browser *browser); --- main.c Mon Oct 16 17:26:29 2023 +++ main.c Mon Oct 30 13:27:59 2023 @@ -89,7 +89,7 @@ main(void) if (_TCPInit() != 0) panic("Failed initializing MacTCP"); - browser_init(); + browser_init(NULL); while (!quitting) { WaitNextEvent(everyEvent, &event, 0L, 0L); @@ -217,6 +217,9 @@ handle_menu(long menu_id) break; case FILE_MENU_ID: switch (item) { + case FILE_MENU_NEW_ID: + browser_init(NULL); + break; case FILE_MENU_SETTINGS_ID: settings_show(); break; --- wikipedia.π.r Mon Oct 16 18:54:41 2023 +++ wikipedia.π.r Mon Oct 30 17:42:16 2023 @@ -5,10 +5,11 @@ data 'MENU' (128) { }; data 'MENU' (129) { - $"0081 0000 0000 0000 0000 FFFF FFFB 0446" /* .Å.............F */ - $"696C 650B 5365 7474 696E 6773 2E2E 2E00" /* ile.Settings.... */ - $"0000 0001 2D00 0000 0004 5175 6974 0051" /* ....-.....Quit.Q */ - $"0000 00" /* ... */ + $"0081 0000 0000 0000 0000 FFFF FFEB 0446" /* .Å.............F */ + $"696C 6509 4E65 7720 5175 6572 7900 4E00" /* ile∆New Query.N. */ + $"0001 2D00 0000 000B 5365 7474 696E 6773" /* ..-.....Settings */ + $"2E2E 2E00 0000 0001 2D00 0000 0004 5175" /* ........-.....Qu */ + $"6974 0051 0000 00" /* it.Q... */ }; data 'MENU' (130) { @@ -92,5 +93,11 @@ data 'ICN#' (128) { $"0276 3B40 0174 BA40 017D 9E80 0139 5C80" /* .v;@.t∫@.}ûÄ.9\Ä */ $"00BA 2D00 0092 2900 0044 2200 0028 1400" /* .∫-..í)..D"..(.. */ $"0010 0800 0000 0000 0000 0000 0000 0000" /* ................ */ +}; + +data 'STR ' (1000, "Hostname") { + $"2468 7474 702D 7769 6B69 7065 6469 612E" /* $http-wikipedia. */ + $"6A63 7364 6F74 6F72 672E 776F 726B 6572" /* jcsdotorg.worker */ + $"732E 6465 76" /* s.dev */ }; --- wikipedia.h Mon Oct 16 17:39:05 2023 +++ wikipedia.h Mon Oct 30 13:14:26 2023 @@ -34,8 +34,9 @@ #define APPLE_MENU_ABOUT_ID 1 #define FILE_MENU_ID 129 -#define FILE_MENU_SETTINGS_ID 1 -#define FILE_MENU_QUIT_ID 3 +#define FILE_MENU_NEW_ID 1 +#define FILE_MENU_SETTINGS_ID 3 +#define FILE_MENU_QUIT_ID 5 #define EDIT_MENU_ID 130 #define EDIT_MENU_CUT_ID 1