Reputation: 919
I'm writing a terminal, and was trying to use steam locomotive as a test bed, and ran into an unusual problem. Even in a regular terminal like xterm or mate-terminal, the output is different if you run the application, i.e. sl
verses if you log it to a file i.e. sl > sl.txt
then cat it cat sl.txt
This is particularly pronounced on sl-h
where in the first few seconds, codes are output which would make the X/O for the railroad crossing which if catted show incorrectly putting the X/O at the beginning of the line.
It seems that there is an ioctl
that's happening that somehow changes newline behavior to advance to the next line, but not return back to the beginning. I.e. strace sl-h 2> sllog.txt
shows: ioctl(1, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig -icanon echo ...}) = 0
How would you be able to detect this as a terminal? What systems are in place? Why wouldn't ncurses just use escape sequences to convey this information? There's a lot of questions that I'm not sure how to handle in my terminal.
Upvotes: 0
Views: 70
Reputation: 54475
ncurses (like Unix curses) puts the terminal into raw mode for two reasons:
printf
.In raw mode, the Unix-style conversion of line-feed to carriage-return and line-feed is disabled. That lets ncurses move directly down by one row (in the same column) with a single characters. Cursor addressing would typically use 6 or more characters. Even a cursor-down would use 3 characters.
Incidentally, that treatment of line-feed is the reason why the terminal descriptions often have the cursor-down capability assigned to a line-feed.
Upvotes: 1