TermReadKey
view release on metacpan or search on metacpan
ReadKey.pm.PL view on Meta::CPAN
my ($prog) = "resize";
# Workaround for Solaris path silliness
if ( -f "/usr/openwin/bin/resize" ) {
$prog = "/usr/openwin/bin/resize";
}
my ($resize) = scalar(`$prog 2>/dev/null`);
if (defined $resize
and ( $resize =~ /COLUMNS\s*=\s*(\d+)/
or $resize =~ /setenv\s+COLUMNS\s+'?(\d+)/ )
)
{
$results[0] = $1;
if ( $resize =~ /LINES\s*=\s*(\d+)/
or $resize =~ /setenv\s+LINES\s+'?(\d+)/ )
{
$results[1] = $1;
@results[ 2, 3 ] = ( 0, 0 );
}
else
{
@results = ();
}
}
else
#if defined(TIOCSWINSZ) && !defined(DONT_USE_SWINSZ)
char buffer[10];
struct winsize w;
w.ws_col=width;
w.ws_row=height;
w.ws_xpixel=xpix;
w.ws_ypixel=ypix;
if (ioctl (handle, TIOCSWINSZ, &w) == 0) {
sprintf(buffer,"%d",width); /* Be polite to our children */
my_setenv("COLUMNS",buffer);
sprintf(buffer,"%d",height);
my_setenv("LINES",buffer);
return 0;
}
else {
croak("TIOCSWINSZ ioctl call to set terminal size failed: %s",Strerror(errno));
return -1;
}
#else
# if defined(TIOCSSIZE) && !defined(DONT_USE_SSIZE)
char buffer[10];
struct ttysize w;
w.ts_lines=height;
w.ts_cols=width;
w.ts_xxx=xpix;
w.ts_yyy=ypix;
if (ioctl (handle, TIOCSSIZE, &w) == 0) {
sprintf(buffer,"%d",width);
my_setenv("COLUMNS",buffer);
sprintf(buffer,"%d",height);
my_setenv("LINES",buffer);
return 0;
}
else {
croak("TIOCSSIZE ioctl call to set terminal size failed: %s",Strerror(errno));
return -1;
}
# else
/*sprintf(buffer,"%d",width) * Should we could do this and then *
my_setenv("COLUMNS",buffer) * said we succeeded? *
sprintf(buffer,"%d",height);
my_setenv("LINES",buffer)*/
return -1; /* Fail */
# endif
#endif
#endif
}
STATIC const I32 terminal_speeds[] = {
#ifdef B50
magic_nextpack|||
magic_regdata_cnt|||
magic_regdatum_get|||
magic_regdatum_set|||
magic_scalarpack|||
magic_set_all_env|||
magic_setarylen|||
magic_setcollxfrm|||
magic_setdbline|||
magic_setdefelem|||
magic_setenv|||
magic_sethint|||
magic_setisa|||
magic_setmglob|||
magic_setnkeys|||
magic_setpack|||
magic_setpos|||
magic_setregexp|||
magic_setsig|||
magic_setsubstr|||
magic_settaint|||
my_fflush_all||5.006000|
my_fork||5.007003|n
my_kid|||
my_lstat_flags|||
my_lstat||5.019003|
my_memcmp|||n
my_memset||5.004000|n
my_pclose||5.004000|
my_popen_list||5.007001|
my_popen||5.004000|
my_setenv|||
my_snprintf|5.009004||pvn
my_socketpair||5.007003|n
my_sprintf|5.009003||pvn
my_stat_flags|||
my_stat||5.019003|
my_strftime||5.007002|
my_strlcat|5.009004||pn
my_strlcpy|5.009004||pn
my_unexec|||
my_vsnprintf||5.009004|n
( run in 1.755 second using v1.01-cache-2.11-cpan-2398b32b56e )