]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
MdeModulePkg/TerminalDxe: Improve TtyTerm cursor position tracking
[mirror_edk2.git] / 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