aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-10-23 16:53:31 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-10-23 17:14:24 +0200
commitf7155f3919317d5592a66bfdf1343836f77be929 (patch)
tree0de5b0c97157fa44ac07cb5d6871da94040a0f00 /degesch.c
parentf0324663079d8b1bce0fa2e19c70e073a4b700d2 (diff)
downloadxK-f7155f3919317d5592a66bfdf1343836f77be929.tar.gz
xK-f7155f3919317d5592a66bfdf1343836f77be929.tar.xz
xK-f7155f3919317d5592a66bfdf1343836f77be929.zip
degesch: allow hiding join/part messages
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/degesch.c b/degesch.c
index db66483..adc2c3e 100644
--- a/degesch.c
+++ b/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");