Does at Tab character just move the cursor, or actually wipe out the cells it passes over?
printf 'hello\r\tworld\n'
produces the text hello world
so tabs just move the cursor.
If you insert characters before a string that was positioned with a Tab, does the string stay where it is (like in Vim) or does it get shifted across?
printf '\033[2J\033[1;1H\thello\r\033[4@\n'
produces a hello
preceeded by 12 empty cells, so the fact that a given string was aligned with a tab is not recorded.It seems that the cursor-position is set for the terminal as a whole:
printf '\033[1;1H\033[?47h\033[5;5H\033[?47l'
After running this command, the normal framebuffer is active but the cursor is located when it was put while the alternate framebuffer was active.
Note: xterm seems to not distinguish between:
printf 'hello world'
and:
printf 'hello\tworld'
…both produce a three-cell gap between the two words (as opposed to three 1-cell space characters, as iTerm does).
On the other hand, when you include colours, they are different:
printf "$(tput setab 3)hello$(tput setab 4)\\t$(tput setab 5)world\\n"
printf "$(tput setab 3)hello$(tput setab 4) $(tput setab 5)world\\n"
When the words are seperated by a tab, a gap is left coloured in the original background colour. When the words are separated by spaces, those cells have their background colour set to ‘4’ (blue). So, uh, that makes things messy.
If two consecutive physical lines are distinct (resizing the window does not affect the alignment of the second line), and text is printed across their shared boundary, the two lines are joined into one logical line, and after that resizing the window does affect the alignment of the second line.
Testcase:
printf 'hello\nworld\n\033[2A\033[78Gencyc\n\n'
In iTerm and Terminal.app, when making the framebuffer narrower, lines that wrap always push the lines above them up. For example, if physical and logical line 23 is exactly the width of the terminal, and the terminal is subsequently resized narrower such that it wraps onto two lines, those will be physical lines 22 and 23 (but still one logical line).
Testcase:
printf '\033[2J\033[1;79H01\n'
for (( i=2; i <= 23; i=i+1 )); do
printf '\033[79G%02i\n' $i
done
printf '\033[1;1H'
In xterm and Terminal.app, printing a double-width character at the end of a line causes that character to appear at the beginning of the next line (in Terminal.app, such wrapping occurs dynamically, so dragging the window 1 cell wider makes it jump back to the end of the first line; in xterm the wrapping occurs statically).
Testcase:
printf '\033[80G病\n'