aboutsummaryrefslogtreecommitdiffstats
path: root/sercp.c
diff options
context:
space:
mode:
authorPavel Vymetálek <pavel@vym.cz>2019-03-02 15:20:33 +0100
committerPavel Vymetálek <pavel@vym.cz>2019-03-02 15:20:33 +0100
commit33e4233b0f7a6f7c1c3b5f17b0ae6fa4f882457b (patch)
tree49d5cfe0409f6e2fe41e5488b486ffbaf84610e3 /sercp.c
parentf43a5c6f101fc801c5ac2a5925dfca2c00c19f02 (diff)
downloadsercp-pc-33e4233b0f7a6f7c1c3b5f17b0ae6fa4f882457b.tar.gz
Přidáno čtení šířky konzole i na Windows.
- testováno na wine a v XP a šířku ukazuje stále 80 znaků :-( - otestovat na win7 a win10
Diffstat (limited to 'sercp.c')
-rw-r--r--sercp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sercp.c b/sercp.c
index ea9388d..9364abc 100644
--- a/sercp.c
+++ b/sercp.c
@@ -232,7 +232,14 @@ void signal_handler_sigterm (int status) {
/************************************************************************/
int GetTerminalWidth(void) {
#ifdef __WIN32
- return (80);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ int columns;
+// int rows;
+
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
+ columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+// rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ return (columns);
#else
struct winsize termsize;
ioctl (STDOUT_FILENO, TIOCGWINSZ, &termsize);