Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Get cursor position (Was: [bug report] prompt can erase messages written on the terminal by background processes)
- X-seq: zsh-workers 51132
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>, Millian Poquet <millian.poquet@xxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Get cursor position (Was: [bug report] prompt can erase messages written on the terminal by background processes)
- Date: Thu, 8 Dec 2022 09:34:41 +0100
- Archived-at: <https://zsh.org/workers/51132>
- In-reply-to: <20221208082103.zg44mrv77jrizsaj@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- References: <9e3026aa-39a1-dd50-4d29-a64724d4eaaf@irit.fr> <CAN=4vMq2kc1cSV_0N-c6o32C3UR3hVSjE3mF+kV4pjcy7YR9=g@mail.gmail.com> <CAH+w=7aDn7SCv4Bao7ZQqtUaEv8EkvBXa15kM_nkF_GHLAcSFg@mail.gmail.com> <20221208082103.zg44mrv77jrizsaj@chazelas.org>
On Thu, Dec 8, 2022 at 9:21 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> curpos() {
> set -o localoptions -o extendedglob
> local match answer
> IFS= read -rsdR -t0.2 answer$'?\e[6n' &&
> [[ $answer = (#b)$'\e['(<->)';'(<->) ]] &&
> eval "${1-x}=\$match[2] ${2-y}=\$match[1]"
> }
Functions that accept output parameter names as arguments are tricky.
The following won't work:
# Which line is the cursor on?
curpos _ answer
print -r -- "The cursor is on the line number $answer"
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author