summaryrefslogtreecommitdiff
path: root/phpdbg_utils.c
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2014-02-16 17:09:15 +0100
committerBob Weinand <bobwei9@hotmail.com>2014-02-16 17:09:15 +0100
commit7b44890ac476cc45ff107048a2efbb72298b5a72 (patch)
tree2e6a8b343182df5c60861019916649f2b2919996 /phpdbg_utils.c
parent0dc1072a190c10f0ee1be67103549c1ec79436ea (diff)
parent21c973d3de5d0b3d3ce8377dfdd07bd3940d72d1 (diff)
downloadphp-git-7b44890ac476cc45ff107048a2efbb72298b5a72.tar.gz
Merge pull request #73 from TerryE/new-help
New help updates
Diffstat (limited to 'phpdbg_utils.c')
-rw-r--r--phpdbg_utils.c21
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;
+} /* }}} */
+