jcs
/textview
/amendments
/95
tv_draw: Abstract scroll guts to TVScrollParts so users can call it
This would be useful for handling Page Down the same way as clicking
inPageDown, by now calling TVScrollPart(tv, inPageDown, false).
jcs made amendment 95 8 days ago
--- textview.h Wed Nov 11 13:40:59 2026
+++ textview.h Tue Nov 17 20:30:23 2026
@@ -213,6 +213,7 @@ unsigned long TVGetText(TVHandle tvh, char *dst, unsig
long TVGetTextOffset(TVHandle tvh, Point p);
void TVBigRectToLocalRect(TVHandle tvh, BigRect *bigrect, Rect *rect);
void TVScroll(TVHandle tvh, long horiz, long vert);
+void TVScrollPart(TVHandle tvh, short part, Boolean fine);
void TVScrollToOffset(TVHandle tvh, unsigned long off);
Boolean TVCopy(TVHandle tvh);
void TVSetSelect(TVHandle tvh, unsigned long start, unsigned long end);
@@ -232,11 +233,11 @@ pascal void TVTrackScrollControl(ControlHandle control
/* NOTE: update TVFindStyle when additional fields are added */
#define ARE_STYLES_EQUAL(one, two) \
- ((one)->font == (two)->font && \
+ ((one)->tag == (two)->tag && \
+ (one)->font == (two)->font && \
(one)->style == (two)->style && \
(one)->size == (two)->size && \
(one)->align == (two)->align && \
- (one)->tag == (two)->tag && \
(one)->bitmap_data_size == (two)->bitmap_data_size)
struct TVRec * TVLock(TVHandle tvh);
--- tv_draw.c Wed Nov 11 13:39:56 2026
+++ tv_draw.c Tue Nov 17 20:39:20 2026
@@ -80,23 +80,34 @@ pascal void
TVTrackScrollControl(ControlHandle control, short part)
{
struct TVRec *tv;
- struct TVLine *top_line, *bottom_line, *line, *oline;
KeyMap km;
- Boolean horiz, cmd_down;
+ Boolean cmd_down;
if (tv_track_control == NULL) {
/* TVTrackScrollControl without TVSetTrackScrollControl */
Debugger();
return;
}
- tv = TVLock(tv_track_control);
-
- horiz = (((*control)->contrlRect.bottom - (*control)->contrlRect.top) <
- ((*control)->contrlRect.right - (*control)->contrlRect.left));
GetKeys(&km);
cmd_down = (km[1] & (1L << 15)) != 0;
+ TVScrollPart(tv_track_control, part, cmd_down);
+
+ tv = TVLock(tv_track_control);
+ if (control != tv->scroller)
+ SetCtlValue(control, -(tv->scrolled.top) / TVScrollDivisor(tv));
+ TVUnlock(tv);
+}
+
+void
+TVScrollPart(TVHandle tvh, short part, Boolean fine)
+{
+ struct TVRec *tv;
+ struct TVLine *top_line, *bottom_line, *line, *oline;
+
+ tv = TVLock(tvh);
+
top_line = TVGetLine(tv, TVLineForY(tv, -(tv->scrolled.top)));
bottom_line = TVGetLine(tv, TVLineForY(tv, -(tv->scrolled.top) +
tv->frame.bottom - 1));
@@ -107,7 +118,7 @@ TVTrackScrollControl(ControlHandle control, short part
switch (part) {
case inUpButton:
- if (cmd_down) {
+ if (fine) {
TVScrollLocked(tv, 0, 1);
break;
}
@@ -131,7 +142,7 @@ TVTrackScrollControl(ControlHandle control, short part
(tv->scrolled.top + top_line->rect.bottom) - 1);
break;
case inDownButton:
- if (cmd_down) {
+ if (fine) {
TVScrollLocked(tv, 0, -1);
break;
}
@@ -165,7 +176,9 @@ TVTrackScrollControl(ControlHandle control, short part
break;
}
- SetCtlValue(control, -(tv->scrolled.top) / TVScrollDivisor(tv));
+ if (tv->scroller)
+ SetCtlValue(tv->scroller,
+ -(tv->scrolled.top) / TVScrollDivisor(tv));
TVUnlock(tv);
}