AmendHub

Download:

jcs

/

amend

/

amendments

/

96

browser: Limit initial window size to about 81 characters in committer view

This way we can show a +/- line with 80 characters of code

jcs made amendment 96 over 2 years ago
--- browser.c Wed Aug 31 16:28:42 2022 +++ browser.c Tue Sep 6 14:12:25 2022 @@ -116,8 +116,8 @@ browser_init(struct repo *repo) Rect data_bounds = { 0, 0, 0, 1 }; /* tlbr */ Point cell_size = { 0, 0 }; Cell cell = { 0 }; - short colonpos, n; - + short colonpos, n, width, height; + browser = xmalloczero(sizeof(struct browser), "browser"); browser->state = BROWSER_STATE_IDLE; browser->repo = repo; @@ -125,11 +125,14 @@ browser_init(struct repo *repo) GetIndPattern(&fill_pattern, sysPatListID, 22); /* main window */ - bounds.left = (PADDING / 2); - bounds.top = screenBits.bounds.top + (GetMBarHeight() * 2) - 1 + - (PADDING / 2); - bounds.right = screenBits.bounds.right - 1 - (PADDING / 2); - bounds.bottom = screenBits.bounds.bottom - 1 - (PADDING / 2); + width = screenBits.bounds.right - screenBits.bounds.left - PADDING; + if (width > 540) + width = 540; + height = screenBits.bounds.bottom - screenBits.bounds.top - + PADDING - (GetMBarHeight() * 2); + if (height > 350) + height = 350; + center_in_screen(width, height, true, &bounds); memcpy(filename, browser->repo->bile->filename, sizeof(filename)); PtoCstr(filename); @@ -206,7 +209,8 @@ browser_init(struct repo *repo) browser_update_menu(browser); browser_add_files(browser); - UpdateScrollbarForTE(browser->diff_scroller, browser->diff_te, true); + UpdateScrollbarForTE(browser->win, browser->diff_scroller, + browser->diff_te, true); focusable = xmalloczero(sizeof(struct focusable), "focusable"); focusable->cookie = browser; @@ -407,7 +411,8 @@ browser_show_amendment(struct browser *browser, SetCursor(&arrow); } - UpdateScrollbarForTE(browser->diff_scroller, browser->diff_te, true); + UpdateScrollbarForTE(browser->win, browser->diff_scroller, + browser->diff_te, true); browser_update_menu(browser); } --- committer.c Wed Aug 31 16:28:48 2022 +++ committer.c Tue Sep 6 14:13:16 2022 @@ -289,8 +289,8 @@ committer_key_down(struct focusable *focusable, EventR k = (event->message & charCodeMask); TEKey(k, committer->log_te); - UpdateScrollbarForTE(committer->log_scroller, committer->log_te, - false); + UpdateScrollbarForTE(committer->win, committer->log_scroller, + committer->log_te, false); committer_update_menu(committer); } @@ -481,8 +481,8 @@ committer_generate_diff(struct committer *committer) HUnlock(committer->diff_te); InvalRect(&committer->win->portRect); - UpdateScrollbarForTE(committer->diff_scroller, committer->diff_te, - true); + UpdateScrollbarForTE(committer->win, committer->diff_scroller, + committer->diff_te, true); progress(NULL); --- editor.c Wed Aug 31 16:29:02 2022 +++ editor.c Tue Sep 6 14:13:47 2022 @@ -270,7 +270,8 @@ editor_key_down(struct focusable *focusable, EventReco TEKey(k, editor->last_te); if (editor->last_te == editor->log_te) - UpdateScrollbarForTE(editor->log_scroller, editor->last_te, false); + UpdateScrollbarForTE(editor->win, editor->log_scroller, + editor->last_te, false); editor_update_menu(editor); }