MCPcopy Create free account
hub / github.com/antirez/ds4 / getCursorPosition

Function getCursorPosition

linenoise.c:656–676  ·  view source on GitHub ↗

Use the ESC [6n escape sequence to query the horizontal cursor position * and return it. On error -1 is returned, on success the position of the * cursor. */

Source from the content-addressed store, hash-verified

654}
655
656static void disableRawMode(int fd) {
657 /* Test mode: nothing to restore. */
658 if (getenv("LINENOISE_ASSUME_TTY")) {
659 rawmode = 0;
660 return;
661 }
662 /* Don't even check the return value as it's too late. */
663 if (rawmode && tcsetattr(fd,TCSAFLUSH,&orig_termios) != -1) {
664 /* Leave bracketed paste mode when leaving raw mode. */
665 if (write(rawmode_output, "\x1b[?2004l", 8) == -1) {}
666 rawmode = 0;
667 }
668}
669
670/* Re-enable raw mode if a child process changed the terminal state. This is
671 * useful when the application spawns external processes that may reset the
672 * terminal to cooked mode. This is deliberately conservative: while an editor
673 * is active, orig_termios must remain the cooked-mode state used by
674 * disableRawMode(), so never replace it with the current terminal attributes.
675 * TCSANOW avoids discarding bytes the user typed while the child was running. */
676void linenoiseRestoreRawMode(void) {
677 if (getenv("LINENOISE_ASSUME_TTY")) return;
678 if (!rawmode) return;
679 if (!isatty(STDIN_FILENO)) return;

Callers 1

getColumnsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected