Simplify(?) reflow buffer loop
parent
b98c7d6863
commit
29bd788660
8
ui.c
8
ui.c
|
@ -459,10 +459,12 @@ void uiFormat(
|
||||||
static void reflow(struct Window *window) {
|
static void reflow(struct Window *window) {
|
||||||
werase(window->pad);
|
werase(window->pad);
|
||||||
wmove(window->pad, BufferCap - 1, 0);
|
wmove(window->pad, BufferCap - 1, 0);
|
||||||
size_t len = window->buffer.len;
|
struct Buffer *buffer = &window->buffer;
|
||||||
for (size_t i = (len > BufferCap ? len - BufferCap : 0); i < len; ++i) {
|
for (size_t i = 0; i < BufferCap; ++i) {
|
||||||
|
char *line = buffer->lines[(buffer->len + i) % BufferCap];
|
||||||
|
if (!line) continue;
|
||||||
waddch(window->pad, '\n');
|
waddch(window->pad, '\n');
|
||||||
wordWrap(window->pad, window->buffer.lines[i % BufferCap]);
|
wordWrap(window->pad, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue