aboutsummaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-18 00:38:55 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-18 00:38:55 -0800
commit4382fffbe06fa5832ba369e082438661719efa52 (patch)
tree8a66d6a66144ed08229ba43e82026ef6761f4ad6 /print.c
parent2615a3b9f21701866bfc4bdf9df24044587a6e92 (diff)
Better visualization of matches with newlines and tabs
Diffstat (limited to 'print.c')
-rw-r--r--print.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/print.c b/print.c
index 264e6c2..77fe654 100644
--- a/print.c
+++ b/print.c
@@ -75,6 +75,7 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char *
for (size_t i = 0; i < viz_typelen; i++) {
switch (viz_type[i]) {
case '\n': printf("↵"); break;
+ case '\t': printf("⇥"); break;
default: printf("%c", viz_type[i]); break;
}
}
@@ -103,7 +104,12 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char *
if (c > m->m->start) printf(" ");
// TODO: utf8
//while ((*c & 0xC0) != 0x80) printf("%c", *(c++));
- printf("%c", *c);
+ if (*c == '\n')
+ printf("↵");
+ else if (*c == '\t')
+ printf("⇥");
+ else
+ printf("%c", *c);
}
printf("\033[0;2m%s\033[0m", V);
} else {