From 991c60208000192f969bf47c0d007eed9ef064ee Mon Sep 17 00:00:00 2001 From: WuWuWuJi <117707145+WuWuWuJi@users.noreply.github.com> Date: Tue, 8 Nov 2022 13:27:03 +0800 Subject: [PATCH] Fix a error of Terminal::get_screen_columns. When using replxx with the command of "tee", it will be unsuccessful to get screen columns of Terminal from "STDOUT_FILENO" . --- src/terminal.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/terminal.cxx b/src/terminal.cxx index d737edf..0be3bec 100644 --- a/src/terminal.cxx +++ b/src/terminal.cxx @@ -153,7 +153,7 @@ int Terminal::get_screen_columns( void ) { cols = inf.dwSize.X; #else struct winsize ws; - cols = ( ioctl( 1, TIOCGWINSZ, &ws ) == -1 ) ? 80 : ws.ws_col; + cols = ( ioctl( STDIN_FILENO, TIOCGWINSZ, &ws ) == -1 ) ? 80 : ws.ws_col; #endif // cols is 0 in certain circumstances like inside debugger, which creates // further issues @@ -168,7 +168,7 @@ int Terminal::get_screen_rows( void ) { rows = 1 + inf.srWindow.Bottom - inf.srWindow.Top; #else struct winsize ws; - rows = (ioctl(1, TIOCGWINSZ, &ws) == -1) ? 24 : ws.ws_row; + rows = ( ioctl( STDIN_FILENO, TIOCGWINSZ, &ws) == -1) ? 24 : ws.ws_row; #endif return (rows > 0) ? rows : 24; }