help-bash
[Top][All Lists]
Advanced

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

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


From: Dennis Williamson
Subject: Re: [Help-bash] Storing cursor positions using tput into an array.
Date: Thu, 14 Sep 2017 15:46:50 -0500

On Thu, Sep 14, 2017 at 1:26 PM, Bob Proulx <address@hidden> wrote:

> Greg Wooledge wrote:
> > The real voodoo is how to GET the cursor position into the coordinate
> > arrays in the first place.  Starting from
> >
> > https://unix.stackexchange.com/questions/88296/get-
> vertical-cursor-position/183121#183121
> >
> > I ended up with:
> >
> > wooledg:~$ IFS=$'\e[;' read -sdR -p $'\e[6n' _ _ 'y[1]' 'x[1]'
> > wooledg:~$ declare -p x y
> > declare -a x=([1]="1")
> > declare -a y=([1]="45")
> >
> > Not tested on anything but my own system in one terminal emulator.
> > Use at your own risk, etc.
>
> Yes.  Getting the cursor position seems to be voodoo.  Unfortunately
> using \e escape hard codes for one terminal type.  The above is the
> popular one today but it won't work for other types such as say
> hpterm.  (I didn't test hpterm but I assume not.)  But I haven't found
> a better way to ge tthis info either.
>
> I think the original plan was that if some application wanted to
> position the cursor then that application must position and track the
> position itself completely.  Like the way the curses library does it.
> Then it will know where the cursor is later because it placed the
> cursor there, obviating the need to ask the terminal where the cursor
> happens to be at the moment.
>
> Bob
>
>
One issue might be knowing where the cursor is after output which uses
address@hidden or address@hidden (and possibly others) unless you know of a way 
to do
that.

-- 
Visit serverfault.com to get your system administration questions answered.


reply via email to

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