From 88bd558a73e9b29c05b5cc3e9bb78aee46ac5ee0 Mon Sep 17 00:00:00 2001 From: Terry Ellison Date: Sun, 2 Feb 2014 16:35:28 +0000 Subject: Work in progress chekpoint of changes to help module. To allow peer review and feedback --- phpdbg_utils.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpdbg_utils.c') diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 1effcfccaf..4bb671247e 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -30,6 +30,8 @@ #ifdef _WIN32 # include "win32/time.h" +#elif defined(HAVE_SYS_IOCTL_H) +# include "sys/ioctl.h" #endif ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -385,3 +387,22 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ return PHPDBG_G(prompt)[1]; } /* }}} */ + +PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ +{ + int columns; +#ifdef _win32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; +#elif defined(HAVE_SYS_IOCTL_H) + struct winsize w; + + columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100; +#else + columns = 100; +#endif + return columns; +} /* }}} */ + -- cgit v1.2.1