Help me to decipher the escape sequences created by ncurses
library and catched by strace
. I am exploring how ncurses
interacts with terminal and want to understand its "handshake protocol". I have found some descriptions already, but didn't understand all of them though, like "Set cursor key to cursor".
echo $TERM
prints xterm-256color
.
Original
write(1, "\33[?1049h\33[22;0;0t\33[1;39r\33(B\33[m\33[4l\33[?7h\33[H\33[2J", 46) = 46
write(1, "Hello World !!!", 15) = 15
write(1, "\33[39;1H\33[?1049l\33[23;0;0t\r\33[?1l\33>", 32) = 32
My assumptions
write(1, "
\33[?1049h # go to alternate screen
\33[22;0;0t
\33[1;39r
\33(B # Set United States G0 character set
\33[m # Turn off character attributes
\33[4l
\33[?7h # Set auto-wrap mode
\33[H # Move cursor to upper left corner
\33[2J # Clear entire screen
", 46) = 46
write(1, "Hello World !!!", 15) = 15
write(1, "
\33[39;1H
\33[?1049l # Go back to the initial screen
\33[23;0;0t\r
\33[?1l # Set cursor key to cursor
\33>
", 32) = 32
The testing program source
int main()
{
napms(25000); /* This pause is needed to catch the process by strace*/
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
endwin(); /* End curses mode */
return 0;
}
gdb
did not help :). – MiniMax May 04 '20 at 14:19