diff options
Diffstat (limited to 'Functions/Zle')
-rw-r--r-- | Functions/Zle/.distfiles | 1 | ||||
-rw-r--r-- | Functions/Zle/define-composed-chars | 58 | ||||
-rw-r--r-- | Functions/Zle/match-words-by-style | 3 | ||||
-rw-r--r-- | Functions/Zle/move-line-in-buffer | 16 | ||||
-rw-r--r-- | Functions/Zle/read-from-minibuffer | 35 | ||||
-rw-r--r-- | Functions/Zle/replace-string | 20 | ||||
-rw-r--r-- | Functions/Zle/replace-string-again | 6 |
7 files changed, 102 insertions, 37 deletions
diff --git a/Functions/Zle/.distfiles b/Functions/Zle/.distfiles index 22eef1e6e..256044fa5 100644 --- a/Functions/Zle/.distfiles +++ b/Functions/Zle/.distfiles @@ -25,6 +25,7 @@ kill-word-match match-word-context match-words-by-style modify-current-argument +move-line-in-buffer narrow-to-region narrow-to-region-invisible predict-on diff --git a/Functions/Zle/define-composed-chars b/Functions/Zle/define-composed-chars index 12a357fc1..15d693a3f 100644 --- a/Functions/Zle/define-composed-chars +++ b/Functions/Zle/define-composed-chars @@ -135,6 +135,26 @@ a=j z[$a]="\ i 133 \ " +# ligature with f +a=f +z[$a]="\ +f FB00 \ +" +# ligature with i +a=i +z[$a]="\ +f FB01 \ +" +# ligature with l +a=l +z[$a]="\ +f FB02 \ +" +# ligature with t +a=t +z[$a]="\ +f FB05 s FB06 \ +" # eszett a=s z[$a]="\ @@ -252,6 +272,19 @@ z[$a]+=" Z 5e6" a=h z[$a]+=" S 5e9" +# Superscripts +a=S +z[$a]+=" \ +0 2070 1 B9 2 B2 3 B3 4 2074 5 2075 6 2076 7 2077 8 2078 9 2079 \ ++ 207a - 207b = 207C ( 207D ) 207E n 207f \ +" +# Subscripts +a=s +z[$a]+=" \ +0 2080 1 2081 2 2082 3 2083 4 2084 5 2085 6 2086 7 2087 8 2088 9 2089 \ ++ 208a - 208b = 208C ( 208D ) 208E \ +" + typeset -i 16 -Z 4 ia typeset -i 16 -Z 6 iuni # Extended width characters ^A, ^B, ... (not RFC1345) @@ -327,10 +360,14 @@ z[g]+=" R AE" z[m]+=" ' AF" # degree z[G]+=" D B0" +# degree centigrade +z[C]+=" o 2103" +# degree fahrenheit +z[F]+=" o 2109" +# numero +z[0]+=" N 2116" # +/- z[-]+=" + B1" -# superscripts -z[S]+=" 2 B2 3 B3" # lonely acute a=\' z[$a]+=" ' B4" @@ -342,8 +379,6 @@ z[I]+=" P B6" z[M]+=" . B7" # Lonely cedilla z[,]+=" ' B8" -# Superscript one -z[S]+=" 1 B9" # spanish masculine ordinal z[o]+=" - BA" # right guillemet @@ -415,5 +450,20 @@ z[0]+=" 0 221E" # Female and male z[m]+=" F 2640" z[l]+=" M 2642" +# Commercial AT +z[t]+=" A 40" +# Prime, double prime, triple prime +a=\' +z[$a]+=" 1 2032 2 2033 3 2034" +# Arrows +z[-]+=" < 2190" +a=\! +z[$a]+=" - 2191" +a=\> +z[$a]+=" - 2192 < 2194 = 21D2" +z[v]+=" - 2193" +z[D]+=" U 2195" +a=\= +z[$a]+=" < 21D0 = 21D4" zsh_accented_chars=("${(kv)z[@]}") diff --git a/Functions/Zle/match-words-by-style b/Functions/Zle/match-words-by-style index 69ceba76a..b387828f3 100644 --- a/Functions/Zle/match-words-by-style +++ b/Functions/Zle/match-words-by-style @@ -220,8 +220,7 @@ if [[ $wordstyle = *subword* ]]; then fi match=() -charskip= -repeat $skip charskip+=\? +charskip=${(l:skip::?:)} eval pat2='${RBUFFER##(#b)('${charskip}${spacepat}')('\ ${wordpat2}')('${spacepat}')}' diff --git a/Functions/Zle/move-line-in-buffer b/Functions/Zle/move-line-in-buffer new file mode 100644 index 000000000..5f37a9d71 --- /dev/null +++ b/Functions/Zle/move-line-in-buffer @@ -0,0 +1,16 @@ +#autoload + +# Line motions that do not leave the current history entry, +# for editing in multi-line buffers. + +# To use: +# autoload -Uz move-line-in-buffer +# zle -N up-line-in-buffer move-line-in-buffer +# zle -N down-line-in-buffer move-line-in-buffer +# +# then bindkey as you prefer + +local hno=$HISTNO curs=$CURSOR +zle .${WIDGET:s/in-buffer/or-history} "$@" && + (( HISTNO != hno && (HISTNO=hno, CURSOR=curs) )) +return 0 diff --git a/Functions/Zle/read-from-minibuffer b/Functions/Zle/read-from-minibuffer index fce6b5319..57e926884 100644 --- a/Functions/Zle/read-from-minibuffer +++ b/Functions/Zle/read-from-minibuffer @@ -19,26 +19,19 @@ while getopts "k:" opt; do done (( OPTIND > 1 )) && shift $(( OPTIND - 1 )) +local readprompt="$1" lbuf_init="$2" rbuf_init="$3" + +# Use anonymous function to make sure special values get restored, +# even if this function is called as a widget. +# local +h ensures special parameters stay special. +() { local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY " -# We could use the local variables mechanism to save these -# values, but if read-from-minibuffer is called as a widget -# (which isn't actually all that useful) the values won't be -# restored because the variables are already local at the current -# level and don't get restored when they go out of scope. -# We could do it with an additional function level. - local save_lbuffer=$LBUFFER - local save_rbuffer=$RBUFFER - local save_predisplay=$PREDISPLAY - local save_postdisplay=$POSTDISPLAY - local -a save_region_highlight - save_region_highlight=("${region_highlight[@]}") - -{ - LBUFFER="$2" - RBUFFER="$3" - PREDISPLAY="$pretext${1:-? }" - POSTDISPLAY= + local +h LBUFFER="$lbuf_init" + local +h RBUFFER="$rbuf_init" + local +h PREDISPLAY="$pretext${readprompt:-? }" + local +h POSTDISPLAY= + local +h -a region_highlight region_highlight=("P${#pretext} ${#PREDISPLAY} bold") if [[ -n $keys ]]; then @@ -50,12 +43,6 @@ done stat=$? (( stat )) || REPLY=$BUFFER fi -} always { - LBUFFER=$save_lbuffer - RBUFFER=$save_rbuffer - PREDISPLAY=$save_predisplay - POSTDISPLAY=$save_postdisplay - region_highlight=("${save_region_highlight[@]}") } return $stat diff --git a/Functions/Zle/replace-string b/Functions/Zle/replace-string index bc608e577..a3416a403 100644 --- a/Functions/Zle/replace-string +++ b/Functions/Zle/replace-string @@ -3,7 +3,15 @@ setopt extendedglob autoload -Uz read-from-minibuffer replace-string-again -local p1="Replace: " p2=" with: " +local p1 p2 + +if [[ -n $_replace_string_src ]]; then + p1="[$_replace_string_src -> $_replace_string_rep]"$'\n' +fi + +p1+="Replace: " +p2=" with: " + # Saving curwidget is necessary to avoid the widget name being overwritten. local REPLY previous curwidget=$WIDGET @@ -14,10 +22,12 @@ else fi read-from-minibuffer $p1 ${previous:+$_replace_string_src} || return 1 -typeset -g _replace_string_src=$REPLY +if [[ -n $REPLY ]]; then + typeset -g _replace_string_src=$REPLY -read-from-minibuffer "$p1$_replace_string_src$p2" \ - ${previous:+$_replace_string_rep} || return 1 -typeset -g _replace_string_rep=$REPLY + read-from-minibuffer "$p1$_replace_string_src$p2" \ + ${previous:+$_replace_string_rep} || return 1 + typeset -g _replace_string_rep=$REPLY +fi replace-string-again $curwidget diff --git a/Functions/Zle/replace-string-again b/Functions/Zle/replace-string-again index f24c14f88..dac3db755 100644 --- a/Functions/Zle/replace-string-again +++ b/Functions/Zle/replace-string-again @@ -40,8 +40,10 @@ if [[ $curwidget = *(pattern|regex)* ]]; then rep2+=$rep if [[ $curwidget = *regex* ]]; then autoload -Uz regexp-replace - regexp-replace LBUFFER $_replace_string_src $rep2 || return 1 - regexp-replace RBUFFER $_replace_string_src $rep2 || return 1 + integer ret=1 + regexp-replace LBUFFER $_replace_string_src $rep2 && ret=0 + regexp-replace RBUFFER $_replace_string_src $rep2 && ret=0 + return ret else LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} |