From 5c30cf42afdfebbc78b391bcdecd233af1442176 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 2 May 2022 20:58:39 -0700 Subject: Ensure clrline calls observe background mode. --- pw.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pw.c b/pw.c index 2ef63a5..ee34f18 100644 --- a/pw.c +++ b/pw.c @@ -317,9 +317,10 @@ static int grexec(grep *gr, const char *line) return match != gr->inv; } -static void clrline() +static void clrline(unsigned stat) { - printf("\r\033[J"); + if ((stat & stat_bkgnd) == 0) + printf("\r\033[J"); } static void clreol(int nl) @@ -470,7 +471,7 @@ static unsigned redraw(char **circbuf, int nlines, unsigned hpos, unsigned hist, drawline(snapshot[hist][i], hpos, columns, l); } } else { - clrline(); + clrline(stat); } drawstatus(hist, columns, stat, cmd); @@ -536,7 +537,7 @@ static void execute(char *cmd, unsigned *pstat, unsigned hist) { char *arg = cmd + 2 + strspn(cmd + 2, " \t"); - clrline(); + clrline(0); cmd[0] = 0; switch (cmd[1]) { @@ -841,7 +842,7 @@ int main(int argc, char **argv) exit_status = 0; if (auto_quit) { if ((stat & stat_bkgnd) == 0) - clrline(); + clrline(stat); break; } } @@ -894,7 +895,7 @@ int main(int argc, char **argv) if ((stat & (stat_susp | stat_bkgnd)) == 0) { snapshot[0] = resizebuf(snapshot[0], snaplines[0], snaplines[0] + 1); snapshot[0][snaplines[0]++] = dsref(line); - clrline(); + clrline(stat); drawline(line, hpos, columns, -1); drawstatus(hist, columns, stat, curcmd); } @@ -992,7 +993,7 @@ int main(int argc, char **argv) if (kbd_state == kbd_esc || kbd_state == kbd_result) { kbd_state = kbd_cmd; curcmd = 0; - clrline(); + clrline(stat); drawstatus(hist, columns, stat, curcmd); } } @@ -1341,7 +1342,7 @@ int main(int argc, char **argv) stat = redraw(circbuf, nlines, hpos, hist, columns, stat, curcmd); } else switch (kbd_state) { case kbd_colon: case kbd_trig: case kbd_result: case kbd_cmd: - clrline(); + clrline(stat); drawstatus(hist, columns, stat, curcmd); } } else { @@ -1351,7 +1352,7 @@ int main(int argc, char **argv) } if ((stat & stat_bkgnd) == 0) { - clrline(); + clrline(stat); ttyset(ttyfd, &tty_saved); } -- cgit v1.2.3