Unix Programming - Re: Get current screen location (was: Re: Terminal output with escape sequences: Any [

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2007 > Re: Get current screen location (was: Re: Terminal output with escape sequences: Any [





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Get current screen location (was: Re: Terminal output with escape sequences: Any [
Stephane CHAZELAS

2007-10-24, 7:31 am

2007-10-24, 07:17(+02), Markus Mayer:
> By the way: Is there any function that allows me to retrieve the curremt
> cursor coordinates?

[...]

On many terminals, you can send:

printf '\033[6n'

or

tput u7

Then, the terminal will reply back with:

^[[y;xR

That you can read like that:

old_settings=$(stty -g)
stty -icanon min 1 time 2 -echo
printf '\033[6n'
IFS='[;R'
set -f
set -- $(dd count=1 2> /dev/null)
stty "$old_settings"

echo "x: $3, y: $2"

--
Stéphane
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com