From 9819b75b643d60e931ae2a7758b35000e806a925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Thu, 21 Apr 2016 23:58:44 +0200 Subject: [PATCH] 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. --- degesch.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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);