diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-08 20:15:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-08 20:15:16 -0700 |
commit | 327a2242901a4c52cbd1130a1d155584549f877c (patch) | |
tree | 9a5fc34c910f09855fe0fdce6ef1698c1575195f | |
parent | c91333deea98660aea85dbb525933a6f198415cb (diff) | |
download | pw-327a2242901a4c52cbd1130a1d155584549f877c.tar.gz pw-327a2242901a4c52cbd1130a1d155584549f877c.tar.bz2 pw-327a2242901a4c52cbd1130a1d155584549f877c.zip |
Ctrl-G shows a few flags also, and -p restores them.
-rw-r--r-- | pw.1 | 18 | ||||
-rw-r--r-- | pw.c | 21 |
2 files changed, 30 insertions, 9 deletions
@@ -256,7 +256,8 @@ Shows the status of the display parameters, in a form which can be given to the .B -p option as an argument in order to re-create the same configuration. -The parameters are four non-negative integers, all in character units. +The parameters are five nonnegative integers, shown in decimal. The first for +are in character units; the fifth is a bitmask value. The documentation for the .B -p option explains the numbers. @@ -830,7 +831,7 @@ option. If neither option is used, then .I pattern is interpreted as a BRE. -.IP "\fB-p\fP [\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP]]]] +.IP "\fB-p\fP [\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP[,\fIinteger\fP]]]]] Specify the display parameters, as comma-separated non-negative integers. The meaning of these integer values is: .RS @@ -841,9 +842,18 @@ width of left pane; .IP 3. width of middle pane; and .IP 4. -middle pane view offset. +middle pane view offset; and +.IP 5. +bitmask of several flags controlling line number display +.RB ( # +command), highlighting +.RB ( Ctrl-I/Tab +command), and suspended mode +.RB ( Space +command). The values are internal and undocumented. + .PP -All four numbers are optional, and default to zero if omitted. Since +All five numbers are optional, and default to zero if omitted. Since .B -p requires an argument, the only way all four may be omitted is if a blank or empty argument is given. @@ -80,6 +80,7 @@ enum status_flags { stat_bkgnd = 0x0200, // running in the background stat_hlite = 0x0400, // running in the background stat_oneshot = 0x0800, // running in the background + stat_save = stat_susp | stat_lino | stat_hlite }; typedef enum execode { @@ -1161,9 +1162,10 @@ int main(int argc, char **argv) { char *err; char *hpos = strtok(optarg, ", \t"); - char *lpane = hpos ? strtok(0, ", \t") : 0; - char *rpane = lpane ? strtok(0, ", \t") : 0; - char *vs2pos = rpane ? strtok(0, ", \t") : 0; + char *lpane = strtok(0, ", \t"); + char *rpane = strtok(0, ", \t"); + char *vs2pos = strtok(0, ", \t"); + char *flags = strtok(0, ", \t"); if (hpos) { if ((pw.hpos = getznn(hpos, &err)) < 0) @@ -1188,6 +1190,14 @@ int main(int argc, char **argv) error("-%c option: bad right pane view offset %s: %s\n", opt, vs2pos, err); } + + if (flags) { + int stat = getznn(flags, &err); + if (stat < 0) + error("-%c option: bad flags %s: %s\n", + opt, flags, err); + pw.stat = stat & stat_save; + } } break; case 'e': @@ -1659,8 +1669,9 @@ int main(int argc, char **argv) pw.stat |= stat_force; break; case ctrl('g'): - snprintf(pw.cmdbuf, sizeof pw.cmdbuf, "-p %d,%d,%d,%d", - pw.hpos, pw.vsplit1, pw.vsplit2, pw.vs2pos); + snprintf(pw.cmdbuf, sizeof pw.cmdbuf, "-p %d,%d,%d,%d,%d", + pw.hpos, pw.vsplit1, pw.vsplit2, pw.vs2pos, + (int) pw.stat & stat_save); pw.curcmd = pw.cmdbuf; kbd_state = kbd_result; break; |