TermReadKey
view release on metacpan or search on metacpan
/* Logic: return maximum possible screen width, but return
only currently selected height */
if (retwidth)
*retwidth = info.dwMaximumWindowSize.X;
/*info.srWindow.Right - info.srWindow.Left;*/
if (retheight)
*retheight = info.srWindow.Bottom - info.srWindow.Top;
if (xpix)
*xpix = 0;
if (ypix)
*ypix = 0;
return 0;
} else
return -1;
}
#else
int GetTermSizeWin32(pTHX_ PerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix)
{
croak("TermSizeWin32 is not implemented on this architecture");
return 0;
}
#endif /* USE_WIN32 */
STATIC int termsizeoptions() {
return 0
#ifdef VIOMODE
| 1
#endif
#if defined(TIOCGWINSZ) && !defined(DONT_USE_GWINSZ)
| 2
#endif
#if defined(TIOCGSIZE) && !defined(DONT_USE_GSIZE)
| 4
#endif
#if defined(USE_WIN32)
| 8
#endif
;
}
int SetTerminalSize(pTHX_ PerlIO *file,int width,int height,int xpix,int ypix)
{
int handle=PerlIO_fileno(file);
#ifdef VIOMODE
return -1;
#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
50, B50,
#endif
#ifdef B75
75, B75,
#endif
#ifdef B110
110, B110,
#endif
#ifdef B134
134, B134,
#endif
#ifdef B150
150, B150,
#endif
#ifdef B200
200, B200,
#endif
#ifdef B300
300, B300,
#endif
#ifdef B600
600, B600,
#endif
#ifdef B1200
1200, B1200,
#endif
#ifdef B1800
1800, B1800,
#endif
#ifdef B2400
2400, B2400,
#endif
#ifdef B4800
4800, B4800,
#endif
#ifdef B9600
9600, B9600,
#endif
#ifdef B19200
19200, B19200,
#endif
#ifdef B38400
38400, B38400,
#endif
#ifdef B57600
57600, B57600,
#endif
#ifdef B115200
115200, B115200,
#endif
( run in 0.451 second using v1.01-cache-2.11-cpan-2398b32b56e )