Browse Source

TTY: fixes after rebase.

Code clean up.
Modification of tty_refresh for NCurses: call doupdate() after refresh()
every time.
tty_draw_box_slow() is not private function of TTY now.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 15 years ago
parent
commit
509f4d5c4f
8 changed files with 21 additions and 27 deletions
  1. 1 1
      edit/editdraw.c
  2. 2 2
      src/tty/color-slang.c
  3. 3 13
      src/tty/key.c
  4. 0 9
      src/tty/tty-internal.h
  5. 4 1
      src/tty/tty-ncurses.c
  6. 1 0
      src/tty/tty-slang.c
  7. 9 1
      src/tty/tty.c
  8. 1 0
      src/tty/tty.h

+ 1 - 1
edit/editdraw.c

@@ -279,7 +279,7 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
     if (option_line_state) {
         int i;
         for (i = 0; i < LINE_STATE_WIDTH; i++)
-            if (status[i] == '\0') {
+            if (status[i] == '\0')
                 status[i] = ' ';
 
         tty_setcolor (LINE_STATE_COLOR);

+ 2 - 2
src/tty/color-slang.c

@@ -154,10 +154,10 @@ tty_try_alloc_color_pair (const char *fg, const char *bg)
     p->next = NULL;
     p->fg = fg ? g_strdup (fg) : NULL;
     p->bg = bg ? g_strdup (bg) : NULL;
-    if (fg == NULL
+    if (fg == NULL)
         /* Index in color_map array = COLOR_INDEX - 1 */
 	fg = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].fg;
-    if (bg == NULL
+    if (bg == NULL)
 	bg = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].bg;
     p->index = alloc_color_pair (fg, bg);
     return p->index;

+ 3 - 13
src/tty/key.c

@@ -455,6 +455,9 @@ static key_define_t qansi_key_defines[] =
 /* timeout for old_esc_mode in usec */
 static int keyboard_key_timeout = 1000000;	/* settable via env */
 
+/* This holds all the key definitions */
+static key_def *keys = NULL;
+
 static int input_fd;
 static int disabled_channels = 0; /* Disable channels checking */
 
@@ -1485,19 +1488,6 @@ get_key_code (int no_delay)
     return correct_key_code (c);
 }
 
-/* Return the code associated with the symbolic name keyname */
-int
-lookup_key (char *keyname)
-{
-    int i;
-
-    for (i = 0; key_name_conv_tab [i].code; i++)
-	if (str_casecmp (key_name_conv_tab [i].name, keyname) == 0)
-	    return key_name_conv_tab [i].code;
-
-    return 0;
-}
-
 /* Returns a character read from stdin with appropriate interpretation */
 /* Also takes care of generated mouse events */
 /* Returns EV_MOUSE if it is a mouse event */

+ 0 - 9
src/tty/tty-internal.h

@@ -14,13 +14,4 @@ extern gboolean slow_tty;
 /* The mouse is currently: TRUE - enabled, FALSE - disabled */
 extern gboolean mouse_enabled;
 
-static inline void
-tty_draw_box_slow (int y, int x, int ys, int xs)
-{
-    tty_draw_hline (y, x, ' ', xs);
-    tty_draw_vline (y, x, ' ', ys);
-    tty_draw_vline (y, x + xs - 1, ' ', ys);
-    tty_draw_hline (y + ys - 1, x, ' ', xs);
-}
-
 #endif			/* MC_TTY_INTERNAL_H */

+ 4 - 1
src/tty/tty-ncurses.c

@@ -41,6 +41,7 @@
 #endif
 
 #include "../../src/tty/tty-internal.h"		/* slow_tty */
+#include "../../src/tty/tty.h"			/* tty_draw_box_slow */
 #include "../../src/tty/color-ncurses.h"
 #include "../../src/tty/color-internal.h"
 #include "../../src/tty/win.h"
@@ -316,8 +317,10 @@ tty_refresh (void)
 #ifdef WITH_BACKGROUND
     if (!we_are_background)
 #endif				/* WITH_BACKGROUND */
+    {
 	refresh ();
-    doupdate ();
+	doupdate ();
+    }
 }
 
 void

+ 1 - 0
src/tty/tty-slang.c

@@ -43,6 +43,7 @@
 #include "../../src/global.h"
 
 #include "../../src/tty/tty-internal.h"		/* slow_tty */
+#include "../../src/tty/tty.h"			/* tty_draw_box_slow */
 #include "../../src/tty/color-slang.h"
 #include "../../src/tty/color-internal.h"
 #include "../../src/tty/mouse.h"	/* Gpm_Event is required in key.h */

+ 9 - 1
src/tty/tty.c

@@ -40,7 +40,6 @@
 #include "../../src/tty/tty-internal.h"
 
 #include "../../src/strutil.h"
-#include "../../src/background.h"	/* we_are_background */
 
 /*** global variables **************************************************/
 
@@ -136,3 +135,12 @@ tty_print_one_vline (void)
     else
 	tty_print_alt_char (ACS_VLINE);
 }
+
+void
+tty_draw_box_slow (int y, int x, int ys, int xs)
+{
+    tty_draw_hline (y, x, ' ', xs);
+    tty_draw_vline (y, x, ' ', ys);
+    tty_draw_vline (y, x + xs - 1, ' ', ys);
+    tty_draw_hline (y + ys - 1, x, ' ', xs);
+}

+ 1 - 0
src/tty/tty.h

@@ -74,6 +74,7 @@ extern void tty_print_one_hline (void);
 extern void tty_draw_hline (int y, int x, int ch, int len);
 extern void tty_draw_vline (int y, int x, int ch, int len);
 extern void tty_draw_box (int y, int x, int rows, int cols);
+extern void tty_draw_box_slow (int y, int x, int ys, int xs);
 extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
 
 extern char *tty_tgetstr (const char *name);