From 96386adac3cf4e0ac48c5b8f39b719f194f8d2e6 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Wed, 2 Sep 2020 18:51:07 -0400 Subject: Hide ignored messages at the soft -> hard buffer layer This restores normal scrolling behaviour. --- buffer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'buffer.c') diff --git a/buffer.c b/buffer.c index 711d5fd..7ac5c10 100644 --- a/buffer.c +++ b/buffer.c @@ -174,7 +174,7 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) { } int bufferPush( - struct Buffer *buffer, int cols, + struct Buffer *buffer, int cols, bool ignore, enum Heat heat, time_t time, const char *str ) { struct Line *soft = linesNext(&buffer->soft); @@ -182,10 +182,11 @@ int bufferPush( soft->time = time; soft->str = strdup(str); if (!soft->str) err(EX_OSERR, "strdup"); + if (heat < Cold && ignore) return 0; return flow(&buffer->hard, cols, soft); } -void bufferReflow(struct Buffer *buffer, int cols) { +void bufferReflow(struct Buffer *buffer, int cols, bool ignore) { buffer->hard.len = 0; for (size_t i = 0; i < BufferCap; ++i) { free(buffer->hard.lines[i].str); @@ -193,6 +194,8 @@ void bufferReflow(struct Buffer *buffer, int cols) { } for (size_t i = 0; i < BufferCap; ++i) { const struct Line *soft = bufferSoft(buffer, i); - if (soft) flow(&buffer->hard, cols, soft); + if (!soft) continue; + if (soft->heat < Cold && ignore) continue; + flow(&buffer->hard, cols, soft); } } -- cgit 1.4.1-2-gfad0