MdeModulePkg/TerminalDxe: Improve TtyTerm cursor position tracking

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>
This commit is contained in:
Brian J. Johnson 2016-10-07 22:53:58 +08:00 committed by Feng Tian
parent 2d90b74d02
commit 851b044f0a
1 changed files with 25 additions and 0 deletions

View File

@ -2,6 +2,7 @@
Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
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;