degesch: print a marker for unread messages
This commit is contained in:
parent
d48adf4557
commit
ccc167d120
47
degesch.c
47
degesch.c
|
@ -20,17 +20,18 @@
|
|||
// A table of all attributes we use for output
|
||||
// FIXME: awful naming, collides with ATTRIBUTE_*
|
||||
#define ATTR_TABLE(XX) \
|
||||
XX( PROMPT, "prompt", "Terminal attributes for the prompt" ) \
|
||||
XX( PROMPT, "prompt", "Terminal attrs for the prompt" ) \
|
||||
XX( RESET, "reset", "String to reset terminal attributes" ) \
|
||||
XX( WARNING, "warning", "Terminal attributes for warnings" ) \
|
||||
XX( ERROR, "error", "Terminal attributes for errors" ) \
|
||||
XX( EXTERNAL, "external", "Terminal attributes for external lines" ) \
|
||||
XX( TIMESTAMP, "timestamp", "Terminal attributes for timestamps" ) \
|
||||
XX( HIGHLIGHT, "highlight", "Terminal attributes for highlights" ) \
|
||||
XX( ACTION, "action", "Terminal attributes for user actions" ) \
|
||||
XX( USERHOST, "userhost", "Terminal attributes for user@host" ) \
|
||||
XX( JOIN, "join", "Terminal attributes for joins" ) \
|
||||
XX( PART, "part", "Terminal attributes for parts" )
|
||||
XX( READ_MARKER, "read_marker", "Terminal attrs for the read marker" ) \
|
||||
XX( WARNING, "warning", "Terminal attrs for warnings" ) \
|
||||
XX( ERROR, "error", "Terminal attrs for errors" ) \
|
||||
XX( EXTERNAL, "external", "Terminal attrs for external lines" ) \
|
||||
XX( TIMESTAMP, "timestamp", "Terminal attrs for timestamps" ) \
|
||||
XX( HIGHLIGHT, "highlight", "Terminal attrs for highlights" ) \
|
||||
XX( ACTION, "action", "Terminal attrs for user actions" ) \
|
||||
XX( USERHOST, "userhost", "Terminal attrs for user@host" ) \
|
||||
XX( JOIN, "join", "Terminal attrs for joins" ) \
|
||||
XX( PART, "part", "Terminal attrs for parts" )
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -1945,6 +1946,7 @@ init_colors (struct app_context *ctx)
|
|||
|
||||
INIT_ATTR (PROMPT, enter_bold_mode);
|
||||
INIT_ATTR (RESET, exit_attribute_mode);
|
||||
INIT_ATTR (READ_MARKER, g_terminal.color_set_fg[COLOR_MAGENTA]);
|
||||
INIT_ATTR (WARNING, g_terminal.color_set_fg[COLOR_YELLOW]);
|
||||
INIT_ATTR (ERROR, g_terminal.color_set_fg[COLOR_RED]);
|
||||
|
||||
|
@ -2927,6 +2929,16 @@ buffer_remove (struct app_context *ctx, struct buffer *buffer)
|
|||
refresh_prompt (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_print_read_marker (struct app_context *ctx)
|
||||
{
|
||||
struct formatter f;
|
||||
formatter_init (&f, ctx, NULL);
|
||||
formatter_add (&f, "#a-- -- -- ---\n", ATTR_READ_MARKER);
|
||||
formatter_flush (&f, stdout);
|
||||
formatter_free (&f);
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
|
||||
{
|
||||
|
@ -2935,14 +2947,23 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
|
|||
print_status ("%s", buffer->name);
|
||||
|
||||
// That is, minus the buffer switch line and the readline prompt
|
||||
int to_display = MAX (10, g_terminal.lines - 2);
|
||||
int display_limit =
|
||||
MAX (MAX (10, buffer->unseen_messages_count), g_terminal.lines - 2);
|
||||
|
||||
struct buffer_line *line = buffer->lines_tail;
|
||||
while (line && line->prev && --to_display > 0)
|
||||
line = line->prev;
|
||||
int to_display = line != NULL;
|
||||
for (; line && line->prev && --display_limit > 0; line = line->prev)
|
||||
to_display++;
|
||||
|
||||
// Once we've found where we want to start with the backlog, print it
|
||||
int until_marker = to_display - (int) buffer->unseen_messages_count;
|
||||
for (; line; line = line->next)
|
||||
{
|
||||
if (until_marker-- == 0)
|
||||
buffer_print_read_marker (ctx);
|
||||
buffer_line_display (ctx, line, false);
|
||||
}
|
||||
|
||||
buffer->unseen_messages_count = 0;
|
||||
buffer->highlighted = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue