fix: Dont' scroll after writing last row.
This commit is contained in:
@@ -101,10 +101,11 @@ int getWindowSize(int *rows, int *cols) {
|
|||||||
|
|
||||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
|
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
|
||||||
// Fallback if ioctl can't query size:
|
// 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) {
|
if (write(STDOUT_FILENO, "\x1b[999C\x1b[999B", 12) != 12) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// then query its position.
|
||||||
return getCursorPosition(rows, cols);
|
return getCursorPosition(rows, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +118,12 @@ int getWindowSize(int *rows, int *cols) {
|
|||||||
|
|
||||||
void editorDrawRows() {
|
void editorDrawRows() {
|
||||||
for (int y = 0; y < E.screenrows; y++) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user