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
This commit is contained in:
Axel Dörfler 2005-04-13 12:51:26 +00:00
parent 7c71cdd82d
commit fce78d9e21
2 changed files with 17 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include <string.h>
#include <stdio.h>
#include <termios.h>
#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;
}

View File

@ -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;
}