first commit
This commit is contained in:
commit
0610f4aeab
130 changed files with 9897 additions and 0 deletions
24
fn/-z4h-get-cursor-pos
Normal file
24
fn/-z4h-get-cursor-pos
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env zsh
|
||||
#
|
||||
# If invoked with an argument, passes unrecognized TTY content to zle.
|
||||
|
||||
local fd=${_z4h_tty_fd-1}
|
||||
[[ -t $fd ]] || return
|
||||
|
||||
# Note: `read -u $fd` doesn't work.
|
||||
|
||||
local resp
|
||||
IFS= builtin read -srt 5 -d R resp$'?\e[6n' <&$fd || return
|
||||
|
||||
while [[ $resp != *$'\e['<->';'<-> ]]; do
|
||||
IFS= builtin read -srt 5 -d R resp <&$fd || return
|
||||
done
|
||||
|
||||
if (( ARGC )); then
|
||||
local pref=${resp%$'\e['*}
|
||||
[[ -n $pref ]] && print -rz -- $pref
|
||||
fi
|
||||
|
||||
resp=${resp##*'['}
|
||||
typeset -g cursor_y=${resp%';'*}
|
||||
typeset -g cursor_x=${resp#*';'}
|
Loading…
Add table
Add a link
Reference in a new issue