aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-29 02:31:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-29 02:31:30 -0700
commitbcab803191a240e87414d58fdb6112e9299cb72e (patch)
tree84810b10bd14671f91a13e73d425949935c99004
parent918dafb4a35bdb2b06d2d8c1bbe667ecface63ed (diff)
downloadpw-bcab803191a240e87414d58fdb6112e9299cb72e.tar.gz
pw-bcab803191a240e87414d58fdb6112e9299cb72e.tar.bz2
pw-bcab803191a240e87414d58fdb6112e9299cb72e.zip
New :i and :l commands to adjust intervals.
-rw-r--r--pw.118
-rw-r--r--pw.c15
2 files changed, 31 insertions, 2 deletions
diff --git a/pw.1 b/pw.1
index b90a34b..281ba17 100644
--- a/pw.1
+++ b/pw.1
@@ -298,7 +298,23 @@ status line disappears. If the optional
modifier is included in the command, then it pops the entire stack,
forgetting all the patterns and disabling grep mode.
+.IP "\fB:i\fP \fIreal\fP"
+Set the poll interval to the number of seconds specified by
+.IR real .
+See the description of the
+.B -i
+command line option for the argument format and semantics.
+
+.IP "\fB:l\fP \fIreal\fP"
+Set the long interval to the number of seconds specified by
+.IR real .
+See the description of the
+.B -i
+command option for the argument format and the
+.B -l
+option for the semantics.
.PP
+
Any other command results in a brief error message.
.SH OPTIONS
@@ -380,8 +396,6 @@ The program uses hard-coded ANSI sequences, so it doesn't support interesting
old terminals. On the other hand, it carries no dependency on any
terminal abstraction library/data.
-The intervals cannot be dynamically adjusted.
-
There is no support for unwrapping long lines, which would be useful for
copy and paste. However, the features like
.B :w
diff --git a/pw.c b/pw.c
index 6a4b5b2..826f0eb 100644
--- a/pw.c
+++ b/pw.c
@@ -474,6 +474,21 @@ static void execute(char *cmd, unsigned *pstat)
if (ngrep == 0)
*pstat &= ~stat_grep;
break;
+ case 'i': case 'l':
+ {
+ char *err = 0;
+ int interval = getms(arg, &err);
+
+ if (interval < 0)
+ snprintf(cmd, cmdsize, "%s", err);
+ else if (cmd[1] == 'i')
+ poll_interval = interval;
+ else
+ long_interval = interval;
+
+ dsdrop(err);
+ }
+ break;
default:
sprintf(cmd, "bad command");
break;