aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-19 12:53:18 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-19 12:53:18 +0200
commitffa12d93c7efc516ead1dfc798f9afc0d3ec1aa1 (patch)
tree574635d1ed446def3fc894379eef036494f42964 /window.c
parentf212b9d4952c87052e23b5161195917410b7c911 (diff)
downloadvis-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.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/window.c b/window.c
index a3b28b6..dc3e7dd 100644
--- a/window.c
+++ b/window.c
@@ -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;