From 73d5358fb91d80ebe3cb39d5193c3ed5f335165a Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 12 Apr 1994 15:08:30 +0000 Subject: [PATCH] (set_window_size): New function. --- src/sysdep.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/sysdep.c b/src/sysdep.c index 9b5ee10749..3de75eb6dc 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1371,10 +1371,10 @@ tabs_safe_p () EMACS_GET_TTY (input_fd, &tty); return EMACS_TTY_TABS_OK (&tty); } - + /* Get terminal size from system. - Store number of lines into *heightp and width into *widthp. - If zero or a negative number is stored, the value is not valid. */ + Store number of lines into *HEIGHTP and width into *WIDTHP. + We store 0 if there's no valid information. */ get_frame_size (widthp, heightp) int *widthp, *heightp; @@ -1431,6 +1431,43 @@ get_frame_size (widthp, heightp) #endif /* not BSD-style */ } +/* Set the logical window size associated with descriptor FD + to HEIGHT and WIDTH. This is used mainly with ptys. */ + +int +set_window_size (fd, height, width) + int fd, height, width; +{ +#ifdef TIOCSWINSZ + + /* BSD-style. */ + struct winsize size; + size.ws_row = height; + size.ws_col = width; + + if (ioctl (fd, TIOCSWINSZ, &size) == -1) + return 0; /* error */ + else + return 1; + +#else +#ifdef TIOCSSIZE + + /* SunOS - style. */ + struct ttysize size; + size.ts_lines = height; + size.ts_cols = width; + + if (ioctl (fd, TIOCGSIZE, &size) == -1) + return 0; + else + return 1; +#else + return -1; +#endif /* not SunOS-style */ +#endif /* not BSD-style */ +} + /* Prepare the terminal for exiting Emacs; move the cursor to the bottom of the frame, turn off interrupt-driven I/O, etc. */ -- 2.20.1