From f46115c8fbef8b68bdb426cf7d25ba84b864cdbe Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 30 Apr 2022 14:29:13 -0700 Subject: New a, d commands to advance or delay triggers. --- pw.1 | 10 ++++++++++ pw.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pw.1 b/pw.1 index 1cc8bc7..0738873 100644 --- a/pw.1 +++ b/pw.1 @@ -289,6 +289,16 @@ is shown followed by the list of triggers in parentheses. Patterns which have a position other than 1 are preceded by the position shown in square brackets. +.IP "[\fIcount\fP]\fBa\fP, [\fIcount\fP]\fBd\fP" +Advance or delay the currently active triggers by +.I count +lines, defaulting to 1. Advancing means that all of the triggers are assigned +to more recently received lines closer to the head of the FIFO. +on earlier data. Delaying is the opposite: the triggers are assigned to +less recently received items, closer to the tail of the FIFO. +The advance/delay commands will not move any trigger to a position which +corresponds to a line that is not displayed. + .IP "[\fIcount\fP]\fB+\fP" Increases the display size by .I count diff --git a/pw.c b/pw.c index 4c25464..81494de 100644 --- a/pw.c +++ b/pw.c @@ -909,6 +909,34 @@ int main(int argc, char **argv) cmdbuf[1] = 0; curcmd = cmdbuf; break; + case 'a': case 'd': + if ((stat & (stat_htmode | stat_ttmode))) { + int step = ((((stat & stat_htmode) && ch == 'a') || + ((stat & stat_ttmode) && ch == 'd')) + ? -1 : 1); + + if (cmdcount == UINT_MAX) + cmdcount = 1; + + if (step < 0) { + for (; cmdcount && !triglist[0]; cmdcount --) { + memmove(triglist, triglist + 1, + (maxtrig - 1) * sizeof *triglist); + triglist[maxtrig - 1] = 0; + } + } else if (nlines <= maxtrig) { + for (; (cmdcount && + !triglist[nlines - 1] && + !triglist[maxtrig - 1]); + cmdcount --) + { + memmove(triglist + 1, triglist, + (maxtrig - 1) * sizeof *triglist); + triglist[0] = 0; + } + } + } + break; case '+': if (ws.ws_row && maxlines >= ws.ws_row - 1) { break; -- cgit v1.2.3