a5bd9f6
From 105030380129f8c17035ac88980eaa4c151ee521 Mon Sep 17 00:00:00 2001
a5bd9f6
From: Andrey Borzenkov  <arvidjaar@gmail.com>
a5bd9f6
Date: Mon, 8 Apr 2013 19:51:33 +0200
a5bd9f6
Subject: [PATCH 272/364] 	* grub-core/term/i386/pc/console.c: Fix cursor
a5bd9f6
 moving algorithm.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog                        |  4 ++++
a5bd9f6
 grub-core/term/i386/pc/console.c | 24 +++++++++---------------
a5bd9f6
 2 files changed, 13 insertions(+), 15 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index 3a241c0..9e08bea 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,7 @@
a5bd9f6
+2013-04-08  Andrey Borzenkov <arvidjaar@gmail.com>
a5bd9f6
+
a5bd9f6
+	* grub-core/term/i386/pc/console.c: Fix cursor moving algorithm.
a5bd9f6
+
a5bd9f6
 2013-04-08  Bryan Hundven <bryanhundven@gmail.com>
a5bd9f6
 
a5bd9f6
 	* docs/grub-dev.texi: Move @itemize after @subsection to satisfy
a5bd9f6
diff --git a/grub-core/term/i386/pc/console.c b/grub-core/term/i386/pc/console.c
a5bd9f6
index ee6650b..358611a 100644
a5bd9f6
--- a/grub-core/term/i386/pc/console.c
a5bd9f6
+++ b/grub-core/term/i386/pc/console.c
a5bd9f6
@@ -86,13 +86,9 @@ grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
a5bd9f6
  * Put the character C on the console. Because GRUB wants to write a
a5bd9f6
  * character with an attribute, this implementation is a bit tricky.
a5bd9f6
  * If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh
a5bd9f6
- * (TELETYPE OUTPUT). Otherwise, save the original position, put a space,
a5bd9f6
- * save the current position, restore the original position, write the
a5bd9f6
- * character and the attribute, and restore the current position.
a5bd9f6
- *
a5bd9f6
- * The reason why this is so complicated is that there is no easy way to
a5bd9f6
- * get the height of the screen, and the TELETYPE OUTPUT BIOS call doesn't
a5bd9f6
- * support setting a background attribute.
a5bd9f6
+ * (TELETYPE OUTPUT). Otherwise, use INT 10, AH = 9 to write character
a5bd9f6
+ * with attributes and advance cursor. If we are on the last column,
a5bd9f6
+ * let BIOS to wrap line correctly.
a5bd9f6
  */
a5bd9f6
 static void
a5bd9f6
 grub_console_putchar_real (grub_uint8_t c)
a5bd9f6
@@ -112,19 +108,18 @@ grub_console_putchar_real (grub_uint8_t c)
a5bd9f6
   /* get the current position */
a5bd9f6
   pos = grub_console_getxy (NULL);
a5bd9f6
   
a5bd9f6
+  /* write the character with the attribute */
a5bd9f6
+  int10_9 (c, 1);
a5bd9f6
+
a5bd9f6
   /* check the column with the width */
a5bd9f6
   if ((pos & 0xff00) >= (79 << 8))
a5bd9f6
     {
a5bd9f6
       grub_console_putchar_real (0x0d);
a5bd9f6
       grub_console_putchar_real (0x0a);
a5bd9f6
-      /* get the current position */
a5bd9f6
-      pos = grub_console_getxy (NULL);
a5bd9f6
     }
a5bd9f6
+  else
a5bd9f6
+    grub_console_gotoxy (NULL, ((pos & 0xff00) >> 8) + 1, (pos & 0xff));
a5bd9f6
 
a5bd9f6
-  /* write the character with the attribute */
a5bd9f6
-  int10_9 (c, 1);
a5bd9f6
-
a5bd9f6
-  grub_console_gotoxy (NULL, ((pos & 0xff00) >> 8) + 1, (pos & 0xff));
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static void
a5bd9f6
@@ -255,8 +250,7 @@ grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused))
a5bd9f6
 static grub_uint16_t
a5bd9f6
 grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
-  /* Due to current cursor moving algorithm we lost the last column.  */
a5bd9f6
-  return (79 << 8) | 25;
a5bd9f6
+  return (80 << 8) | 25;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static void
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6