From 3be6a458fd8ee9b11112cac61bbdbec2d0b2b101 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 8 May 2022 23:02:54 -0700 Subject: New :p command; :s saves display params too. --- pw.1 | 9 +++++++-- pw.c | 20 ++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pw.1 b/pw.1 index a43eda4..08c4401 100644 --- a/pw.1 +++ b/pw.1 @@ -669,6 +669,11 @@ the trigger count is reset to zero. Thus when the command is used to resume capture, the same number of capture events will have to occur again before the next automatic suspension. +.IP "\fB:p\fP [\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP]]]]] +Sets the display parameters, exactly in the manner of the +.B -p +option. + .IP "\fB:s\fP [\fIfilename\fP]" Save a snapshot of the configuration state to the specified file. The state is saved as a sequence of colon and trigger commands, @@ -682,8 +687,8 @@ is started up with .I filename as the argument to the .B -f -option, the grep stack and trigger state will be stored to exactly -the same configuration that existed at the time the state was saved. +option, the grep stack, trigger state and display parameters will be stored to +exactly the same configuration that existed at the time the state was saved. .SH OPTIONS diff --git a/pw.c b/pw.c index 1e4ce19..174dac4 100644 --- a/pw.c +++ b/pw.c @@ -709,17 +709,18 @@ static int decodeparms(pwstate *pw, char *parms, snprintf(resbuf, size, "bad flags %s: %s\n", flags, err); return 0; } - pw->stat = stat & stat_save; + pw->stat &= ~stat_save; + pw->stat |= (stat & stat_save); } return 1; } -static execode execute(pwstate *pw, const char *cmd, char *resbuf, +static execode execute(pwstate *pw, char *cmd, char *resbuf, size_t size, int count) { execode res = exec_failed; - const char *arg = cmd + 2 + strspn(cmd + 2, " \t"); + char *arg = cmd + 2 + strspn(cmd + 2, " \t"); clrline(0); @@ -874,6 +875,14 @@ static execode execute(pwstate *pw, const char *cmd, char *resbuf, res = exec_ok; } break; + case 'p': + { + if (decodeparms(pw, arg, resbuf, size)) { + pw->stat |= stat_force; + res = exec_ok; + } + } + break; case 's': { int rflg = 0; @@ -889,6 +898,9 @@ static execode execute(pwstate *pw, const char *cmd, char *resbuf, break; } + fprintf(f, ":p%d,%d,%d,%d,%d\n", pw->hpos, pw->vsplit1, pw->vsplit2, + pw->vs2pos, (int) pw->stat & stat_save); + if (pw->tcount) fprintf(f, ":f%d\n", pw->tcount); if (pw->sncount) @@ -998,7 +1010,7 @@ static execode execute(pwstate *pw, const char *cmd, char *resbuf, return res; } -static execode batchexe(pwstate *pw, const char *cmd, char *resbuf, size_t size) +static execode batchexe(pwstate *pw, char *cmd, char *resbuf, size_t size) { size_t ndigits = strspn(cmd, "0123456789"); int count = 0; -- cgit v1.2.3