help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Storing cursor positions using tput into an array.


From: Sinbad
Subject: [Help-bash] Storing cursor positions using tput into an array.
Date: Mon, 11 Sep 2017 18:24:16 +0530

Hi,

I want to extract the cursor positions using tput into an array and recover
to the stored cursor positions accordingly at later point in time. The
following function is able to extract the position
but i'm not able to figure out how to store each extraction in to an array.

save_pos () {
    export $1
    exec < /dev/tty
    oldstty=$(stty -g)
    stty raw -echo min 0
    echo -en "\033[6n" > /dev/tty
    IFS=';' read -r -d R -a pos
    stty $oldstty
    eval "$1[0]=$((${pos[0]:2} - 2))"
    eval "$1[1]=$((${pos[1]} - 1))"}

save_pos pos works, But i want something like save_pos pos[$index];
but this is resulting into
an error. how to achieve this ?

Thanks


reply via email to

[Prev in Thread] Current Thread [Next in Thread]