diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-19 12:53:18 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-19 12:53:18 +0200 |
| commit | ffa12d93c7efc516ead1dfc798f9afc0d3ec1aa1 (patch) | |
| tree | 574635d1ed446def3fc894379eef036494f42964 /window.c | |
| parent | f212b9d4952c87052e23b5161195917410b7c911 (diff) | |
| download | vis-ffa12d93c7efc516ead1dfc798f9afc0d3ec1aa1.tar.gz vis-ffa12d93c7efc516ead1dfc798f9afc0d3ec1aa1.tar.xz | |
Windows style newlines are actually \r\n not \n\r
This is fiddely stuff, hopefully it doesn't break too much
Diffstat (limited to 'window.c')
| -rw-r--r-- | window.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -430,9 +430,10 @@ void window_draw(Win *win) { c.len = len; } - if (cur[0] == '\n' && rem > 1 && cur[1] == '\r') { - /* convert windows style newline \n\r into a single char with len = 2 */ - c.len = len = 2; + if (cur[0] == '\r' && rem > 1 && cur[1] == '\n') { + /* convert windows style newline \r\n into a single char with len = 2 */ + len = 2; + c = (Char){ .c = "\n", .wchar = L'\n', .len = len }; } wattrset(win->win, attrs); @@ -607,16 +608,18 @@ static bool window_viewport_up(Win *win, int n) { return false; size_t off = 0; /* skip newlines immediately before display area */ - if (c == '\r' && text_iterator_byte_prev(&it, &c)) - off++; if (c == '\n' && text_iterator_byte_prev(&it, &c)) off++; + if (c == '\r' && text_iterator_byte_prev(&it, &c)) + off++; do { - if ((c == '\n' || c == '\r') && --n == 0) + if (c == '\n' && --n == 0) break; if (++off > max) break; } while (text_iterator_byte_prev(&it, &c)); + if (c == '\r') + off++; win->start -= off; window_draw(win); return true; |
