On 3/12/17 6:57 PM, Grisha Levit wrote:

> Also it seems that the prompt is re-drawn after the text?  For
> example, setting the prompt as:
> 
> PS1='\n\[\e[0m\e[K\]'
> 
> and repeating the above puts point in the middle of a blank line.

Readline redraws the prompt because in the general case it needs to
output all of the invisible characters to get things like the color
right.  The invisible characters are assumed to be non-destructive.
This is potentially inefficient, but not dangerous.

In the above scenario, readline makes sure the cursor is at column 0,
deletes the necessary 24 characters ("(reverse-i-search)`fo': ") using
the terminal's `DC' capability, leaving "echo foo" on the screen, then
redraws the prompt, since those are the bytes that differ between the
old line and the new one.

The second CSI sequence in the prompt above erases from the cursor
to the end of the line, but readline cannot know this.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to