summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-04-21 23:58:44 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-04 10:08:30 +0200
commit9819b75b643d60e931ae2a7758b35000e806a925 (patch)
tree2f69daaf52e51987fdbad73734a7d122f8325570 /degesch.c
parentf716e7601fa32947e380e7d1f7dd1433d2818a55 (diff)
downloadxK-9819b75b643d60e931ae2a7758b35000e806a925.tar.gz
xK-9819b75b643d60e931ae2a7758b35000e806a925.tar.xz
xK-9819b75b643d60e931ae2a7758b35000e806a925.zip
degesch: make the unread marker look a bit fancier
Upstreamed after who knows how long, in a slightly modified form. The marker looks fairly ugly without this and defaults should be desirable. It's possible to get the previous behaviour by resetting the separator character in the configuration to an empty string. It might be a better idea in general to just disallow this value with a special validation callback, so that there's only one way to do it. However given that without fancy-prompt.lua, an optional plugin, the long line stands out considerably, it might actually be a good idea to keep the old behaviour as the default. I'm torn. Right now we don't care about the situation where the string occupies more than one terminal cell or is some Unicode BS. User's problem.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/degesch.c b/degesch.c
index 74134ae..5c172f5 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2425,6 +2425,11 @@ static struct config_schema g_config_behaviour[] =
.comment = "Input to strftime(3) for the date change line",
.type = CONFIG_ITEM_STRING,
.default_ = "\"%F\"" },
+ { .name = "read_marker_char",
+ .comment = "The character to use for the read marker line",
+ .type = CONFIG_ITEM_STRING,
+ .default_ = "\"-\"",
+ .validate = config_validate_nonjunk_string },
{ .name = "logging",
.comment = "Log buffer contents to file",
.type = CONFIG_ITEM_BOOLEAN,
@@ -4097,7 +4102,28 @@ static void
buffer_print_read_marker (struct app_context *ctx, FILE *stream, int flush_opts)
{
struct formatter f = formatter_make (ctx, NULL);
- formatter_add (&f, "#a-- -- -- ---\n", ATTR_READ_MARKER);
+ const int timestamp_width = 8; // hardcoded to %T right now, simple
+ const char *marker_char = get_config_string (ctx->config.root,
+ "behaviour.read_marker_char");
+
+ // We could turn this off on FLUSH_OPT_NOWRAP, however our default pager
+ // wraps lines for us even if we don't do it ourselves, and thus there's
+ // no need to worry about inconsistency.
+ if (*marker_char)
+ {
+ struct str s = str_make ();
+ for (int i = 0; i < timestamp_width; i++)
+ str_append (&s, marker_char);
+ formatter_add (&f, "#a#s#r", ATTR_TIMESTAMP, s.str);
+ str_reset (&s);
+ for (int i = timestamp_width; i < g_terminal.columns; i++)
+ str_append (&s, marker_char);
+ formatter_add (&f, "#a#s#r\n", ATTR_READ_MARKER, s.str);
+ str_free (&s);
+ }
+ else
+ formatter_add (&f, "#a-- -- -- ---\n", ATTR_READ_MARKER);
+
formatter_flush (&f, stream, flush_opts);
// Flush the trailing formatting reset item
fflush (stream);