[BusyBox-cvs] busybox/editors vi.c,1.28,1.29

Erik Andersen andersen at busybox.net
Mon Sep 15 08:33:39 UTC 2003


Update of /var/cvs/busybox/editors
In directory winder:/tmp/cvs-serv10511/editors

Modified Files:
	vi.c 
Log Message:
Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize)
to ensure proper fallback behavior on, i.e. serial consoles.
 -Erik


Index: vi.c
===================================================================
RCS file: /var/cvs/busybox/editors/vi.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- vi.c	19 Mar 2003 09:11:45 -0000	1.28
+++ vi.c	15 Sep 2003 08:33:36 -0000	1.29
@@ -197,9 +197,6 @@
 #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 @@
 	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 @@
 	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)




More information about the busybox-cvs mailing list