about summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-08 16:56:49 -0500
committerJune McEnroe <june@causal.agency>2020-02-08 16:56:49 -0500
commit29bd788660af90855f6acce411506aeaf14f8808 (patch)
tree6ba640373cf860edc7f0019bd798857c908b78a9 /ui.c
parentAdd /topic (diff)
downloadtest-29bd788660af90855f6acce411506aeaf14f8808.tar.gz
test-29bd788660af90855f6acce411506aeaf14f8808.zip
Simplify(?) reflow buffer loop
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ui.c b/ui.c
index c738617..29062be 100644
--- a/ui.c
+++ b/ui.c
@@ -459,10 +459,12 @@ void uiFormat(
 static void reflow(struct Window *window) {
 	werase(window->pad);
 	wmove(window->pad, BufferCap - 1, 0);
-	size_t len = window->buffer.len;
-	for (size_t i = (len > BufferCap ? len - BufferCap : 0); i < len; ++i) {
+	struct Buffer *buffer = &window->buffer;
+	for (size_t i = 0; i < BufferCap; ++i) {
+		char *line = buffer->lines[(buffer->len + i) % BufferCap];
+		if (!line) continue;
 		waddch(window->pad, '\n');
-		wordWrap(window->pad, window->buffer.lines[i % BufferCap]);
+		wordWrap(window->pad, line);
 	}
 }
 
105ef734d3b235275&follow=1'>Crudely handle reconnecting after suspendJune McEnroe 2018-12-01Fix sandman hangJune McEnroe 2018-12-01Use sigaction in sandmanJune McEnroe 2018-11-30Handle signals consistently in the event loopJune McEnroe 2018-11-30Separate ircConnect and ircDisconnectJune McEnroe 2018-11-30Measure length of log timestamp more consistentlyJune McEnroe 2018-11-30Reformat sandman Objective-C codeJune McEnroe 2018-11-30Ignore sandmanJune McEnroe 2018-11-30Add sandmanJune McEnroe 2018-11-29Strip timestamps from log replayJune McEnroe 2018-11-29Add basic log replayJune McEnroe 2018-11-29Show unread count in term titleJune McEnroe 2018-11-29Handle no such nick errorJune McEnroe 2018-11-29Add /whoisJune McEnroe 2018-11-29Set LIBRESSL_PREFIX in Darwin.mkJune McEnroe 2018-11-28Add NetBSD.mkJune McEnroe 2018-11-28Make use of config.mk and add Darwin.mkJune McEnroe