|
|
|
|
|
by Joker_vD
84 days ago
|
|
Could you give an outline of an example scenarios? For e.g. "print a line with a highlighted word in it" (alternative to print 'This is \e[7mhighlighted\e[m text\n'), and "print some text, move cursor to the second last word, delete it, move to the new end": print 'This is a line of text which is being line-edited in an imaginary editor.'
if no line-wrap happened:
# move left a manually calculated amount of 17 (wcswidth?), delete
# everything to the right, reprint the rest of the line
print '\e[17D\e[Keditor.'
else:
# You need to know how much fit on the previous line, and the
# terminal's width. Let's assume 80, and that wrap happened
# after 'imagi', so 'nary' was on the next line. Move up 1, move
# right 63 (or do \r and move right 75), clear the rest of the
# screen, reprint
print '\e[A\e[63C\e[Jeditor.'
One of the problems with secondary channels is their synchronization with the main one: say you printed some text to the main fd, requested cursor position from the control fd, and then immediately printed some more text to the main fd — what cursor position will be reported? |
|