bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

/sbin/grub problems with NON-curses setups


From: Klaus Reichl
Subject: /sbin/grub problems with NON-curses setups
Date: Fri, 18 Jan 2002 00:48:17 +0100

Hi all,

The output of /sbin/grub with NON-curses setups (! HAVE_LIBCURSES,
--no-curses, and last but not least and most important --batch) is
ugly. 

Echoes of commands are always far right on the terminal, because of
sending far to many BS SPACE combinations unconditionally (they
are OK for non-dumb terminals but counter-productive for NON-CURSES
mode of operation).

Here is a patch helping /sbin/grub on that and optimizing the dumb
terminal behavior wrt. superfluous BS SPACE sent.

If you agree, I'll check it in.

KR
--
                                        email: address@hidden 
Klaus Reichl                                   address@hidden
Danhausergasse 8/16                     voice: +43 (1) 27722 / 3884 (job)    
A-1040 Wien                                    +43 (1)    94 137 94 (private)
                                               +43 (6991) 94 137 94 (mobile)
 
Testcases:  
/sbin/grub:     Use --batch and watch a typical '< commands' szenario.
TERMINAL_DUMB:  Use `emacs' shell mode and count superfluous BS SPACE
                sequences. 

Here's the fix:

cvs diff -u ChangeLog grub/main.c stage2/char_io.c 
Index: ChangeLog
===================================================================
RCS file: /cvsroot/grub/grub/ChangeLog,v
retrieving revision 1.463
diff -u -r1.463 ChangeLog
--- ChangeLog   15 Jan 2002 10:32:21 -0000      1.463
+++ ChangeLog   17 Jan 2002 23:13:46 -0000
@@ -11,6 +11,16 @@
 
        * docs/grub.texi: Added some text about JFS and XFS.
 
+2002-01-09  Klaus Reichl  <address@hidden>
+
+       * stage2/char_io.c (get_cmdline, cl_refresh): If TERMINAL_DUMB
+       section is always 0.
+       Line is only cleared if !TERMINAL_DUMB.
+
+       * grub/main.c (use_curses): Initialize to 0 if !HAVE_LIBCURSES
+       (main): Check for curses use and set terminal to dumb if we don't
+       use it (helps for --batch and variants of non-curses setup).
+
 2002-01-08  Yoshinori K. Okuji  <address@hidden>
 
        * grub/main.c (use_preset_menu): New variable.
Index: grub/main.c
===================================================================
RCS file: /cvsroot/grub/grub/grub/main.c,v
retrieving revision 1.20
diff -u -r1.20 main.c
--- grub/main.c 8 Jan 2002 03:19:23 -0000       1.20
+++ grub/main.c 17 Jan 2002 23:13:46 -0000
@@ -35,7 +35,11 @@
 char *program_name = 0;
 int use_config_file = 1;
 int use_preset_menu = 0;
+#ifdef HAVE_LIBCURSES
 int use_curses = 1;
+#else
+int use_curses = 0;
+#endif
 int verbose = 0;
 int read_only = 0;
 int floppy_disks = 1;
@@ -241,6 +245,11 @@
       
       sleep (1);
     }
+
+  /* If we don't have curses (!HAVE_LIBCURSES or --no-curses or
+     --batch) put terminal to dumb for better handling of line i/o */
+  if (!use_curses)
+    terminal |= TERMINAL_DUMB;
 
   /* Transfer control to the stage2 simulator. */
   exit (grub_stage2 ());
Index: stage2/char_io.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/char_io.c,v
retrieving revision 1.43
diff -u -r1.43 char_io.c
--- stage2/char_io.c    30 Dec 2001 07:33:23 -0000      1.43
+++ stage2/char_io.c    17 Jan 2002 23:13:54 -0000
@@ -385,7 +385,8 @@
       if (full)
        {
          /* Recompute the section number.  */
-         if (lpos + plen < CMDLINE_WIDTH)
+         if ((terminal & TERMINAL_DUMB)
+             || (lpos + plen < CMDLINE_WIDTH))
            section = 0;
          else
            section = ((lpos + plen - CMDLINE_WIDTH)
@@ -448,48 +449,51 @@
 
          pos++;
        }
-
-      /* Fill up the rest of the line with spaces.  */
-      for (; i < start + len; i++)
-       {
-         grub_putchar (' ');
-         pos++;
-       }
-
-      /* If the cursor is at the last position, put `>' or a space,
-        depending on if there are more characters in BUF.  */
-      if (pos == CMDLINE_WIDTH)
+      
+      if (! (terminal & TERMINAL_DUMB))
        {
-         if (start + len < llen)
-           grub_putchar ('>');
-         else
-           grub_putchar (' ');
+         /* Fill up the rest of the line with spaces.  */
+         for (; i < start + len; i++)
+           {
+             grub_putchar (' ');
+             pos++;
+           }
          
-         pos++;
-       }
-
-      /* Back to XPOS.  */
-      if ((terminal & TERMINAL_CONSOLE)
+         /* If the cursor is at the last position, put `>' or a space,
+            depending on if there are more characters in BUF.  */
+         if (pos == CMDLINE_WIDTH)
+           {
+             if (start + len < llen)
+               grub_putchar ('>');
+             else
+               grub_putchar (' ');
+             
+             pos++;
+           }
+         
+         /* Back to XPOS.  */
+         if ((terminal & TERMINAL_CONSOLE)
 # ifdef SUPPORT_HERCULES
-         || (terminal & TERMINAL_HERCULES)
+             || (terminal & TERMINAL_HERCULES)
 # endif /* SUPPORT_HERCULES */
-         )
-       {
-         int y = getxy () & 0xFF;
-         
-         gotoxy (xpos, y);
-       }
+             )
+           {
+             int y = getxy () & 0xFF;
+             
+             gotoxy (xpos, y);
+           }
 # ifdef SUPPORT_SERIAL      
-      else if (! (terminal & TERMINAL_SERIAL) && (pos - xpos > 4))
-       {
-         grub_printf ("\e[%dD", pos - xpos);
-       }
-      else
-       {
-         for (i = 0; i < pos - xpos; i++)
-           grub_putchar ('\b');
-       }
+         else if (! (terminal & TERMINAL_SERIAL) && (pos - xpos > 4))
+           {
+             grub_printf ("\e[%dD", pos - xpos);
+           }
+         else
+           {
+             for (i = 0; i < pos - xpos; i++)
+               grub_putchar ('\b');
+           }
 # endif /* SUPPORT_SERIAL */
+       }
     }
 
   /* Initialize the command-line.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]