EmbeddedPkg/SimpleTextInOutSerial: Update the cursor position

It is a UEFI requirement to update the cursor position infomation for each
string displayed using calls to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL->OutputString().



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11728 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-06-03 09:11:55 +00:00
parent e8e95df41d
commit 56226bf769
1 changed files with 60 additions and 2 deletions

View File

@ -517,14 +517,72 @@ OutputString (
IN CHAR16 *String IN CHAR16 *String
) )
{ {
UINTN Size = StrLen(String) + 1; UINTN Size;
CHAR8 *OutputString = AllocatePool(Size); CHAR8* OutputString;
EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
UINTN MaxColumn;
UINTN MaxRow;
Size = StrLen(String) + 1;
OutputString = AllocatePool(Size);
//If there is any non-ascii characters in String buffer then replace it with '?' //If there is any non-ascii characters in String buffer then replace it with '?'
//Eventually, UnicodeStrToAsciiStr API should be fixed. //Eventually, UnicodeStrToAsciiStr API should be fixed.
SafeUnicodeStrToAsciiStr(String, OutputString); SafeUnicodeStrToAsciiStr(String, OutputString);
SerialPortWrite ((UINT8 *)OutputString, Size - 1); SerialPortWrite ((UINT8 *)OutputString, Size - 1);
//
// Parse each character of the string to output
// to update the cursor position information
//
Mode = This->Mode;
Status = This->QueryMode (
This,
Mode->Mode,
&MaxColumn,
&MaxRow
);
if (EFI_ERROR (Status)) {
return Status;
}
for (; *String != CHAR_NULL; String++) {
switch (*String) {
case CHAR_BACKSPACE:
if (Mode->CursorColumn > 0) {
Mode->CursorColumn--;
}
break;
case CHAR_LINEFEED:
if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
Mode->CursorRow++;
}
break;
case CHAR_CARRIAGE_RETURN:
Mode->CursorColumn = 0;
break;
default:
if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {
// Move the cursor as if we print CHAR_CARRIAGE_RETURN & CHAR_LINE_FEED
// CHAR_LINEFEED
if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
Mode->CursorRow++;
}
// CHAR_CARIAGE_RETURN
Mode->CursorColumn = 0;
} else {
Mode->CursorColumn++;
}
break;
}
}
FreePool(OutputString); FreePool(OutputString);
return EFI_SUCCESS; return EFI_SUCCESS;