Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Addressing the cursor of a VT100 style terminal emulator using perl (http://www.velocityreviews.com/forums/t895829-addressing-the-cursor-of-a-vt100-style-terminal-emulator-using-perl.html)

Jeff Silverman 12-29-2005 06:06 AM

Addressing the cursor of a VT100 style terminal emulator using perl
 
I am working on a perl program which uses VT100 style escape codes and
runs in gnome-terminal or konsole or rxterm or xterm or similar.

I want to know if there is a way to sent an escape sequence to the
terminal emulator which queries for the current size of the screen and
gets a report back. I am assuming that the user can resize the
terminal. I plan to query the terminal size at the end of each pass.
If the user resizes the terminal in the middle of pass - well - he's
going to be confused.

Does anybody know how to do this? I have looked at Term::Cap but I
don't see where that queries the current terminal size. Ditto for
Term::ANSIColor.


Many thanks,


Jeff Silverman

Samwyse 12-29-2005 07:33 AM

Re: Addressing the cursor of a VT100 style terminal emulator usingperl
 
Jeff Silverman <"Remove the letters in all caps" wrote:
> I am working on a perl program which uses VT100 style escape codes and
> runs in gnome-terminal or konsole or rxterm or xterm or similar.
>
> I want to know if there is a way to sent an escape sequence to the
> terminal emulator which queries for the current size of the screen and
> gets a report back. I am assuming that the user can resize the
> terminal. I plan to query the terminal size at the end of each pass.
> If the user resizes the terminal in the middle of pass - well - he's
> going to be confused.
>
> Does anybody know how to do this? I have looked at Term::Cap but I
> don't see where that queries the current terminal size. Ditto for
> Term::ANSIColor.


Actually, when a terminal is resized, your app gets a SIGWINCH signal.
You should then issue an ioctl to get the new size:
struct winsize size;
ioctl(fileno(stdout), TIOCGWINSZ, &size);
This way, you don't have to query the terminal and worry about the user
hitting a key at the wrong time. The ncurses library handles all of
this for you, I suppose that Term::Cap does as well. The next time you
call 'getch()', the library will return KEY_RESIZE to let you know what
happened. Typically, you repaint the entire screen at that point.

Googling the terms in all caps should tell you more.

Thomas Dickey 12-29-2005 01:10 PM

Re: Addressing the cursor of a VT100 style terminal emulator using perl
 
Samwyse <samwyse@gmail.com> wrote:
>> don't see where that queries the current terminal size. Ditto for
>> Term::ANSIColor.


> Actually, when a terminal is resized, your app gets a SIGWINCH signal.
> You should then issue an ioctl to get the new size:
> struct winsize size;
> ioctl(fileno(stdout), TIOCGWINSZ, &size);
> This way, you don't have to query the terminal and worry about the user
> hitting a key at the wrong time. The ncurses library handles all of
> this for you, I suppose that Term::Cap does as well. The next time you


I don't belive Term::Cap does this since it doesn't have a getch() method.
(likewise Term::AnsiColor).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


All times are GMT. The time now is 02:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.