chore: MIsc comments.
This commit is contained in:
@@ -72,6 +72,8 @@ char editorReadKey() {
|
||||
}
|
||||
|
||||
int getCursorPosition(int *rows, int *cols) {
|
||||
// `n` is the "Device Status Report" command, the argument `6`
|
||||
// asks for the active position.
|
||||
if (write(STDOUT_FILENO, "\x1b[6n", 4) != 4) {
|
||||
return -1;
|
||||
}
|
||||
@@ -82,6 +84,7 @@ int getCursorPosition(int *rows, int *cols) {
|
||||
while (i < sizeof(buf) - 1) {
|
||||
if (read(STDIN_FILENO, &buf[i], 1) != 1)
|
||||
break;
|
||||
// `R` stands for "Cursor Position Report"
|
||||
if (buf[i] == 'R')
|
||||
break;
|
||||
i++;
|
||||
@@ -102,6 +105,7 @@ 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;
|
||||
// (`C` is cursor forward, `B` is cursor down)
|
||||
if (write(STDOUT_FILENO, "\x1b[999C\x1b[999B", 12) != 12) {
|
||||
return -1;
|
||||
}
|
||||
@@ -120,7 +124,8 @@ void editorDrawRows() {
|
||||
for (int y = 0; y < E.screenrows; y++) {
|
||||
write(STDOUT_FILENO, "~", 1);
|
||||
|
||||
// Don't scroll on the last line.
|
||||
// No new line on the last line, the terminal scrolls past the
|
||||
// first line otherwise.
|
||||
if (y < E.screenrows - 1) {
|
||||
write(STDOUT_FILENO, "\r\n", 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user