]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/TerminalDxe: Improve TtyTerm cursor position tracking
authorBrian J. Johnson <bjohnson@sgi.com>
Fri, 7 Oct 2016 14:53:58 +0000 (22:53 +0800)
committerFeng Tian <feng.tian@intel.com>
Thu, 27 Oct 2016 01:11:14 +0000 (09:11 +0800)
When we print the last character on a line, the terminal driver wraps
CursorRow/CursorColumn to the beginning of the next line.  But the
terminal itself doesn't wrap its cursor until the next character is
printed.  That throws off the driver's cursor position tracking.

So when we have printed the last character on a line, and are not in
the middle of outputing an escape sequence, synchronize the terminal
with the driver by outputing CR+LF.  This matches the expected
behavior, and the behavior of the VGA console driver.

Only change the behavior of TtyTerm, not the other terminal types.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brian Johnson <bjohnson@sgi.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Tested-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c

index 9fa952ad2a32808adc3088adf8e82dc2a441867d..b11e83f4f24a648ac3015f4f87a21a2c8806a44b 100644 (file)
@@ -2,6 +2,7 @@
   Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.\r
 \r
 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -313,6 +314,30 @@ TerminalConOutOutputString (
           Mode->CursorRow++;\r
         }\r
 \r
+        if (TerminalDevice->TerminalType == TTYTERMTYPE &&\r
+            !TerminalDevice->OutputEscChar) {\r
+          //\r
+          // We've written the last character on the line.  The\r
+          // terminal doesn't actually wrap its cursor until we print\r
+          // the next character, but the driver thinks it has wrapped\r
+          // already.  Print CR LF to synchronize the terminal with\r
+          // the driver, but only if we're not in the middle of\r
+          // printing an escape sequence.\r
+          //\r
+          CHAR8 CrLfStr[] = {'\r', '\n'};\r
+\r
+          Length = sizeof(CrLfStr);\r
+\r
+          Status = TerminalDevice->SerialIo->Write (\r
+                                                TerminalDevice->SerialIo,\r
+                                                &Length,\r
+                                                CrLfStr\r
+                                                );\r
+\r
+          if (EFI_ERROR (Status)) {\r
+            goto OutputError;\r
+          }\r
+        }\r
       }\r
       break;\r
 \r