From fce78d9e213cbace22549179c63567003056de4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 13 Apr 2005 12:51:26 +0000 Subject: [PATCH] The console driver now supports TIOCGWINSZ (getting the window size), and "consoled" now uses this information to tell the TTY its size. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12355 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/common/console.cpp | 11 +++++++++++ src/tests/kernel/consoled/consoled.cpp | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/add-ons/kernel/drivers/common/console.cpp b/src/add-ons/kernel/drivers/common/console.cpp index fa601e6773..99901f45a8 100644 --- a/src/add-ons/kernel/drivers/common/console.cpp +++ b/src/add-ons/kernel/drivers/common/console.cpp @@ -15,6 +15,7 @@ #include #include +#include #define DEVICE_NAME "console" @@ -705,6 +706,16 @@ console_write(void *cookie, off_t pos, const void *buffer, size_t *_length) static status_t console_ioctl(void *cookie, uint32 op, void *buffer, size_t length) { + struct console_desc *console = (struct console_desc *)cookie; + + if (op == TIOCGWINSZ) { + struct winsize size; + size.ws_xpixel = size.ws_col = console->columns; + size.ws_ypixel = size.ws_row = console->lines; + + return user_memcpy(buffer, &size, sizeof(struct winsize)); + } + return B_BAD_VALUE; } diff --git a/src/tests/kernel/consoled/consoled.cpp b/src/tests/kernel/consoled/consoled.cpp index c0cf724152..b1225e96c4 100644 --- a/src/tests/kernel/consoled/consoled.cpp +++ b/src/tests/kernel/consoled/consoled.cpp @@ -210,6 +210,7 @@ start_console(struct console *con) } else { // set default mode struct termios termios; + struct winsize size; if (tcgetattr(con->tty_slave_fd, &termios) == 0) { termios.c_iflag = ICRNL; @@ -218,6 +219,11 @@ start_console(struct console *con) tcsetattr(con->tty_slave_fd, TCSANOW, &termios); } + + if (ioctl(con->console_fd, TIOCGWINSZ, &size, sizeof(struct winsize)) == 0) { + // we got the window size from the console + ioctl(con->tty_slave_fd, TIOCSWINSZ, &size, sizeof(struct winsize)); + } } break; }