diff options
author | Terry Ellison <Terry@ellisons.org.uk> | 2014-02-02 16:35:28 +0000 |
---|---|---|
committer | Terry Ellison <Terry@ellisons.org.uk> | 2014-02-02 16:35:28 +0000 |
commit | 88bd558a73e9b29c05b5cc3e9bb78aee46ac5ee0 (patch) | |
tree | 9d0bd8aa565f639345518f16a96f5be5b4922c3d /phpdbg_utils.c | |
parent | 261a5305c6b3528ec45d6e185c50dbac61916dd6 (diff) | |
download | php-git-88bd558a73e9b29c05b5cc3e9bb78aee46ac5ee0.tar.gz |
Work in progress chekpoint of changes to help module. To allow peer review and feedback
Diffstat (limited to 'phpdbg_utils.c')
-rw-r--r-- | phpdbg_utils.c | 21 |
1 files changed, 21 insertions, 0 deletions
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; +} /* }}} */ + |