From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14501 invoked by alias); 31 May 2013 05:11:05 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31440 Received: (qmail 10600 invoked from network); 31 May 2013 05:11:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130530221023.ZM11251@torch.brasslantern.com> Date: Thu, 30 May 2013 22:10:23 -0700 In-reply-to: Comments: In reply to Mario Signorino "Re: Strange initial escape string" (May 31, 12:56am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Mario Signorino , zsh-workers@zsh.org Subject: Re: Strange initial escape string MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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