AmendHub

Download:

jcs

/

amend

/

amendments

/

89

*: Tweak font sizing, Geneva 11 isn't a standard size and looks bad


jcs made amendment 89 over 2 years ago
--- browser.c Wed Aug 17 14:24:15 2022 +++ browser.c Wed Aug 17 17:07:23 2022 @@ -30,6 +30,13 @@ #include "tetab.h" #include "util.h" +#define FILE_LIST_FONT geneva +#define FILE_LIST_FONT_SIZE 10 +#define DIFF_BUTTON_FONT geneva +#define DIFF_BUTTON_FONT_SIZE 12 + +#define PADDING 10 + bool browser_close(struct focusable *focusable); void browser_idle(struct focusable *focusable, EventRecord *event); void browser_update_menu(struct browser *browser); @@ -109,7 +116,7 @@ browser_init(struct repo *repo) Rect data_bounds = { 0, 0, 0, 1 }; /* tlbr */ Point cell_size = { 0, 0 }; Cell cell = { 0 }; - short padding = 10, colonpos, n; + short colonpos, n; browser = xmalloczero(sizeof(struct browser)); browser->state = BROWSER_STATE_IDLE; @@ -118,11 +125,11 @@ browser_init(struct repo *repo) GetIndPattern(&fill_pattern, sysPatListID, 22); /* main window */ - bounds.left = (padding / 2); + 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); + (PADDING / 2); + bounds.right = screenBits.bounds.right - 1 - (PADDING / 2); + bounds.bottom = screenBits.bounds.bottom - 1 - (PADDING / 2); memcpy(filename, browser->repo->bile->filename, sizeof(filename)); PtoCstr(filename); @@ -140,13 +147,13 @@ browser_init(struct repo *repo) SetPort(browser->win); /* file list */ - bounds.top = bounds.left = padding; + bounds.top = bounds.left = PADDING; bounds.bottom = browser->win->portRect.bottom - - (browser->win->portRect.bottom * 0.6) - 2 - 20 - padding - padding; + (browser->win->portRect.bottom * 0.6) - 2 - 20 - PADDING - PADDING; bounds.right = 100; - TextFont(applFont); - TextSize(10); + TextFont(FILE_LIST_FONT); + TextSize(FILE_LIST_FONT_SIZE); browser->file_list = LNew(&bounds, &data_bounds, cell_size, 0, browser->win, true, true, false, true); if (!browser->file_list) @@ -155,20 +162,20 @@ browser_init(struct repo *repo) (*(browser->file_list))->selFlags = lNoNilHilite; /* diff button */ - bounds.top = bounds.bottom + padding; + bounds.top = bounds.bottom + PADDING; bounds.bottom = bounds.top + 20; bounds.right += SCROLLBAR_WIDTH; - TextFont(applFont); - TextSize(11); + TextFont(DIFF_BUTTON_FONT); + TextSize(DIFF_BUTTON_FONT_SIZE); browser->diff_button = NewControl(browser->win, &bounds, "\pGenerate Diff", true, 1, 1, 1, pushButProc | useWFont, 0L); /* amendment list */ - bounds.top = bounds.left = padding; - bounds.left = bounds.right + padding; - bounds.right = browser->win->portRect.right - SCROLLBAR_WIDTH - padding; + bounds.top = bounds.left = PADDING; + bounds.left = bounds.right + PADDING; + bounds.right = browser->win->portRect.right - SCROLLBAR_WIDTH - PADDING; - cell_size.v = (FontHeight(applFont, 9) * 2) + 2; + cell_size.v = (FontHeight(geneva, 9) * 2) + 2; browser->amendment_list = LNew(&bounds, &data_bounds, cell_size, AMENDMENT_LDEF_ID, browser->win, true, true, false, true); if (!browser->amendment_list) @@ -177,10 +184,10 @@ browser_init(struct repo *repo) (*(browser->amendment_list))->selFlags = lOnlyOne; /* diff text */ - bounds.top = (*browser->amendment_list)->rView.bottom + padding; - bounds.left = padding; - bounds.right = browser->win->portRect.right - SCROLLBAR_WIDTH - padding; - bounds.bottom = browser->win->portRect.bottom - padding; + bounds.top = (*browser->amendment_list)->rView.bottom + PADDING; + bounds.left = PADDING; + bounds.right = browser->win->portRect.right - SCROLLBAR_WIDTH - PADDING; + bounds.bottom = browser->win->portRect.bottom - PADDING; te_bounds = bounds; InsetRect(&te_bounds, 2, 2); browser->diff_te = TEStylNew(&te_bounds, &bounds); @@ -190,7 +197,7 @@ browser_init(struct repo *repo) TEActivate(browser->diff_te); /* scrollbar for diff text */ - bounds.right = browser->win->portRect.right - padding; + bounds.right = browser->win->portRect.right - PADDING; bounds.left = bounds.right - SCROLLBAR_WIDTH; bounds.bottom++; bounds.top--; @@ -260,8 +267,8 @@ browser_add_files(struct browser *browser) LDelRow(0, 0, browser->file_list); browser_show_amendment(browser, NULL); - TextFont(applFont); - TextSize(10); + TextFont(FILE_LIST_FONT); + TextSize(FILE_LIST_FONT_SIZE); LAddRow(1, cell.v, browser->file_list); LSetCell("[All Files]", 11, cell, browser->file_list); LSetSelect(true, cell, browser->file_list); @@ -562,8 +569,8 @@ browser_update(struct focusable *focusable, EventRecor InsetRect(&r, -1, -1); FillRect(&r, white); FrameRect(&r); - TextFont(applFont); - TextSize(10); + TextFont(FILE_LIST_FONT); + TextSize(FILE_LIST_FONT_SIZE); LUpdate(browser->win->visRgn, browser->file_list); r = (*(browser->amendment_list))->rView; @@ -572,8 +579,8 @@ browser_update(struct focusable *focusable, EventRecor FrameRect(&r); LUpdate(browser->win->visRgn, browser->amendment_list); - TextFont(applFont); - TextSize(11); + TextFont(DIFF_BUTTON_FONT); + TextSize(DIFF_BUTTON_FONT_SIZE); UpdtControl(browser->win, browser->win->visRgn); browser_update_menu(browser); @@ -615,8 +622,8 @@ browser_mouse_down(struct focusable *focusable, EventR nselected = browser_selected_file_ids(browser, &selected_files); /* in case any new items are redrawn in LClick */ - TextFont(applFont); - TextSize(10); + TextFont(FILE_LIST_FONT); + TextSize(FILE_LIST_FONT_SIZE); /* possibly highlight a new cell */ LClick(p, event->modifiers, browser->file_list); @@ -681,8 +688,8 @@ browser_mouse_down(struct focusable *focusable, EventR switch (part = FindControl(p, browser->win, &control)) { case inButton: - TextFont(applFont); - TextSize(11); + TextFont(DIFF_BUTTON_FONT); + TextSize(DIFF_BUTTON_FONT_SIZE); if (TrackControl(control, p, 0L) && control == browser->diff_button) browser->state = BROWSER_STATE_OPEN_COMMITTER; --- committer.c Tue Aug 16 16:56:14 2022 +++ committer.c Wed Aug 17 16:58:51 2022 @@ -28,12 +28,16 @@ #include "tetab.h" #include "util.h" +#define LABEL_FONT geneva +#define LABEL_FONT_SIZE 10 + +#define PADDING 10 + /* needed by diffreg */ struct stat stb1, stb2; long diff_format, diff_context, status = 0; char *ifdefname, *diffargs, *label[2], *ignore_pats; -static short padding = 10; struct committer *committer_diffing = NULL; bool committer_close(struct focusable *focusable); @@ -69,10 +73,10 @@ committer_init(struct browser *browser) /* main window, centered in its browser */ bounds = (*(((WindowPeek)browser->win)->strucRgn))->rgnBBox; - bounds.left += (padding / 2); - bounds.top += ((padding / 2) + MBarHeight); - bounds.right -= (padding / 2); - bounds.bottom -= (padding / 2); + bounds.left += (PADDING / 2); + bounds.top += ((PADDING / 2) + MBarHeight); + bounds.right -= (PADDING / 2); + bounds.bottom -= (PADDING / 2); memcpy(filename, browser->repo->bile->filename, sizeof(filename)); PtoCstr(filename); @@ -86,12 +90,12 @@ committer_init(struct browser *browser) SetPort(committer->win); /* log message */ - bounds.top = padding; + bounds.top = PADDING; bounds.left = 50; fh = FontHeight(monaco, 9); bounds.bottom = bounds.top + (fh * 5) + 2; bounds.right = committer->win->portRect.right - SCROLLBAR_WIDTH - - padding; + PADDING; te_bounds = bounds; InsetRect(&te_bounds, 2, 2); TextFont(monaco); @@ -113,12 +117,12 @@ committer_init(struct browser *browser) true, 1, 1, 1, scrollBarProc, 0L); /* diff */ - bounds.top = bounds.bottom + padding; - bounds.left = padding; - bounds.bottom = committer->win->portRect.bottom - 20 - padding - - padding; + bounds.top = bounds.bottom + PADDING; + bounds.left = PADDING; + bounds.bottom = committer->win->portRect.bottom - 20 - PADDING - + PADDING; bounds.right = committer->win->portRect.right - SCROLLBAR_WIDTH - - padding; + PADDING; te_bounds = bounds; InsetRect(&te_bounds, 2, 2); committer->diff_te = TEStylNew(&te_bounds, &bounds); @@ -136,11 +140,9 @@ committer_init(struct browser *browser) true, 1, 1, 1, scrollBarProc, 0L); /* commit button */ - TextFont(applFont); - TextSize(11); - bounds.left = committer->win->portRect.right - padding - 100; + bounds.left = committer->win->portRect.right - PADDING - 100; bounds.right = bounds.left + 100; - bounds.bottom = committer->win->portRect.bottom - padding; + bounds.bottom = committer->win->portRect.bottom - PADDING; bounds.top = bounds.bottom - 20; committer->commit_button = NewControl(committer->win, &bounds, "\pCommit", true, 1, 1, 1, pushButProc, 0L); @@ -220,9 +222,9 @@ committer_update(struct focusable *focusable, EventRec case -1: case updateEvt: r = (*(committer->log_te))->viewRect; - MoveTo(r.top, r.top + FontHeight(applFont, 11) - 2); - TextFont(applFont); - TextSize(11); + MoveTo(r.top, r.top + FontHeight(LABEL_FONT, LABEL_FONT_SIZE) - 2); + TextFont(LABEL_FONT); + TextSize(LABEL_FONT_SIZE); DrawText("Log:", 0, 4); r = (*(committer->log_te))->viewRect; @@ -237,7 +239,9 @@ committer_update(struct focusable *focusable, EventRec if ((*(committer->diff_te))->nLines > 0) { r = (*(committer->diff_te))->viewRect; - MoveTo(r.left, r.bottom + FontHeight(applFont, 10) + padding); + MoveTo(r.left, r.bottom + FontHeight(monaco, 9) + PADDING); + TextFont(monaco); + TextSize(9); len = snprintf((char *)buf, sizeof(buf), "%d (+), %d (-)", committer->diff_adds, committer->diff_subs); DrawText(buf, 0, len); @@ -321,8 +325,6 @@ committer_mouse_down(struct focusable *focusable, Even switch (part = FindControl(p, committer->win, &control)) { case inButton: - TextFont(applFont); - TextSize(11); if (TrackControl(control, p, 0L) && control == committer->commit_button) committer_commit(committer); @@ -392,11 +394,6 @@ committer_update_menu(struct committer *committer) EnableItem(edit_menu, EDIT_MENU_PASTE_ID); } - if ((*(committer->log_te))->nLines > 0 && committer->allow_commit) - HiliteControl(committer->commit_button, 0); - else - HiliteControl(committer->commit_button, 255); - DisableItem(repo_menu, REPO_MENU_ADD_FILE_ID); DisableItem(repo_menu, REPO_MENU_DISCARD_CHANGES_ID); DisableItem(repo_menu, REPO_MENU_APPLY_PATCH_ID); @@ -408,6 +405,11 @@ committer_update_menu(struct committer *committer) HUnlock(committer->diff_te); EnableItem(repo_menu, 0); + + if ((*(committer->log_te))->nLines > 0 && committer->allow_commit) + HiliteControl(committer->commit_button, 0); + else + HiliteControl(committer->commit_button, 255); } void --- commit_list.c Wed Aug 17 14:15:57 2022 +++ commit_list.c Wed Aug 17 17:10:07 2022 @@ -21,6 +21,9 @@ #include "repo.h" #include "util.h" +#define LIST_FONT geneva +#define LIST_FONT_SIZE 9 + void amendment_list_draw_cell(ListHandle theList, Cell theCell, short dataLen, Rect *cellRect, Boolean selected); @@ -73,10 +76,10 @@ amendment_list_draw_cell(ListHandle theList, Cell theC EraseRect(&textRect); InsetRect(&textRect, 4, 4); - height = FontHeight(applFont, 9); + height = FontHeight(LIST_FONT, LIST_FONT_SIZE); TextFace(bold); - TextFont(applFont); - TextSize(9); + TextFont(LIST_FONT); + TextSize(LIST_FONT_SIZE); MoveTo(textRect.left, textRect.top + 6); HLock(amendment->log); --- editor.c Wed Aug 17 14:25:10 2022 +++ editor.c Wed Aug 17 16:59:44 2022 @@ -27,8 +27,11 @@ #include "tetab.h" #include "util.h" -static short padding = 10; +#define LABEL_FONT geneva +#define LABEL_FONT_SIZE 10 +#define PADDING 10 + bool editor_close(struct focusable *focusable); void editor_idle(struct focusable *focusable, EventRecord *event); void editor_update(struct focusable *focusable, EventRecord *event); @@ -68,8 +71,9 @@ editor_init(struct browser *browser, struct repo_amend memcpy(filename, browser->repo->bile->filename, sizeof(filename)); PtoCstr(filename); - snprintf((char *)&title, sizeof(title), "%s: %s: Edit Amendment", - PROGRAM_NAME, (browser->repo ? (char *)filename : "No repo open")); + snprintf((char *)&title, sizeof(title), "%s: %s: Edit Amendment %d", + PROGRAM_NAME, (browser->repo ? (char *)filename : "No repo open"), + amendment->id); editor->win = NewWindow(0L, &bounds, CtoPstr(title), false, noGrowDocProc, (WindowPtr)-1L, true, 0); @@ -78,15 +82,15 @@ editor_init(struct browser *browser, struct repo_amend SetPort(editor->win); /* author */ - bounds.top = padding; - bounds.left = 60; - fh = FontHeight(applFont, 10); + bounds.top = PADDING; + bounds.left = 55; + fh = FontHeight(LABEL_FONT, LABEL_FONT_SIZE); bounds.bottom = bounds.top + fh + 4; bounds.right = 140; te_bounds = bounds; InsetRect(&te_bounds, 2, 2); - TextFont(applFont); - TextSize(10); + TextFont(LABEL_FONT); + TextSize(LABEL_FONT_SIZE); editor->author_te = TENew(&te_bounds, &bounds); TEAutoView(true, editor->author_te); TEActivate(editor->author_te); @@ -94,13 +98,13 @@ editor_init(struct browser *browser, struct repo_amend editor->author_te); /* date */ - bounds.top = bounds.bottom + padding; + bounds.top = bounds.bottom + PADDING; bounds.bottom = bounds.top + fh + 2; bounds.right = 200; te_bounds = bounds; InsetRect(&te_bounds, 2, 2); - TextFont(applFont); - TextSize(10); + TextFont(LABEL_FONT); + TextSize(LABEL_FONT_SIZE); editor->date_te = TENew(&te_bounds, &bounds); TEAutoView(true, editor->date_te); @@ -111,11 +115,11 @@ editor_init(struct browser *browser, struct repo_amend TEInsert(date, strlen(date), editor->date_te); /* log message */ - bounds.top = bounds.bottom + padding; + bounds.top = bounds.bottom + PADDING; fh = FontHeight(monaco, 9); - bounds.bottom = editor->win->portRect.bottom - 20 - (padding * 2); + bounds.bottom = editor->win->portRect.bottom - 20 - (PADDING * 2); bounds.right = editor->win->portRect.right - SCROLLBAR_WIDTH - - padding; + PADDING; te_bounds = bounds; InsetRect(&te_bounds, 2, 2); TextFont(monaco); @@ -139,11 +143,9 @@ editor_init(struct browser *browser, struct repo_amend true, 1, 1, 1, scrollBarProc, 0L); /* save button */ - TextFont(applFont); - TextSize(11); - bounds.left = editor->win->portRect.right - padding - 100; + bounds.left = editor->win->portRect.right - PADDING - 100; bounds.right = bounds.left + 100; - bounds.bottom = editor->win->portRect.bottom - padding; + bounds.bottom = editor->win->portRect.bottom - PADDING; bounds.top = bounds.bottom - 20; editor->save_button = NewControl(editor->win, &bounds, "\pSave", true, 1, 1, 1, pushButProc, 0L); @@ -201,27 +203,27 @@ editor_update(struct focusable *focusable, EventRecord case -1: case updateEvt: r = (*(editor->author_te))->viewRect; - MoveTo(padding, r.top + FontHeight(applFont, 11) - 2); - TextFont(applFont); - TextSize(11); + MoveTo(PADDING, r.top + FontHeight(LABEL_FONT, LABEL_FONT_SIZE) - 2); + TextFont(LABEL_FONT); + TextSize(LABEL_FONT_SIZE); DrawText("Author:", 0, 7); InsetRect(&r, -1, -1); FrameRect(&r); TEUpdate(&r, editor->author_te); r = (*(editor->date_te))->viewRect; - MoveTo(padding, r.top + FontHeight(applFont, 11) - 2); - TextFont(applFont); - TextSize(11); + MoveTo(PADDING, r.top + FontHeight(LABEL_FONT, LABEL_FONT_SIZE) - 2); + TextFont(LABEL_FONT); + TextSize(LABEL_FONT_SIZE); DrawText("Date:", 0, 5); InsetRect(&r, -1, -1); FrameRect(&r); TEUpdate(&r, editor->date_te); r = (*(editor->log_te))->viewRect; - MoveTo(padding, r.top + FontHeight(applFont, 11) - 2); - TextFont(applFont); - TextSize(11); + MoveTo(PADDING, r.top + FontHeight(LABEL_FONT, LABEL_FONT_SIZE) - 2); + TextFont(LABEL_FONT); + TextSize(LABEL_FONT_SIZE); DrawText("Log:", 0, 4); InsetRect(&r, -1, -1); FrameRect(&r); @@ -326,8 +328,6 @@ editor_mouse_down(struct focusable *focusable, EventRe switch (part = FindControl(p, editor->win, &control)) { case inButton: - TextFont(applFont); - TextSize(11); if (TrackControl(control, p, 0L) && control == editor->save_button) editor_save(editor);