* Strange initial escape string @ 2013-05-30 21:28 Mario Signorino 2013-05-30 22:56 ` Mario Signorino 0 siblings, 1 reply; 7+ messages in thread From: Mario Signorino @ 2013-05-30 21:28 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 605 bytes --] Hi all I'm working on a new terminal emulator. When I start the terminal with a bash shell, I read this string "\033]0;Window title\007" followed by the prompt and the other stuff. When I switch to zsh I read "\033[1m\033[7m%" and then the prompt. What is that? If I push the string manually into a gnome-terminal or an xterm $ echo -e "\033[1m\033[7m%" > /dev/pst/3 I get a % inversed and bold as expected... but starting the gnome-terminal (or xterm..) does not show anything... Is that some special stuff hidden by the terminals? I read it as "write % bold and inversed". Any hints? Regards, Mario ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange initial escape string 2013-05-30 21:28 Strange initial escape string Mario Signorino @ 2013-05-30 22:56 ` Mario Signorino 2013-05-31 5:10 ` Bart Schaefer 0 siblings, 1 reply; 7+ messages in thread From: Mario Signorino @ 2013-05-30 22:56 UTC (permalink / raw) To: zsh-workers On Thu, May 30, 2013 at 11:28 PM, Mario Signorino <mario.signorino@gnufish.net> wrote: > When I switch to zsh I read "\033[1m\033[7m%" and then the prompt. > What is that? Ok: stupid question. It's a small part of a bigger sequence. The final result is a simple prompt as Linux% But what I get from the pty is this sequence (splitted on many lines to be more readable): \033[1m \033[7m% \033[27m \033[1m \033[0m \r \r\r \033[0m \033[27m \033[24m \033[J Linux% \033[K \033[?1h \033= Tnx anyway. Mario ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange initial escape string 2013-05-30 22:56 ` Mario Signorino @ 2013-05-31 5:10 ` Bart Schaefer 2013-06-15 11:31 ` Mario Signorino 0 siblings, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2013-05-31 5:10 UTC (permalink / raw) To: Mario Signorino, zsh-workers 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange initial escape string 2013-05-31 5:10 ` Bart Schaefer @ 2013-06-15 11:31 ` Mario Signorino 2013-06-15 12:22 ` Mikael Magnusson 2013-06-15 18:44 ` Bart Schaefer 0 siblings, 2 replies; 7+ messages in thread From: Mario Signorino @ 2013-06-15 11:31 UTC (permalink / raw) Cc: zsh-workers [-- Attachment #1: Type: text/plain, Size: 2428 bytes --] On Fri, May 31, 2013 at 7:10 AM, Bart Schaefer <schaefer@brasslantern.com> wrote: > 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 Thanks! It's clear now. Yes: I'm actually writing a new terminal emulator... and I'm really having fun. This is the result so far http://goo.gl/YJgMf I want to merge a terminal emulator, a file manager and a launcher (zeitgeist, locate and other stuff). My app must works with no additional software than itself. With zsh it will be fully functional: bash cannot do half of the trick of zsh, and I did not checked know other shells. Actually I'm writing a player for shells: I just added some custom escape codes catch tab completion. Each line of the terminal can be pluginable (as the launcher content) in qml or c++: so it should be possible to add handlers for any shell command... for example a git handler (in pure qml) should trap the git output and display it in a different way. In the video I've done that with wget. That is still a prototype but it seems promising... no big problems so far. Your link saved me a lot of work: I'm using the pre-built state machine engine found on that link to parse the pts output. So I don't have to care about splitting CSI and OSC... unfortunately it does not support utf8, but I will fix it sooner or later. Now some question: I've used some custom escape codes ( \033| ) to surround the important info. Now I can trap these strings and easily work on them. This is working. The problem is in the prompt. My PS1 is something like that: export XPIPETERMINATOR=$'\033|.' PS1="${XPIPETERMINATOR}mario@squit $ " that "terminator" tells to my terminal that the previous command has just finished. I use it to close any pending operation (show icons... git fancy output): if I receive that, it means *for sure* that I am again on the standard prompt. The problem is that zsh does not know anything about that escape codes and it thinks to have written more chars than it actually has: and it sends the carriage return too early (when I reach the end of the line). So: how can I tell to zsh to forget those 2 or 3 special chars? Or: is there any other way to know that the execution of the last command is just finished? something as a "postexec()" function? Regards, Mario ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange initial escape string 2013-06-15 11:31 ` Mario Signorino @ 2013-06-15 12:22 ` Mikael Magnusson 2013-06-15 18:44 ` Bart Schaefer 1 sibling, 0 replies; 7+ messages in thread From: Mikael Magnusson @ 2013-06-15 12:22 UTC (permalink / raw) To: zsh workers On 15 June 2013 13:31, Mario Signorino <mario.signorino@gnufish.net> wrote: > On Fri, May 31, 2013 at 7:10 AM, Bart Schaefer <schaefer@brasslantern.com> > wrote: > Now some question: > I've used some custom escape codes ( \033| ) to surround the important > info. Now I can trap these strings and easily work on them. This is > working. The problem is in the prompt. My PS1 is something like that: > > export XPIPETERMINATOR=$'\033|.' > PS1="${XPIPETERMINATOR}mario@squit $ " > > that "terminator" tells to my terminal that the previous command has just > finished. I use it to close any pending operation (show icons... git fancy > output): if I receive that, it means *for sure* that I am again on the > standard prompt. > The problem is that zsh does not know anything about that escape codes and > it thinks to have written more chars than it actually has: and it sends the > carriage return too early (when I reach the end of the line). > So: how can I tell to zsh to forget those 2 or 3 special chars? %{ %} -- Mikael Magnusson ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange initial escape string 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 1 sibling, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2013-06-15 18:44 UTC (permalink / raw) To: Mario Signorino; +Cc: zsh-workers On Jun 15, 1:31pm, Mario Signorino wrote: } } export XPIPETERMINATOR=$'\033|.' } PS1="${XPIPETERMINATOR}mario@squit $ " } } The problem is that zsh does not know anything about that escape codes and } it thinks to have written more chars than it actually has: and it sends the } carriage return too early (when I reach the end of the line). } So: how can I tell to zsh to forget those 2 or 3 special chars? Or: is } there any other way to know that the execution of the last command is just } finished? something as a "postexec()" function? As Mikael has already so tersely mentioned: PS1="%{${XPIPETERMINATOR}%}mario@squit $ " Assuming xpipe is responsible for starting the shell that runs inside the emulator, I would suggest that xpipe itself export XPIPETERMINATOR, so that zsh init files can test for it and adjust prompts. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange initial escape string 2013-06-15 18:44 ` Bart Schaefer @ 2013-06-15 19:14 ` Mario Signorino 0 siblings, 0 replies; 7+ messages in thread From: Mario Signorino @ 2013-06-15 19:14 UTC (permalink / raw) Cc: zsh-workers On Sat, Jun 15, 2013 at 8:44 PM, Bart Schaefer <schaefer@brasslantern.com> wrote: > > As Mikael has already so tersely mentioned: > > PS1="%{${XPIPETERMINATOR}%}mario@squit $ " ops! sometimes my brain simply refuses to learn... Tnx! Mario ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-06-15 19:15 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-05-30 21:28 Strange initial escape string Mario Signorino 2013-05-30 22:56 ` Mario Signorino 2013-05-31 5:10 ` Bart Schaefer 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
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).