jcs
/textview
/amendments
/38
Allow turning off re-calculation in TVAppend, add stubs for select/copy
For applications doing lots of small appends, it may be useful to
just do one TVCalcLines after adding a chunk of data
jcs made amendment 38 over 2 years ago
--- textview.c Fri Oct 25 12:04:47 2024
+++ textview.c Fri Oct 25 13:22:58 2024
@@ -89,6 +89,7 @@ TVNew(Rect *view, Rect *padding)
tv->cur_style = NO_STYLE;
tv->linewrap = true;
+ tv->autocalc = true;
if (!TVSetupCanvas(tv))
goto fail;
@@ -202,6 +203,11 @@ TVAppend(TVHandle tvh, struct TVStyle *style, char *te
chunk->need_recalc = true;
}
+ if (!tv->autocalc) {
+ ret = true;
+ goto append_done;
+ }
+
if (!TVCalcLinesLocked(tv, false))
goto append_done;
@@ -349,6 +355,16 @@ TVResize(TVHandle tvh)
}
void
+TVAutoCalc(TVHandle tvh, Boolean calc)
+{
+ struct TVRec *tv;
+
+ tv = TVLock(tvh);
+ tv->autocalc = calc;
+ TVUnlock(tv);
+}
+
+void
TVAutoScroll(TVHandle tvh, Boolean scroll)
{
struct TVRec *tv;
@@ -623,6 +639,16 @@ TVScroll(TVHandle tvh, short horiz, short vert)
TVScrollUnlocked(tv, (long)horiz * TVScrollDivisor(tv),
(long)vert * TVScrollDivisor(tv));
TVUnlock(tv);
+}
+
+void
+TVCopy(TVHandle tvh)
+{
+}
+
+void
+TVSetSelect(TVHandle tvh, unsigned long start, unsigned long end)
+{
}
void
--- textview.h Fri Oct 25 10:35:59 2024
+++ textview.h Fri Oct 25 13:25:50 2024
@@ -127,6 +127,10 @@ struct TVRec {
#define TV_LINE_GROUP_SIZE (sizeof(struct TVLine) * TV_LINE_GROUP_NLINES)
unsigned short nlines;
+ unsigned long sel_start;
+ unsigned long sel_end;
+
+ Boolean autocalc;
Boolean autoscroll;
Boolean linewrap;
unsigned char tabstop;
@@ -138,6 +142,7 @@ TVHandle TVNew(Rect *view, Rect *padding);
void TVDispose(TVHandle tvh);
Boolean TVAppend(TVHandle tvh, struct TVStyle *style, char *text,
unsigned long length);
+void TVAutoCalc(TVHandle tvh, Boolean calc);
void TVAutoScroll(TVHandle tvh, Boolean scroll);
void TVLineWrap(TVHandle tvh, Boolean wrap);
void TVTabStop(TVHandle tvh, unsigned char tabstop);
@@ -147,6 +152,8 @@ void TVUpdateScrollbar(TVHandle tvh, ControlHandle scr
void TVClick(TVHandle tvh, Point p, Boolean extend);
unsigned long TVGetOffset(TVHandle tvh, Point p);
void TVScroll(TVHandle tvh, short horiz, short vert);
+void TVCopy(TVHandle tvh);
+void TVSetSelect(TVHandle tvh, unsigned long start, unsigned long end);
void TVClear(TVHandle tvh);
Boolean TVCalcLines(TVHandle tvh);