AmendHub

Download (as of this amendment):

jcs

/

textview

/

amendments

/

84

*: Minor cleanups


jcs made amendment 84 about 1 month ago
--- textview.h Wed Oct 14 23:20:34 2026 +++ textview.h Thu Oct 15 09:41:50 2026 @@ -122,7 +122,6 @@ struct TVRec { GrafPtr canvas; Handle canvas_baseaddr; short canvas_refcnt; - unsigned long canvas_size; GrafPtr canvas_old_port; Boolean canvas_dirty; @@ -178,7 +177,6 @@ struct TVFindInRectMatch { struct TVLine *line; struct TVStyle *style; struct TVSlab *text_slab; - char *text_slab_data; unsigned long text_start; unsigned long text_end; BigRect findrect; @@ -252,7 +250,7 @@ Boolean TVCalcLinesLocked(struct TVRec *tv, Boolean ig void TVApplyStyle(struct TVStyle *style); struct TVStyle * TVGetStyle(struct TVRec *tv, TVSlabLocator loc); struct TVStyle * TVFindStyle(struct TVRec *tv, struct TVStyle *style); -void TVScrollUnlocked(struct TVRec *tv, long horiz, long vert); +void TVScrollLocked(struct TVRec *tv, long horiz, long vert); Boolean TVFindInRectLocked(struct TVRec *tv, BigRect *findrect, long startline, TVFindInRectCallback callback, void *cookie); Boolean TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch *match, --- tv_draw.c Thu Oct 15 08:58:41 2026 +++ tv_draw.c Thu Oct 15 09:42:27 2026 @@ -108,7 +108,7 @@ TVTrackScrollControl(ControlHandle control, short part switch (part) { case inUpButton: if (cmd_down) { - TVScrollUnlocked(tv, 0, 1); + TVScrollLocked(tv, 0, 1); break; } @@ -117,22 +117,22 @@ TVTrackScrollControl(ControlHandle control, short part oline = TVGetLine(tv, top_line->nline - 1); if (oline == NULL) break; - TVScrollUnlocked(tv, 0, top_line->rect.top - + TVScrollLocked(tv, 0, top_line->rect.top - oline->rect.top + 1); break; } /* nothing found, just scroll to the top */ - TVScrollUnlocked(tv, 0, tv->bounds.bottom); + TVScrollLocked(tv, 0, tv->bounds.bottom); break; case inPageUp: /* scroll to put the top mostly-visible line at the bottom */ - TVScrollUnlocked(tv, 0, (long)tv->frame.bottom - + TVScrollLocked(tv, 0, (long)tv->frame.bottom - (tv->scrolled.top + top_line->rect.bottom) - 1); break; case inDownButton: if (cmd_down) { - TVScrollUnlocked(tv, 0, -1); + TVScrollLocked(tv, 0, -1); break; } @@ -141,13 +141,13 @@ TVTrackScrollControl(ControlHandle control, short part line = TVGetLine(tv, bottom_line->nline + 1); if (line == NULL) break; - TVScrollUnlocked(tv, 0, + TVScrollLocked(tv, 0, -(tv->scrolled.top - tv->frame.bottom + line->rect.bottom)); break; } /* nothing found, just scroll to the bottom */ - TVScrollUnlocked(tv, 0, -(tv->bounds.bottom)); + TVScrollLocked(tv, 0, -(tv->bounds.bottom)); break; case inPageDown: /* scroll to put the bottom mostly-visible line at the top */ @@ -155,13 +155,13 @@ TVTrackScrollControl(ControlHandle control, short part line = TVGetLine(tv, bottom_line->nline + 1); if (line == NULL) break; - TVScrollUnlocked(tv, 0, -(line->rect.top + tv->scrolled.top) + + TVScrollLocked(tv, 0, -(line->rect.top + tv->scrolled.top) + (line->rect.bottom - line->rect.top) + 1); break; } /* nothing found, just scroll to the bottom */ - TVScrollUnlocked(tv, 0, -(tv->bounds.bottom)); + TVScrollLocked(tv, 0, -(tv->bounds.bottom)); break; } @@ -177,7 +177,7 @@ TVScroll(TVHandle tvh, long horiz, long vert) tv = TVLock(tvh); div = TVScrollDivisor(tv); - TVScrollUnlocked(tv, horiz * div, vert * div); + TVScrollLocked(tv, horiz * div, vert * div); TVUnlock(tv); } @@ -194,7 +194,6 @@ TVUpdate(TVHandle tvh) Boolean TVSetupCanvas(struct TVRec *tv) { - struct TVLine *line; long width, height; GrafPtr old_port, canvas = NULL; Handle canvas_baseaddr = NULL; @@ -277,11 +276,10 @@ Boolean TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch *match, void *cookie) { - unsigned long n, j; + unsigned long n; long next_tabstop; unsigned char c; char *text, *spanstart; - short ts; Rect r; Point pen; @@ -303,20 +301,14 @@ TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch r.bottom = tv->scrolled.top + match->line->rect.bottom; EraseRect(&r); match->line->grew = false; - } else if (match->style->align == TV_ALIGN_CENTER) { + } else if (match->style->align == TV_ALIGN_CENTER || + match->style->align == TV_ALIGN_RIGHT) { /* erase from this chunk to the right of the view */ r.left = tv->scrolled.left + match->rect.left; r.top = tv->scrolled.top + match->line->rect.top; r.right = tv->scrolled.left + tv->view.right - tv->padding.right; r.bottom = tv->scrolled.top + match->line->rect.bottom; EraseRect(&r); - } else if (match->style->align == TV_ALIGN_RIGHT) { - /* erase from the right of the view to the right of the view */ - r.left = tv->scrolled.left + match->rect.left; - r.top = tv->scrolled.top + match->line->rect.top; - r.right = tv->scrolled.left + tv->view.right - tv->padding.right; - r.bottom = tv->scrolled.top + match->line->rect.bottom; - EraseRect(&r); } MoveTo(tv->scrolled.left + match->rect.left, @@ -334,7 +326,7 @@ TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch CopyBits(&match->style->bitmap, &thePort->portBits, &match->style->bitmap.bounds, &r, srcOr, NULL); } else if (tv->tabstop) { - text = match->text_slab_data + (match->text_start - + text = match->text_slab->data + (match->text_start - match->text_slab->base); spanstart = NULL; for (n = 0; n < match->text_end - match->text_start; n++) { @@ -349,7 +341,7 @@ TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch #if 0 /* draw dotted lines for tabs */ /* XXX: disabled for now but might be useful as an option */ - PenPat(&tabpat); + PenPat(&tv->tab_pat); MoveTo(pen.h, tv->scrolled.top + match->line->rect.top + ((match->line->rect.bottom - match->line->rect.top) / 2)); GetPen(&pen); @@ -368,7 +360,7 @@ TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch if (spanstart != NULL) DrawText(spanstart, 0, text - spanstart); } else - DrawText(match->text_slab_data + (match->text_start - + DrawText(match->text_slab->data + (match->text_start - match->text_slab->base), 0, match->text_end - match->text_start); tv->canvas_dirty = true; @@ -376,16 +368,11 @@ TVDrawMatch(struct TVRec *tv, struct TVFindInRectMatch } void -TVScrollUnlocked(struct TVRec *tv, long horiz, long vert) +TVScrollLocked(struct TVRec *tv, long horiz, long vert) { - struct TVChunk *chunk; - struct TVLine *line; - struct TVStyle *style; - struct TVSlab *text_slab; long wastop, top, wasleft, left; Rect r; RgnHandle vacated; - char *text_slab_data; if (!horiz && !vert) return; @@ -484,7 +471,9 @@ TVRevealCanvas(struct TVRec *tv) tv->canvas_old_port = NULL; tv->canvas_dirty = false; +#ifdef USE_CANVAS HUnlock(tv->canvas_baseaddr); +#endif } void --- tv_layout.c Wed Oct 14 23:54:43 2026 +++ tv_layout.c Thu Oct 15 09:52:52 2026 @@ -30,6 +30,9 @@ TVResize(TVHandle tvh) tv = TVLock(tvh); + SetRect(&tv->frame, 0, 0, tv->view.right - tv->view.left, + tv->view.bottom - tv->view.top); + TVUseCanvas(tv); EraseRect(&tv->frame); TVRevealCanvas(tv); @@ -46,8 +49,6 @@ TVResize(TVHandle tvh) return false; } #endif - SetRect(&tv->frame, 0, 0, tv->view.right - tv->view.left, - tv->view.bottom - tv->view.top); tv->bounds.right = tv->frame.right; tv->bounds.bottom = tv->padding.top + tv->padding.bottom; tv->scrolled = tv->bounds; @@ -432,7 +433,6 @@ prep_chunk: match.text_slab = TVGetTextSlab(tv, match.chunk->start); if (match.text_slab == NULL) goto draw_done; - match.text_slab_data = match.text_slab->data; match.style = TVGetStyle(tv, match.chunk->style); if (match.style == NULL) --- tv_select.c Wed Oct 14 21:51:28 2026 +++ tv_select.c Thu Oct 15 09:38:27 2026 @@ -56,7 +56,7 @@ TVClick(TVHandle tvh, Point p, Boolean extend) (unsigned long)TickCount() - tv->last_click_ticks <= GetDblTime() && dh >= -TV_DOUBLE_CLICK_SLOP && dh <= TV_DOUBLE_CLICK_SLOP && dv >= -TV_DOUBLE_CLICK_SLOP && dv <= TV_DOUBLE_CLICK_SLOP) - tv->click_count = (tv->click_count % 3) + 1; + tv->click_count = (tv->click_count % TV_UNIT_LINE) + 1; else tv->click_count = 1; tv->last_click_point = p; @@ -108,7 +108,7 @@ TVClick(TVHandle tvh, Point p, Boolean extend) if (amount > -1) amount = -1; } - TVScrollUnlocked(tv, 0, amount); + TVScrollLocked(tv, 0, amount); if (tv->scroller) TVUpdateScrollbar(tvh, tv->scroller); last_scroll = TickCount(); --- tv_store.c Wed Oct 14 22:27:58 2026 +++ tv_store.c Thu Oct 15 09:14:17 2026 @@ -69,8 +69,6 @@ TVAllocateSlab(struct TVRec *tv, unsigned long size, H Handle TVAllocateLineGroup(struct TVRec *tv, short groupn) { - short n; - if (groupn >= sizeof(tv->line_groups) / sizeof(tv->line_groups[0])) return NULL;