tty: ensure that current status fields are always copied to prior status
values so that comparisons are correct
tty: fix an out of bounds error in tty_status_update() for BL_HUNGER case
-tty: fix leftover display artifact when last field on the row got smaller
- and optimize so only the right-most field requires the cleanup code
+tty: fix leftover display artifact when the last field on the row got placed
+ to the left of where it was previously due to it, or one of the fields
+ to its left, getting shorter
X11: its use of genl_status_update exposed a negative index use that could
lead to a segfault
tty_status[NOW][i].valid = FALSE;
tty_status[NOW][i].dirty = FALSE;
tty_status[NOW][i].redraw = FALSE;
- tty_status[NOW][i].padright = FALSE;
+ tty_status[NOW][i].padright = 0;
tty_status[BEFORE][i] = tty_status[NOW][i];
}
tty_condition_bits = 0L;
/* On a change to the field length, everything
further to the right must be updated as well */
- if (tty_status[NOW][idx].lth != tty_status[BEFORE][idx].lth) {
+ if (tty_status[NOW][idx].lth != tty_status[BEFORE][idx].lth)
update_right = TRUE;
- if ((tty_status[NOW][idx].lth < tty_status[BEFORE][idx].lth) &&
- idx == last_on_row[row])
- tty_status[NOW][idx].padright = TRUE;
+
+ if (idx == last_on_row[row]) {
+ int prevright = tty_status[BEFORE][idx].x
+ + tty_status[BEFORE][idx].lth,
+ currright = tty_status[NOW][idx].x
+ + tty_status[NOW][idx].lth;
+
+ if (currright < prevright)
+ tty_status[NOW][idx].padright = prevright - currright;
}
if (!update_right && !forcefields) {
term_end_color();
End_Attr(attridx);
}
- if (tty_status[NOW][fldidx].padright) {
- int cnt = tty_status[BEFORE][fldidx].lth
- - tty_status[NOW][fldidx].lth;
+ if (tty_status[NOW][fldidx].padright > 0) {
+ int cnt = tty_status[NOW][fldidx].padright;
+ /* .lth - 1 below because we already did the leading
+ blank above */
x += (tty_status[NOW][fldidx].lth - 1);
while (cnt-- > 0)
tty_putstatusfield(nullfield, " ", x++, y);
/* reset .redraw, .dirty, .padright now that they've been rendered */
tty_status[NOW][fldidx].dirty = FALSE;
tty_status[NOW][fldidx].redraw = FALSE;
- tty_status[NOW][fldidx].padright = FALSE;
+ tty_status[NOW][fldidx].padright = 0;
/*
* Make a copy of the entire tty_status struct for comparison