public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Brian J. Johnson" <bjohnson@sgi.com>
To: edk2-devel@lists.01.org
Cc: "Brian J. Johnson" <bjohnson@sgi.com>,
	Feng Tian <feng.tian@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH 1/3] MdeModulePkg/TerminalDxe: Improve TtyTerm cursor position tracking
Date: Fri,  7 Oct 2016 09:53:58 -0500	[thread overview]
Message-ID: <d7365473bd376be1904780ef43a5553522d71ec5.1475849212.git.bjohnson@sgi.com> (raw)
In-Reply-To: <cover.1475849212.git.bjohnson@sgi.com>
In-Reply-To: <cover.1475849212.git.bjohnson@sgi.com>

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>
---
 .../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.<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;
 
-- 
2.7.4



  reply	other threads:[~2016-10-07 14:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07 14:53 [PATCH 0/3] MdeModulePkg/TerminalDxe: TtyTerm improvements Brian J. Johnson
2016-10-07 14:53 ` Brian J. Johnson [this message]
2016-10-07 14:53 ` [PATCH 2/3] MdeModulePkg/TerminalDxe: Optimize TtyTerm cursor motion Brian J. Johnson
2016-10-27  3:09   ` Kinney, Michael D
2016-10-27  5:06     ` Tian, Feng
2016-10-27 18:06     ` Brian J. Johnson
2016-10-27 18:14       ` Kinney, Michael D
2016-10-27 18:32         ` Kinney, Michael D
2016-10-07 14:54 ` [PATCH 3/3] MdeModulePkg/TerminalDxe: Handle more keys with TtyTerm Brian J. Johnson
2016-10-14 20:53   ` Roy Franz (HPE)
2016-10-07 15:56 ` [PATCH 0/3] MdeModulePkg/TerminalDxe: TtyTerm improvements Laszlo Ersek
2016-10-07 15:59   ` Leif Lindholm
2016-10-12  8:17     ` Ryan Harkin
2016-10-14 19:39       ` Brian J. Johnson
2016-10-14 20:37         ` Laszlo Ersek
2016-10-18 15:34           ` Brian J. Johnson
2016-10-26 15:00             ` Brian J. Johnson
2016-10-27  1:01               ` Tian, Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7365473bd376be1904780ef43a5553522d71ec5.1475849212.git.bjohnson@sgi.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox