* gdb.base/attach.exp (do_attach_tests): Don't forget to kill second
[deliverable/binutils-gdb.git] / readline / display.c
index 5150ea6a07bef5ba8efaf3d7bb514f427052aaf4..e7b75912c9e465e49001c78a15041c975fa02559 100644 (file)
 
 #include <stdio.h>
 
+#ifdef __MSDOS__
+# include <pc.h>
+#endif
+
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
 #include "rlmbutil.h"
@@ -70,7 +74,7 @@ static void insert_some_chars PARAMS((char *, int, int));
 static void cr PARAMS((void));
 
 #if defined (HANDLE_MULTIBYTE)
-static int _rl_col_width PARAMS((char *, int, int));
+static int _rl_col_width PARAMS((const char *, int, int));
 static int *_rl_wrapped_line;
 #else
 #  define _rl_col_width(l, s, e)       (((e) <= (s)) ? 0 : (e) - (s))
@@ -1348,9 +1352,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
            {
              _rl_output_some_chars (nfd + lendiff, temp - lendiff);
 #if 0
-             _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff) - col_lendiff;
-#else
              _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
+#else
+             _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
 #endif
            }
        }
@@ -1510,8 +1514,15 @@ _rl_move_cursor_relative (new, data)
 #if defined (HANDLE_MULTIBYTE)
   /* If we have multibyte characters, NEW is indexed by the buffer point in
      a multibyte string, but _rl_last_c_pos is the display position.  In
-     this case, NEW's display position is not obvious. */
-  if ((MB_CUR_MAX == 1 || rl_byte_oriented ) && _rl_last_c_pos == new) return;
+     this case, NEW's display position is not obvious and must be
+     calculated. */
+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+    {
+      if (_rl_last_c_pos == new)
+       return;
+    }
+  else if (_rl_last_c_pos == _rl_col_width (data, 0, new))
+    return;
 #else
   if (_rl_last_c_pos == new) return;
 #endif
@@ -1594,11 +1605,7 @@ _rl_move_cursor_relative (new, data)
 #endif
     {
       if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
-       {
-         tputs (_rl_term_cr, 1, _rl_output_character_function);
-         for (i = 0; i < new; i++)
-           putc (data[i], rl_outstream);
-       }
+       _rl_backspace (_rl_last_c_pos - _rl_col_width (data, 0, new));
       else
        _rl_backspace (_rl_last_c_pos - new);
     }
@@ -1632,9 +1639,18 @@ _rl_move_vert (to)
     }
   else
     {                  /* delta < 0 */
+#ifdef __MSDOS__
+      int row, col;
+
+      fflush (rl_outstream); /* make sure the cursor pos is current! */
+      ScreenGetCursor (&row, &col);
+      ScreenSetCursor (row + delta, col);
+      i = -delta;    /* in case someone wants to use it after the loop */
+#else /* !__MSDOS__ */
       if (_rl_term_up && *_rl_term_up)
        for (i = 0; i < -delta; i++)
          tputs (_rl_term_up, 1, _rl_output_character_function);
+#endif /* !__MSDOS__ */
     }
 
   _rl_last_v_pos = to;         /* Now TO is here */
@@ -1848,9 +1864,12 @@ void
 _rl_clear_to_eol (count)
      int count;
 {
+#ifndef __MSDOS__
   if (_rl_term_clreol)
     tputs (_rl_term_clreol, 1, _rl_output_character_function);
-  else if (count)
+  else
+#endif
+  if (count)
     space_to_eol (count);
 }
 
@@ -1871,10 +1890,15 @@ space_to_eol (count)
 void
 _rl_clear_screen ()
 {
+#if defined (__GO32__)
+  ScreenClear ();      /* FIXME: only works in text modes */
+  ScreenSetCursor (0, 0);  /* term_clrpag is "cl" which homes the cursor */
+#else
   if (_rl_term_clrpag)
     tputs (_rl_term_clrpag, 1, _rl_output_character_function);
   else
     rl_crlf ();
+#endif
 }
 
 /* Insert COUNT characters from STRING to the output stream at column COL. */
@@ -1883,6 +1907,9 @@ insert_some_chars (string, count, col)
      char *string;
      int count, col;
 {
+#ifdef __MSDOS__
+  _rl_output_some_chars (string, count);
+#else  /* !__MSDOS__ */
   /* DEBUGGING */
   if (MB_CUR_MAX == 1 || rl_byte_oriented)
     if (count != col)
@@ -1921,6 +1948,7 @@ insert_some_chars (string, count, col)
       if (_rl_term_ei && *_rl_term_ei)
        tputs (_rl_term_ei, 1, _rl_output_character_function);
     }
+#endif /* !__MSDOS__ */
 }
 
 /* Delete COUNT characters from the display line. */
@@ -1931,6 +1959,7 @@ delete_chars (count)
   if (count > _rl_screenwidth) /* XXX */
     return;
 
+#ifndef __MSDOS__
   if (_rl_term_DC && *_rl_term_DC)
     {
       char *buffer;
@@ -1943,6 +1972,7 @@ delete_chars (count)
        while (count--)
          tputs (_rl_term_dc, 1, _rl_output_character_function);
     }
+#endif /* !__MSDOS__ */
 }
 
 void
@@ -2117,7 +2147,7 @@ _rl_current_display_line ()
    scan from the beginning of the string to take the state into account. */
 static int
 _rl_col_width (str, start, end)
-     char *str;
+     const char *str;
      int start, end;
 {
   wchar_t wc;
@@ -2193,4 +2223,3 @@ _rl_col_width (str, start, end)
   return width;
 }
 #endif /* HANDLE_MULTIBYTE */
-         
This page took 0.025695 seconds and 4 git commands to generate.