diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-09-15 08:33:45 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-09-15 08:33:45 +0000 |
commit | 8efe967018dd79aacfe3ca1e2583f115d744e466 (patch) | |
tree | 7590704be6cf03c87242043f5909e12eb4150356 /editors/vi.c | |
parent | c4f72d1426e03f046ac54a00d733a4a52c3a5d4b (diff) |
Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize)
to ensure proper fallback behavior on, i.e. serial consoles.
-Erik
Diffstat (limited to 'editors/vi.c')
-rw-r--r-- | editors/vi.c | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/editors/vi.c b/editors/vi.c index 144e9d760..e01ee1165 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -19,7 +19,7 @@ */ static const char vi_Version[] = - "$Id: vi.c,v 1.28 2003/03/19 09:11:45 mjn3 Exp $"; + "$Id: vi.c,v 1.29 2003/09/15 08:33:36 andersen Exp $"; /* * To compile for standalone use: @@ -197,9 +197,6 @@ static jmp_buf restart; // catch_sig() #if defined(CONFIG_FEATURE_VI_USE_SIGNALS) || defined(CONFIG_FEATURE_VI_CRASHME) static int my_pid; #endif -#ifdef CONFIG_FEATURE_VI_WIN_RESIZE -static struct winsize winsize; // remember the window size -#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */ #ifdef CONFIG_FEATURE_VI_DOT_CMD static int adding2q; // are we currently adding user input to q static Byte *last_modifying_cmd; // last modifying cmd for "." @@ -412,6 +409,14 @@ extern int vi_main(int argc, char **argv) return (0); } +#ifdef CONFIG_FEATURE_VI_WIN_RESIZE +//----- See what the window size currently is -------------------- +static inline void window_size_get(int fd) +{ + get_terminal_width_height(fd, &columns, &rows); +} +#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */ + static void edit_file(Byte * fn) { Byte c; @@ -2122,29 +2127,6 @@ static void cookmode(void) tcsetattr(0, TCSANOW, &term_orig); } -#ifdef CONFIG_FEATURE_VI_WIN_RESIZE -//----- See what the window size currently is -------------------- -static void window_size_get(int sig) -{ - int i; - - i = ioctl(0, TIOCGWINSZ, &winsize); - if (i != 0) { - // force 24x80 - winsize.ws_row = 24; - winsize.ws_col = 80; - } - if (winsize.ws_row <= 1) { - winsize.ws_row = 24; - } - if (winsize.ws_col <= 1) { - winsize.ws_col = 80; - } - rows = (int) winsize.ws_row; - columns = (int) winsize.ws_col; -} -#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */ - //----- Come here when we get a window resize signal --------- #ifdef CONFIG_FEATURE_VI_USE_SIGNALS static void winch_sig(int sig) |