I have an open socket to a remote terminal. Using the answer to "Force telnet client into character mode" I was able to put that terminal into character mode.
My question is, how do I hide the cursor in the remote terminal using this method?
I have an open socket to a remote terminal. Using the answer to "Force telnet client into character mode" I was able to put that terminal into character mode.
My question is, how do I hide the cursor in the remote terminal using this method?
This is something that the ncurses library can do for you.
The curs_set()
function can make the cursor invisible.
To expand upon mjh2007's answer, the following c/c++ code will implement sending the escape codes to the terminal, and is slightly more readable than raw hex numbers.
void showCursor(bool show) const {
#define CSI "\e["
if (show) {
fputs(CSI "?25h", stdout);
}
else {
fputs(CSI "?25l", stdout);
}
#undef CSI
}
?25
! \e[0m\e[?25h
seems to work fine. –
Pertain \e[?25h
and \e[?25l
. To memorize it, remember that L stands for Lehidden and H stands for HonestlyTheCursorWillBeVisible. –
Disrupt This is something that the ncurses library can do for you.
The curs_set()
function can make the cursor invisible.
If the terminal you are using supports ANSI format you should be able to send the following escape codes:
Hide the cursor: 0x9B 0x3F 0x32 0x35 0x6C Show the cursor: 0x9B 0x3F 0x32 0x35 0x68
$TERM
value unless you cannot use ncurses for some reason. –
Inlier If this is using the 'telnet' application then your app should send 'IAC WILL ECHO' to disable echoing on their remote side. This is useful for entering passwords or if your app is doing the echoing.
#define TEL_IAC "\377"
#define TEL_WILL "\373"
#define TEL_ECHO "\001"
char buf[4];
snprintf(buf, sizeof(buf), "%c%c%c" TEL_IAC, TEL_WILL, TEL_ECHO);
write(sock, buf, sizeof(buf));
Or
write(sock, TEL_IAC TEL_WILL TEL_ECHO, 3);
Hope this helps.
© 2022 - 2024 — McMap. All rights reserved.
$TERM
value unless you cannot use ncurses for some reason. – Inlier