Commit fa35f348 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Clean up pass

Trim any #if FALSE switches over a decade old, and keep #if TRUE.
Accept EDIT2 and FMTTEXT1 bracketed code.
Remove unused internal functions txt1_dooaction txt1_dosetoaction.
Retagged as RISC_OSLib-5_85.
parent 99904b10
......@@ -255,8 +255,6 @@ void txt1_disposetextbuffer(txt);
int txt1_dobufsize(txt);
int txt1_dosetbufsize(txt, int);
txt_overflowaction txt1_dooaction(txt);
void txt1_dosetoaction(txt, txt_overflowaction);
txt_charoption txt1_docharoptions(txt);
void txt1_dosetcharoptions(txt, txt_charoption affect, txt_charoption values);
void txt1_dosetdisplayok(txt);
......
......@@ -145,18 +145,6 @@ BOOL txt_setbufsize(txt t, int size)
}
#endif
#if FALSE
txt_overflowaction txt_oaction(txt t)
{
return txt1_dooaction(t);
}
void txt_setoaction(txt t, txt_overflowaction o)
{
txt1_dosetoaction(t, o);
}
#endif
txt_charoption txt_charoptions(txt t)
{
return t->charoptionset;
......
......@@ -489,109 +489,6 @@ static int txt1__spaceavailable(txt t) /* size of gap */
};
}
#if FALSE
/* Never tried, and not useful. */
void txt1__deletefromfront(txt t, int n)
/* Delete characters from the front of the array, adding the resulting
space to the gap. The most important case is where the gap is right at
the end, in tty usage. */
{
txt1_bufindex base;
txt1_bufindex segtop;
int segsize;
txt_index place;
txt1_imarker *m;
if (0 != (txt_DISPLAY & t->charoptionset)) {
/* if (any deleted characters are visible then we take a
special route. */
base = txt1__firstchbi(t);
txt1__incbi(t, &base, n);
if (txt1__lessoreqbi(t, t->w->firstvis.pos, base)) {
place = txt1__bufindextoindex(t, t->gapend);
if (place < n) {place = 0;} else {place -= n;};
/* these routines will update firstvis.pos as appropriate */
txt1_dosetdot(t, 0);
txt1_dodelete(t, n);
txt1_dosetdot(t, place);
return;
};
};
/* normal case, chars to be deleted are not visible. */
while (n > 0) {
base = 0;
if (t->gapend < t->txtstart) base = t->gapend;
/* you won't meet t->gapstart below t->txtstart and above t->gapend,
because t->txtstart is not in the gap. */
/* using segsize from t->txtstart is tricky 'cos it might
equal t->gapstart. */
segtop = 1 + t->top;
if (t->gapstart >= t->txtstart) segtop = t->gapstart;
segsize = segtop - t->txtstart;
if (segsize > n) segsize = n;
if (segsize > 0) {/* i.e. gap not at t->txtstart */
memmove(
/*to*/ &(t->buf[base+segsize]),
/*from*/ &(t->buf[base]),
t->txtstart-base);
/* markers in the first segsize places must move up */
m = t->marksbefore;
while (m != NULL) {
if ((m->pos >= t->txtstart) && (m->pos < t->txtstart+segsize)) {
m->pos += segsize;
if (m->pos == t->top+1) m->pos = 0;
};
m = m->next;
};
txt1__incrawbi(t, &t->txtstart, segsize); /* could reach top+1 */
n -= segsize;
if (base == t->gapend) {
t->gapend += segsize;
} else {
/* the block move wraps round at the base of the buffer. */
if (t->gapend < (1+t->top-segsize)) {
/* t->gapend is not going to wrap round */
memmove(
/*to*/ &(t->buf[0]),
/*from*/ &(t->buf[1+t->top-segsize]),
segsize);
memmove(
/*to*/ &(t->buf[t->gapend+segsize]),
/*from*/ &(t->buf[t->gapend]),
(1+t->top-t->gapend)-segsize);
t->gapend += segsize;
} else {
/* t->gapend is going to wrap from top to bottom */
memmove(
/*to*/ &(t->buf[segsize - (1+t->top-t->gapend)]),
/*from*/ &(t->buf[t->gapend]),
1+t->top-t->gapend);
t->gapend = segsize - (1+t->top-t->gapend);
};
};
if (t->txtstart == t->top+1) t->txtstart = 0;
/* markers after the gap must move up */
m = t->marksafter;
while (m != NULL) {
txt1__incrawbi(t, &m->pos, segsize);
m = m->next;
};
txt1__updatescrollbar(t);
txt1__checkbufinvariant(t, "dff");
} else {
/* the gap is at the start of the array. */
txt1_dodelete(t, n);
n = 0;
};
};
}
#endif
static int txt1__ensurespace(txt t, int space)
/* Ensure that the gap leaves at least the specified amount of space,
extending if necessary. This may in fact not be possible, e.g. extension not
......@@ -649,23 +546,6 @@ BOOL txt1_dosetbufsize(txt t, int b) /* returns FALSE if can't. */
}
#endif
/* >>>> not extensively used or tested! */
/* >>>> do error handling right! */
#ifndef UROM
txt_overflowaction txt1_dooaction(txt t)
{
return t->oaction;
}
#endif
#ifndef UROM
void txt1_dosetoaction(txt t, txt_overflowaction o)
{
t->oaction = o;
}
#endif
void txt1_dosetcharoptions(txt t,
txt_charoption affect, txt_charoption values)
{
......@@ -916,13 +796,6 @@ BOOL txt1__lessoreqbi(txt t, txt1_bufindex a, txt1_bufindex b)
};
}
#if FALSE /* not used! */
static txt1_bufindex txt1__maxbi(txt t, txt1_bufindex a, txt1_bufindex b)
{
if (txt1__lessthanbi(t, a, b)) {return b;} else {return a;};
}
#endif
/* -------- Public operations on the array of characters. -------- */
txt_index txt1_dodot(txt t)
......@@ -1172,11 +1045,7 @@ directly, to reduce redraw and flicker. */
t->w->caretoffsetx = 0;
t->w->caretoffsety = 0;
spaces = " "; /* 40 of them */
#if FALSE
for (n1 = 1; nspaces > 0 /* n1 <= (nspaces + 39) / 40 */; n1++) {
#else
while (nspaces > 0) {
#endif
txt1_doreplacechars(t, 0, spaces, txt1__min(40, nspaces));
txt1_domovedot(t, txt1__min(40, nspaces));
nspaces -= 40;
......@@ -1481,14 +1350,8 @@ void txt1_domovehorizontal(txt t, int by)
) {
/* he is sticking out at the end of a line. */
tracef0("horiz movement.\n");
#if TRUE
t->w->caretoffsetx = txt1__max(0, t->w->caretoffsetx + by*spacewidth);
by = 0; /* prevent further looping. */
#else
/* bug found 20-Jan-89, prevented by>1 from working. */
t->w->caretoffsetx += (by > 0 ? spacewidth : -spacewidth);
if (t->w->caretoffsetx < 0) t->w->caretoffsetx = 0;
#endif
} else {
tracef0("no horiz movement.\n");
/* domovedot, with one funny case. */
......@@ -1874,22 +1737,6 @@ static void txt1__paintcall(
t->calls = c;
}
#if FALSE /* caller has now been removed */
static BOOL txt1__callsequaloryshifted(txt1_call *c1, txt1_call *c2, txt1_zits byy)
/* This is used to chop off the tail of the display of a large paragraph,
see displayreplace2. A difference in y coordinate is permissable, by byy. */
{
if (c1==NULL || c2==NULL) return c1==c2;
return (c1->x == c2->x)
&& (c1->y + byy == c2->y)
&& (c1->ad == c2->ad)
&& (c1->n == c2->n)
&& (c1->width == c2->width)
&& (c1->highlight == c2->highlight)
&& (c1->callendopt == c2->callendopt);
}
#endif
static void txt1__reverseorderofcalls(txt t)
/* standard reverse-in-place of a singly linked list. */
{
......@@ -2527,27 +2374,6 @@ the window and avoiding a total repaint. */
txt1__cancelcalls(t, NULL);
}
#if FALSE
/* not used */
void txt1__redisplaybetween(txt t, txt1_zits ymin, txt1_zits ymax)
/* Redisplay any lines of the window between the stated limits. You are
assured that t->w->caretx/y etc. are correct and reasonable, e.g. so you
don't have to measure things up beyond ymin. */
{
txt1_zits x;
txt1_zits y;
x = t->w->caretx;
y = t->w->carety;
if (! txt1__measureback(t,
&x, &y, ymin, &t->w->caret.pos, txt1__firstchbi(t), TRUE)) {
txt1__assert(FALSE, "rb");
};
txt1__displayfrom(t, t->w->caretx, t->w->carety, t->w->caret.pos);
txt1__paintallcalls(t);
}
#endif
void txt1__displayfrom(txt t, txt1_zits x, txt1_zits y, txt1_bufindex at)
/* Display the characters from at onwards in the window, starting at the
value of (x,y). Do not assume that at==bufend. If you reach the end
......@@ -3014,9 +2840,6 @@ insline and delline then common them up, setting xs to 0. */
txt1_bufindex lineend;
txt1_bufindex atinsend;
txt1_bufindex atdelend;
#if FALSE
txt1_call *c;
#endif
txt1_call *callsinsend;
BOOL giveup;
......@@ -3299,12 +3122,7 @@ not really clear. */
txt1_domovedot(t, moveamount);
} else { /* short drag */
#if FALSE
int nlines = t->w->limy / t->w->linesep;
txt1_scrollbarmoveby(t, (nlines * by) / t->w->isize);
#else
txt1_scrollbarmoveby(t, 1);
#endif
};
}
......
......@@ -82,12 +82,6 @@ BOOL txt3_preparetoaddwindow(txt t)
txt1_donewmarker(t, &t->w->firstvis);
txt1_donewmarker(t, &t->w->lastvis);
txt1_donewmarker(t, &t->w->caret);
#if FALSE
txt_movemarker(t, (txt_marker*) &t->w->firstvis,
txt_indexofmarker(t, (txt_marker*) &parent->firstvis));
txt_movemarker(t, (txt_marker*) &t->w->lastvis,
txt_indexofmarker(t, (txt_marker*) &parent->lastvis));
#endif
return TRUE;
};
}
......
......@@ -164,24 +164,12 @@ static BOOL txtar__closefontsregistered = FALSE;
/* -------- Creating and destroying windows. -------- */
#if TRUE
#define INITSTARTY 0
static txt1_zits txtar__startx = 100;
static txt1_zits txtar__starty = INITSTARTY;
#define CREATESIZEX (1080-44)
#define CREATESIZEY 448
#else
#define INITSTARTY 500
txt1_zits txtar__startx = 300;
txt1_zits txtar__starty = INITSTARTY;
#define CREATESIZEX 580
#define CREATESIZEY 300
#endif
static int txtar__xppinch(void)
{
return 180 / wimpt_dx();
......@@ -369,12 +357,6 @@ static void txtar__dosettitle(txt t, char *title)
strncpy(&s->titlebuf[0], title, TITLEBUFMAX);
s->titlebuf[TITLEBUFMAX] = 0;
r.w = (wimp_w) -1; /* redraw in absolute screen coords */
#if FALSE
r.box.x0 = s->d->info.box.x0;
r.box.y0 = 32 - s->d->info.box.y0; /* >>>> mode-specific? */
r.box.x1 = 36 + s->d->info.box.x1;
r.box.y1 = s->d->info.box.y1;
#endif
r.box = s->d->info.box;
r.box.y1 += 36;
r.box.y0 = r.box.y1 - 36;
......@@ -479,11 +461,7 @@ static BOOL txtar__tryfont(txt t, char *fontname, int width, int height)
tracef1(" fonth=%i.\n", f);
if (f == (font) NULL || e != NULL) {
tracef0("font not found.\n");
#if FALSE
werr(FALSE, "Font '%s' not found", fontname);
#else
werr(FALSE, e->errmess);
#endif
return FALSE;
};
......@@ -668,11 +646,6 @@ so that drag-size-change works. */
/* the wimp doesn't like you doing this in a redraw-> */
/* redraw always ends with one of these with withinredraw==FALSE. */
tracef0(" (setsize delayed).\n");
#if FALSE
if (txtar__setsizepending) { /* 21-Nov-88 WRS bughunt! */
werr(FALSE, "set size already pending!!!");
};
#endif
txtar__setsizepending = TRUE;
return;
};
......@@ -1027,14 +1000,8 @@ static void txtar__grmoveto(int x, int y)
static void txtar__setgrcolour(int c)
{
#if FALSE
bbc_vdu(18); /* set graphics colour */
bbc_vdu(0); /* overwrite mode */
bbc_vdu(c); /* colour: top bit -> background */
#else
wimp_setcolour(c);
/* colour in 0..3, gcol action in 4..6, fg/bg in 7 */
#endif
}
static void txtar__paintseveral(
......@@ -1101,13 +1068,8 @@ perhaps some work could be done to reduce this. */
calls = calls->next;
};
#if FALSE
scx = s->d->info.box.x0 - s->d->info.scx +
wimpt_dx() * (1 + (thiscall.x * txtar__xppinch()) / 72000);
#else
scx = s->d->info.box.x0 - s->d->info.scx +
wimpt_dx() * (s->o.margin + (thiscall.x * txtar__xppinch()) / 72000);
#endif
scy = (s->d->info.box.y1 /* >>>> - wimpt_dy() */ ) - thiscall.y;
if (
......@@ -1407,15 +1369,9 @@ improves the display of italic characters. */
/*
scx + wimpt_dx() * (1 + (width * xppinch()) / 72000)),
*/
#if FALSE
s->d->info.box.x0 - s->d->info.scx +
wimpt_dx() * (/*margin*/1 +
((thiscall.x + thiscall.width) * txtar__xppinch()) / 72000)),
#else
s->d->info.box.x0 - s->d->info.scx +
wimpt_dx() * (s->o.margin +
((thiscall.x + thiscall.width) * txtar__xppinch()) / 72000)),
#endif
scy);
bbc_plot(103, s->d->info.box.x1, scy + t->w->linesep - 1);
} else {
......@@ -1512,18 +1468,6 @@ improves the display of italic characters. */
};
};
#if FALSE
if (thiscall.highlight) {
/* current version: inv-vid after the event. */
txtar__grmoveto(scx, scy);
bbc_vdu(18); bbc_vdu(3); bbc_vdu(7); /* xor bottom three bits */
bbc_plot(96+4+1,
scx + wimpt_dx() * ((thiscall.width *
txtar__xppinch()) / 72000) /*- 1*/,
scy + t->w->linesep - 1);
};
#endif
};
};
......@@ -1544,9 +1488,6 @@ static void txtar__rawpaintseveral(txt t, txt1_call *calls, BOOL alreadycorrect)
{
txtar__sysdata *s = (txtar__sysdata*) t->w->syshandle;
BOOL r;
#if FALSE
int i;
#endif
if (txtar__withinredraw) {
/* We are nested within performredraw below. */
......@@ -1580,17 +1521,6 @@ static void txtar__rawpaintseveral(txt t, txt1_call *calls, BOOL alreadycorrect)
} else {
tracef0("window totally invisible?\n");
};
#if FALSE
/* re-complain about any rectangles invalid from a rawcopylines. */
for (i=1; i<=txtar__invalidboxcount; i++) {
txtar__redrawdata.w = (wimp_w) -1;
txtar__redrawdata.box = txtar__invalidbox[i-1];
tracef4("invalidate %i %i %i %i.\n",
txtar__invalidbox[i-1].x0, txtar__invalidbox[i-1].x1,
txtar__invalidbox[i-1].y0, txtar__invalidbox[i-1].y1);
wimpt_noerr(wimp_force_redraw(&txtar__redrawdata));
};
#endif
};
if (txtar__font_paint_error) {
txtar_options o;
......@@ -1683,19 +1613,6 @@ allow the caret to disappear. This is the correct behaviour, I think. */
int viswidth;
BOOL move;
#if FALSE
/* Experiment: showing the caret clears the caret bit in all other
windows. To help CLI windows. */
{
txtar__sysdata *p = all;
while (p != 0) {
if (p != s) {
p->t->charoptionset &= ~txt_CARET;
};
p = p->next;
};
};
#endif
#if TRUE
/* Experiment: showing the caret clears the caret bit in all other
windows. To help CLI windows. */
......@@ -1732,16 +1649,7 @@ allow the caret to disappear. This is the correct behaviour, I think. */
move = TRUE;
};
if (move) {
#if FALSE
o.w = s->w;
o.box = s->d->info.box;
o.x = s->d->info.scx;
o.y = s->d->info.scy;
o.behind = s->d->info.behind;
wimpt_noerr(wimp_open_wind(&o));
#else
wimpt_noerr(wimp_open_wind((wimp_openstr*) s->d));
#endif
txtar__verify(s);
};
}
......@@ -1959,21 +1867,6 @@ static void txtar__performredraw(txt t)
/* -------- Processing events. -------- */
#if FALSE
static msgref = 1;
void txtar_movetoback(txt t)
{
txtar__sysdata *s = (txtar__sysdata*) t->w->syshandle;
wimp_wstate state;
wimpt_noerr(wimp_get_wind_state(s->w, &state));
state.o.behind = (wimp_w) -2;
wimpt_noerr(wimp_open_wind(&state.o));
win_give_away_caret();
}
#endif
#define DELAY_BEFORE_HOURGLASS 200
static void txtar__visdelay_begin(void)
......@@ -2009,20 +1902,10 @@ static void txtar__textwimpevent(wimp_eventstr *e, void *handle)
};
break;
case wimp_EREDRAW:
#if FALSE
if (wimpt_checkmode()) ;
/* >>>> Dreadful frig: is this right? */
if (wimpt_mode() != s->screenmode) {
txtar__setmode(s);
txtar__dosetoptions(t, &s->o);
};
#else
/* bugfix 10-Feb-94 WRS - explained in c.wimpt */
if (wimpt_checkmode() || wimpt_mode() != s->screenmode) {
txtar__setmode(s);
txtar__dosetoptions(t, &s->o);
};
#endif
txtar__visdelay_begin();
txtar__performredraw(t);
txtar__visdelay_end();
......@@ -2053,21 +1936,6 @@ static void txtar__textwimpevent(wimp_eventstr *e, void *handle)
txtar__visdelay_begin();
txt3_setprimarywindow(t, s);
tracef1("scroll by %i.\n", e->data.scroll.y);
#if FALSE
/* he produces +/-1 for clicks in the arrow boxes, +/-2 in the rest
of the scroll bar. we'll take that latter as meaning a page. */
if (e->data.scroll.y == 2) {
txt1_scrollbarmoveby(t,
0 - (t->w->limy + t->w->linesep - 1) / t->w->linesep);
} else if (e->data.scroll.y == -2) {
txt1_scrollbarmoveby(t,
(t->w->limy + t->w->linesep - 1) / t->w->linesep);
} else { /* by 1 */
txt1_scrollbarmoveby(t, -e->data.scroll.y);
};
/* -ve means move backwards in the array, i.e. the "up" button.
this is the reverse of what arthur gives to us. */
#endif
if (e->data.scroll.y == -2) {
txtar__docharevent(t, txt_EXTRACODE + akbd_Sh + akbd_DownK);
/* turn into "move a page" */
......@@ -2178,30 +2046,11 @@ in order to cancel this effect successfully. */
tracef1("thumb to %i.\n", offset);
#if FALSE
{ wimp_mousestr m;
wimp_get_point_info(&m);
if (m.x == txtar__lastthumbmouse.x
/* && m.y == txtar__lastthumbmouse.y */
&& ((offset >= 0) != (txtar__lastthumbdir >= 0))) {
tracef0("Thumb ignored: mouse has not moved since last one.\n");
return;
} else {
txtar__lastthumbmouse = m;
};
};
txtar__lastthumbdir = offset;
#else
{ wimp_mousestr m;
BOOL ignore = FALSE;
wimp_get_point_info(&m);
tracef1("mouse bbits=%i.\n", m.bbits);
#if FALSE
if (m.bbits == 0) {
tracef0("not dragging.\n");
} else
#endif
if (txtar__lastthumbmouse.bbits == 0) {
tracef0("not already thumbing - no shortcuts.\n");
} else if (m.y > txtar__lastthumbmouse.y
......@@ -2232,7 +2081,6 @@ in order to cancel this effect successfully. */
win_claim_idle_events(s->w);
};
};
#endif
size = s->d->info.ex.y1 - s->d->info.ex.y0;
vissize = s->d->info.box.y1 - s->d->info.box.y0;
......@@ -2249,15 +2097,7 @@ in order to cancel this effect successfully. */
} else if (offset < 0) {
tracef0("thumb forwards in text.\n");
offset = - offset;
#if FALSE
vispos = txtar__max(0, - ((txtar__screenheight() / 2) + s->d->info.ex.y0)) - vissize;
if (vispos <= 0) vispos = 1;
#else
vispos = - s->d->info.ex.y0 - vissize;
#if FALSE
if (vispos <= txtar__screenheight()) vispos = 1; /* if close to end, go all the way. */
#endif
#endif
dist = (offset * 100) / vispos;
tracef1(" thumbforw(t, %i percent);\n", dist);
if (dist > 100) dist = 100;
......@@ -2271,9 +2111,6 @@ static void txtar__doopenevent(txt t, wimp_openstr *o /*in*/)
txtar__sysdata *s = (txtar__sysdata*) t->w->syshandle;
BOOL sizechange;
BOOL move;
#if FALSE
BOOL wasfull = (s->d->info.flags & wimp_WFULL) != 0;
#endif
tracef4("open event: to (%i,%i,%i,%i).\n",
o->box.x0, o->box.y0, o->box.x1, o->box.y1);
......@@ -2343,24 +2180,8 @@ static void txtar__doopenevent(txt t, wimp_openstr *o /*in*/)
/* A redraw forces a recalculation of scroll bar and cursor. */
} else {
#if FALSE
/* if you do anything to a window, it becomes the input focus. */
/* There are some size change cases which are a little delicate, however:
e.g. in the redrawtext case above, we are relying on the redraw to
put the caret right, it could be outside the window at the moment
causing set-caret to cause auto-movement, etc., ...stack overflow.
So, just set the caret when size has not changed. */
(void) txtar__setarthurcaret(t, 0 != (txt_CARET & t->charoptionset));
#endif
};
/* If we've just been toggled, may set the caret. */
#if FALSE
/* Style Guide says no, leave the friggin caret alone */
if ((s->d->info.flags & wimp_WFULL) != 0 && !wasfull) {
txt_setcharoptions(s->t, txt_CARET, txt_CARET);
};
#endif
};
#if TRACE
txtar__checkwinfo(t);
......@@ -2431,28 +2252,6 @@ drag event. */
x,