3 ms·
> Rather, a tab, at least when rendered onto a PTY, advances the cursor to the next tabstop — i.e. to the next virtual column that is a multiple of 8. Multiple
by wahern 5y ago
> Rather, a tab, at least when rendered onto a PTY, advances the cursor to the next tabstop — i.e. to the next virtual column that is a multiple of 8.
Multiple of 8 is just convention, though. AFAIU, it's up to the display software--editor, terminal emulator, etc--where to place tab stops. The kernel TTY and PTY layers don't know anything about tab stops, AFAIU. In the case of terminals there are control sequences available for programs to query and update the tab stops; but all the logic is still at the ends. Contrast that with line buffering and certain escape sequences, where character sequences are captured and interpreted by the terminal device driver.
Also note that it's tab stops, plural. The default tab stops are multiples of 8, but you can tell a terminal (similar to other display software, like MS Word) to place tab stops at discrete positions that aren't multiples of anything, e.g. 10, 12, 18, 27, etc.
- thechao 5y agoWhen we were taught to type, we used long-stroke hammer typewriters. The tab stop was a bit of metal with notches & clips. You set the tab stop with a ruler, and each time you pressed tab it went to next stop. If your tab stop was worn out, the carriage would go right past the stop!
- ksherlock 5y agoThe Unix kernel has tab knowledge - see tcsetattr(), specifically the c_oflag OXTABS bit: If OXTABS is set, tabs are expanded to the appropriate number of spaces (assuming 8 column tab stops). (XTABS if you're not using a real unix.)