Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Strange initial escape string



On May 31, 12:56am, Mario Signorino wrote:
}
} \033[1m	Start bold
} \033[7m%	Start reverse video, display percent
} \033[27m	Stop reverse video
} \033[1m	Stay bold *
} \033[0m	Reset all attributes to defaults

This is the effect of the PROMPT_SP option.  It's a bold, reverse video
percent sign, which is intended to appear at the end of any partial
final line of output from a command, to let the user know that zsh
added a newline that was not part of the actual output.  You can see
the effect of this with "setopt promptsp; print -n anything".

* This is extraneous, it's just there in case stop reverse video also
stops bold, but then of course we're going to reset anyway.  Minor
inefficiency in generating the escapes, in the name of generality,
I think.

}                \r \r\r

This is zsh forcing the cursor to the beginning of a line.  It prints
what it believes to be just enough spaces to cause the cursor to bump
the right margin of the terminal if there was a partial line of output,
then prints a return without a newline; on some terminals when the
cursor is in the rightmost column, this is consumed by the terminal,
so it then prints ANOTHER space to force a line wrap and then prints
more returns to force the cursor back to the leftmost column.

All of this is to guarantee that ZLE knows where the cursor is when
the editor starts up, and is mostly controlled by the PROMPT_CR option.

} \033[0m	Reset all
} \033[27m	No reverse
} \033[24m	No underline
} \033[J	Clear from cursor to end of screen
} Linux%	(the prompt)
} \033[K	Clear from end of prompt to end of line **
} \033[?1h	Enter keypad transmit mode (for arrow keys)
} \033=		(also part of keypad transmit mode sequence)

** In case the prompt value moved the cursor upward or leftward;
otherwise this is redundant with clear-to-end.

If the user sets RPS1 for a right-hand prompt you're going to get even
more cursor-moving-around, and of course the prompt can do pretty much
anything the user tells it to, so depending on what you're hoping to
do you may be in for a hard time.

If you're actually writing a terminal emulator, this may be helpful:

http://www.vt100.net/emu/dec_ansi_parser



Messages sorted by: Reverse Date, Date, Thread, Author