degesch: allow hiding join/part messages
This commit is contained in:
parent
f032466307
commit
f7155f3919
48
degesch.c
48
degesch.c
@ -1508,6 +1508,7 @@ struct buffer
|
||||
unsigned new_messages_count; ///< # messages since last left
|
||||
unsigned new_unimportant_count; ///< How much of that is unimportant
|
||||
bool highlighted; ///< We've been highlighted
|
||||
bool hide_unimportant; ///< Hide unimportant messages
|
||||
|
||||
FILE *log_file; ///< Log file
|
||||
|
||||
@ -3728,10 +3729,16 @@ buffer_line_write_time (struct formatter *f, struct buffer_line *line,
|
||||
formatter_add (f, "#a#s#r ", ATTR_TIMESTAMP, buf);
|
||||
}
|
||||
|
||||
#define buffer_line_will_show_up(buffer, line) \
|
||||
(!(buffer)->hide_unimportant || !((line)->flags & BUFFER_LINE_UNIMPORTANT))
|
||||
|
||||
static void
|
||||
buffer_line_display (struct app_context *ctx,
|
||||
struct buffer_line *line, bool is_external)
|
||||
struct buffer *buffer, struct buffer_line *line, bool is_external)
|
||||
{
|
||||
if (!buffer_line_will_show_up (buffer, line))
|
||||
return;
|
||||
|
||||
CALL (ctx->input, hide);
|
||||
|
||||
struct formatter f;
|
||||
@ -3825,9 +3832,9 @@ log_formatter (struct app_context *ctx,
|
||||
// Another process is using the terminal
|
||||
displayed = false;
|
||||
else if (buffer == ctx->current_buffer)
|
||||
buffer_line_display (ctx, line, false);
|
||||
buffer_line_display (ctx, buffer, line, false);
|
||||
else if (!ctx->isolate_buffers && can_leak)
|
||||
buffer_line_display (ctx, line, true);
|
||||
buffer_line_display (ctx, buffer, line, true);
|
||||
else
|
||||
displayed = false;
|
||||
|
||||
@ -4050,9 +4057,6 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
|
||||
// The prompt can take considerable time to redraw
|
||||
CALL (ctx->input, hide);
|
||||
|
||||
// That is, minus the readline prompt
|
||||
int display_limit = MAX (10, g_terminal.lines - 1);
|
||||
|
||||
// Simulate curses-like fullscreen buffers if the terminal allows it
|
||||
if (g_terminal.initialized && clear_screen)
|
||||
{
|
||||
@ -4080,10 +4084,19 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
|
||||
free (buffer_name_localized);
|
||||
}
|
||||
|
||||
struct buffer_line *line = buffer->lines_tail;
|
||||
int to_display = line != NULL;
|
||||
for (; line && line->prev && --display_limit > 0; line = line->prev)
|
||||
// That is, minus the readline prompt
|
||||
int display_limit = MAX (10, g_terminal.lines - 1);
|
||||
int to_display = 0;
|
||||
|
||||
struct buffer_line *line;
|
||||
for (line = buffer->lines_tail; line; line = line->prev)
|
||||
{
|
||||
to_display++;
|
||||
if (buffer_line_will_show_up (buffer, line))
|
||||
display_limit--;
|
||||
if (!line->prev || display_limit <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
// Once we've found where we want to start with the backlog, print it
|
||||
int until_marker = to_display - (int) buffer->new_messages_count;
|
||||
@ -4092,7 +4105,7 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
|
||||
if (until_marker-- == 0
|
||||
&& buffer->new_messages_count != buffer->lines_count)
|
||||
buffer_print_read_marker (ctx, stdout, 0);
|
||||
buffer_line_display (ctx, line, 0);
|
||||
buffer_line_display (ctx, buffer, line, 0);
|
||||
}
|
||||
|
||||
// So that it is obvious if the last line in the buffer is not from today
|
||||
@ -5827,6 +5840,8 @@ make_prompt (struct app_context *ctx, struct str *output)
|
||||
if (buffer->channel->users_len)
|
||||
str_append_printf (output, "{%zu}", buffer->channel->users_len);
|
||||
}
|
||||
if (buffer->hide_unimportant)
|
||||
str_append (output, "<H>");
|
||||
|
||||
if (buffer != ctx->global_buffer)
|
||||
make_server_postfix (buffer, output);
|
||||
@ -12311,6 +12326,17 @@ on_display_full_log (int count, int key, void *user_data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
on_toggle_unimportant (int count, int key, void *user_data)
|
||||
{
|
||||
(void) count;
|
||||
(void) key;
|
||||
struct app_context *ctx = user_data;
|
||||
ctx->current_buffer->hide_unimportant ^= true;
|
||||
buffer_print_backlog (ctx, ctx->current_buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
static bool
|
||||
@ -12471,6 +12497,7 @@ input_add_functions (void *user_data)
|
||||
XX ("display-backlog", "Show backlog", on_display_backlog)
|
||||
XX ("display-backlog-nw", "Non-wrapped log", on_display_backlog_nowrap)
|
||||
XX ("display-full-log", "Show full log", on_display_full_log)
|
||||
XX ("toggle-unimportant", "Toggle junk msgs", on_toggle_unimportant)
|
||||
XX ("edit-input", "Edit input", on_edit_input)
|
||||
XX ("redraw-screen", "Redraw screen", on_redraw_screen)
|
||||
XX ("insert-attribute", "mIRC formatting", on_insert_attribute)
|
||||
@ -12494,6 +12521,7 @@ bind_common_keys (struct app_context *ctx)
|
||||
CALL_ (self, bind_meta, 'a', "goto-activity");
|
||||
CALL_ (self, bind_meta, 'm', "insert-attribute");
|
||||
CALL_ (self, bind_meta, 'h', "display-full-log");
|
||||
CALL_ (self, bind_meta, 'H', "toggle-unimportant");
|
||||
CALL_ (self, bind_meta, 'e', "edit-input");
|
||||
|
||||
if (key_f5) CALL_ (self, bind, key_f5, "previous-buffer");
|
||||
|
Loading…
Reference in New Issue
Block a user