zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Mario Signorino <mario.signorino@gnufish.net>, zsh-workers@zsh.org
Subject: Re: Strange initial escape string
Date: Thu, 30 May 2013 22:10:23 -0700	[thread overview]
Message-ID: <130530221023.ZM11251@torch.brasslantern.com> (raw)
In-Reply-To: <CAM8HBcWmRz-v3EQ1oN9W9x5zZ4FeZNMt_jnfiTmRNxrrZvzuhg@mail.gmail.com>

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


  reply	other threads:[~2013-05-31  5:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 21:28 Mario Signorino
2013-05-30 22:56 ` Mario Signorino
2013-05-31  5:10   ` Bart Schaefer [this message]
2013-06-15 11:31     ` Mario Signorino
2013-06-15 12:22       ` Mikael Magnusson
2013-06-15 18:44       ` Bart Schaefer
2013-06-15 19:14         ` Mario Signorino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=130530221023.ZM11251@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=mario.signorino@gnufish.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).