Commit f5d866e3 authored by Per Bothner's avatar Per Bothner

Remove OSC 133;Z - just use OSC 133;D for command end.

That requried some tweaks to support options for OSC 133;D while
still not break legacy iTerm2.  Also some fixes for "cancel".
parent 5d06a20e
......@@ -8,18 +8,19 @@ esac
while test -L "$thisfile"; do thisfile=$(readlink -f "$thisfile"); done
source `dirname "$thisfile"`/bash-preexec.sh
#PS1='\[\e]133;P\a\]'$PS1'\[\e]133;B\a\e]122;> \a\]'
#PS1='\[\e]133]A;repaint;aid='"$BASHPID"'\a\e]133;P\a\]'$PS1'\[\e]133;B\a\e]122;> \a\]'
_prompt_executing=""
function __prompt_precmd() {
local ret="$?"
local err=`if test "$ret" != "0"; then echo ";err=$ret"; fi`
_PROMPT_SAVE_PS1="$PS1"
_PROMPT_SAVE_PS2="$PS2"
PS1='\[\e]133;P;k=i\a\]'$PS1'\[\e]133;B\a\e]122;> \a\]'
PS2='\[\e]133;P;k=c\a\]'$PS2'\[\e]133;B\a\]'
if test "$_prompt_executing" = "1"
if test "$_prompt_executing" != "0"
then
printf "\033]133;Z%s;aid=%s\007" "$err" "$BASHPID"
_PROMPT_SAVE_PS1="$PS1"
_PROMPT_SAVE_PS2="$PS2"
PS1='\[\e]133;P;k=i\a\]'$PS1'\[\e]133;B\a\e]122;> \a\]'
PS2='\[\e]133;P;k=c\a\]'$PS2'\[\e]133;B\a\]'
fi
if test "$_prompt_executing" != ""
then
printf "\033]133;D;%s;aid=%s\007" "$ret" "$BASHPID"
fi
printf "\033]133;A;cl=m;aid=%s\007" "$BASHPID"
_prompt_executing=0
......
......@@ -11,8 +11,7 @@ if status --is-interactive
set _fishprompt_prompt_count (math $_fishprompt_prompt_count + 1)
# don't use post-exec, because it is called *before* omitted-newline output
if [ -n "$_fishprompt_postexec" ]
set ret (if test "$_fishprompt_postexec" != "0"; echo ";err=$_fishprompt_postexec"; end)
printf "\033]133;Z%s;aid=%s\007" "$ret" $_fishprompt_aid
printf "\033]133;D;%s;aid=%s\007" "$_fishprompt_postexec" $_fishprompt_aid
end
printf "\033]133;A;aid=%s;cl=m\007" $_fishprompt_aid
end
......
#PS1='\[\e]133;P\a\]'$PS1'\[\e]133;B\a\e]122;> \a\]'
#PS1='\[\e]133]A;repaint;aid='"$BASHPID"'\a\e]133;P\a\]'$PS1'\[\e]133;B\a\e]122;> \a\]'
_prompt_executing=""
function __prompt_precmd() {
local ret="$?"
local err=`if test "$ret" != "0"; then echo ";err=$ret"; fi`
_PROMPT_SAVE_PS1="$PS1"
_PROMPT_SAVE_PS2="$PS2"
PS1=$'%{\e]133;P;k=i\a%}'$PS1$'%{\e]133;B\a\e]122;> \a%}'
PS2=$'%{\e]133;P;k=c\a%}'$PS2$'%{\e]133;B\a%}'
if test "$_prompt_executing" = "1"
if test "$_prompt_executing" != "0"
then
printf "\033]133;Z%s;aid=%s\007" "$err" "$$"
_PROMPT_SAVE_PS1="$PS1"
_PROMPT_SAVE_PS2="$PS2"
PS1=$'%{\e]133;P;k=i\a%}'$PS1$'%{\e]133;B\a\e]122;> \a%}'
PS2=$'%{\e]133;P;k=c\a%}'$PS2$'%{\e]133;B\a%}'
fi
if test "$_prompt_executing" != ""
then
printf "\033]133;D;%s;aid=%s\007" "$ret" "$$"
fi
printf "\033]133;A;cl=m;aid=%s\007" "$$"
_prompt_executing=0
......
......@@ -90,17 +90,26 @@ For example fish uses `⏎`, while zsh uses `%` (in inverse video).
> End of input, and start of output.
`OSC "133;Z"` _options_ `"\007"`
`OSC "133;D"` [`";"` _exit-code_ _options ]`"\007"`
> End of current command.
> Applicable options: `aid`, `cancel`, `err`.
> The _exit-code_ need not be specified if if there are no _options_,
> or if the command was cancelled (no `OSC "133;C"`),
> such as by typing an interrupt/cancel character
> (typically ctrl-C) during line-editing.
> Otherwise, it must be an integer code, where `0` means the command
> succeeded, and other values indicate failure.
> In additing to the _exit-code_ there may be an `err=` option,
> which non-legacy terminals should give precedence to.
> The `err=_value_` option is more general: an empty string is success,
> and any non-empty _value_ (which need not be an integer) is an error code.
> So to indicate success both ways you could send
> `OSC "133;D;0;err=\007"`, though `OSC "133;D;0\007" is shorter.
`OSC "133;D"` [`";"` _exit-code_]`"\007"`
> Same as `OSC "133;Z"` [`";err="` _exit-code_]`"\007"`
> (except that a zero _exit-code_ is equivalet to `OSC "133;Z\007"`
> without the _exit-code_).
> For backward compatibility with Iterm2/FinalTerm.
> These rules are for backward compatibility with iTerm2.
> Applicable options: `aid`, `err`.
## General options syntax
......@@ -123,10 +132,6 @@ A terminal must ignore an _option_ whose _option-name_ it doesn't recognize.
`aid=` _value_
> The current _application identifier_.
`cancel`
> A command was cancelled before execution started, for example by
> typing ctrl-c on Unix-like systems (sending `SIGINT`) during input editing.
`err=` _value_
> Only applicable to a `OSC "133;Z"`command.
> Specifies a string value that reports an error code from the command.
......@@ -248,6 +253,13 @@ line wider than screen width), the prompt should be written at
the end of the final screen line, not the first. This allows
line-wrap indicators to be correct.
### Canceling input
If input is cancelled (such as by typing ctrl-c),
then the application should avoid emitting a `OSC 133;C` command,
and instead just emit a `OSC 133;D` command.
It is suggested it specify a `err=CANCEL` option, but it is not required.
**Issue**: Possibly add a way to mark indentation as distinct from prompts.
### Window re-size
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment