diff --git a/kilo.c b/kilo.c index 44cb46e..d3ae504 100644 --- a/kilo.c +++ b/kilo.c @@ -101,10 +101,11 @@ int getWindowSize(int *rows, int *cols) { if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) { // Fallback if ioctl can't query size: - // Move cursor to the bottom right, then query its position. + // Move cursor to the bottom right; if (write(STDOUT_FILENO, "\x1b[999C\x1b[999B", 12) != 12) { return -1; } + // then query its position. return getCursorPosition(rows, cols); } @@ -117,7 +118,12 @@ int getWindowSize(int *rows, int *cols) { void editorDrawRows() { for (int y = 0; y < E.screenrows; y++) { - write(STDOUT_FILENO, "~\r\n", 3); + write(STDOUT_FILENO, "~", 1); + + // Don't scroll on the last line. + if (y < E.screenrows - 1) { + write(STDOUT_FILENO, "\r\n", 2); + } } }