From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay2.sgi.com [192.48.180.65]) by ml01.01.org (Postfix) with ESMTP id 12A541A1E05 for ; Fri, 7 Oct 2016 07:54:01 -0700 (PDT) Received: from estes.americas.sgi.com (estes.americas.sgi.com [128.162.236.10]) by relay2.corp.sgi.com (Postfix) with ESMTP id 58BE4304062; Fri, 7 Oct 2016 07:54:00 -0700 (PDT) Received: from pc-bjohnson.americas.sgi.com (pc-bjohnson.americas.sgi.com [128.162.232.243]) by estes.americas.sgi.com (Postfix) with ESMTP id 2DC00969F; Fri, 7 Oct 2016 09:54:00 -0500 (CDT) From: "Brian J. Johnson" To: edk2-devel@lists.01.org Cc: "Brian J. Johnson" , Feng Tian , Star Zeng Date: Fri, 7 Oct 2016 09:53:58 -0500 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH 1/3] MdeModulePkg/TerminalDxe: Improve TtyTerm cursor position tracking X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2016 14:54:01 -0000 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 Cc: Feng Tian Cc: Star Zeng --- .../Universal/Console/TerminalDxe/TerminalConOut.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index 9fa952a..b11e83f 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -2,6 +2,7 @@ Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -313,6 +314,30 @@ TerminalConOutOutputString ( Mode->CursorRow++; } + if (TerminalDevice->TerminalType == TTYTERMTYPE && + !TerminalDevice->OutputEscChar) { + // + // We've written the last character on the line. The + // terminal doesn't actually wrap its cursor until we print + // the next character, but the driver thinks it has wrapped + // already. Print CR LF to synchronize the terminal with + // the driver, but only if we're not in the middle of + // printing an escape sequence. + // + CHAR8 CrLfStr[] = {'\r', '\n'}; + + Length = sizeof(CrLfStr); + + Status = TerminalDevice->SerialIo->Write ( + TerminalDevice->SerialIo, + &Length, + CrLfStr + ); + + if (EFI_ERROR (Status)) { + goto OutputError; + } + } } break; -- 2.7.4