aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pw.110
-rw-r--r--pw.c41
2 files changed, 45 insertions, 6 deletions
diff --git a/pw.1 b/pw.1
index f4b3f21..04d0a24 100644
--- a/pw.1
+++ b/pw.1
@@ -210,6 +210,16 @@ assigned to the middle pane. After that, the width of the pane can be
adjusted without affecting what portion of the line it shows, independently
of any horizontal scrolling adjustments occurring in the right pane.
+.IP "\fBCtrl-I, Tab\fP"
+Toggle the highlighting of separator characters appearing in the line
+display. The when toggled on, the
+.BR > ,
+.B <
+and
+.B |
+characters which indicate line truncation and pane separation are
+shown in inverse video (dark foreground, light background).
+
.IP \fISpace\fP
Suspend the acquisition of new snapshots. In suspended mode,
input continues to pass through the FIFO, but new snapshots of data aren't
diff --git a/pw.c b/pw.c
index 9daaf5e..38d08b4 100644
--- a/pw.c
+++ b/pw.c
@@ -76,7 +76,8 @@ enum status_flags {
stat_grep = 64, // grep mode
stat_force = 128, // force refresh even if clean
stat_lino = 256, // render line numbers
- stat_bkgnd = 512 // running in the background
+ stat_bkgnd = 512, // running in the background
+ stat_hlite = 1024 // running in the background
};
typedef struct pwstate {
@@ -337,6 +338,29 @@ static void clreol(int nl)
putchar('\n');
}
+static void hlon(void)
+{
+ printf("\033[7m");
+}
+
+static void hloff(void)
+{
+ printf("\033[m");
+}
+
+#define with_hl(pw, expr) do { \
+ if ((pw)->stat & stat_hlite) \
+ hlon(); \
+ expr; \
+ if ((pw)->stat & stat_hlite) \
+ hloff(); \
+} while (0)
+
+static void hlchar(pwstate *pw, int ch)
+{
+ with_hl(pw, putchar(ch));
+}
+
static void drawline(pwstate *pw, const char *line, int lineno)
{
const char *oline = line;
@@ -372,7 +396,7 @@ static void drawline(pwstate *pw, const char *line, int lineno)
len = 0;
} else if (len - delta <= vsplit2) {
if (vsplit1) {
- putchar('|');
+ hlchar(pw, '|');
delta++;
}
fputs(line + delta, stdout);
@@ -382,7 +406,7 @@ static void drawline(pwstate *pw, const char *line, int lineno)
} else {
unsigned start = 0;
if (vsplit1) {
- putchar('|');
+ hlchar(pw, '|');
start++;
}
for (unsigned i = start; i < vsplit2; i++)
@@ -398,7 +422,7 @@ static void drawline(pwstate *pw, const char *line, int lineno)
if (pw->hpos || vsplit1 || vsplit2) {
line += pw->hpos + 1;
len -= pw->hpos + 1;
- putchar('>');
+ hlchar(pw, '>');
columns--;
}
if (len < (size_t) columns) {
@@ -407,11 +431,12 @@ static void drawline(pwstate *pw, const char *line, int lineno)
} else {
for (int i = 0; i < columns - 1; i++)
putchar(line[i]);
- puts("<");
+ hlchar(pw, '<');
+ putchar('\n');
}
} else {
if (endmark)
- putchar('>');
+ hlchar(pw, '>');
clreol(1);
}
}
@@ -1197,6 +1222,10 @@ int main(int argc, char **argv)
pw.stat |= stat_force;
}
break;
+ case ctrl('i'):
+ pw.stat ^= stat_hlite;
+ pw.stat |= stat_force;
+ break;
case 'j':
if (pw.hist > 0) {
pw.hist--;