/** @file\r
The application to show the Boot Manager Menu.\r
\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
IN CHAR16 *String\r
)\r
{\r
+ UINTN ScreenWidth;\r
+ UINTN ScreenRows;\r
+ CHAR16 *TurncateString;\r
+ EFI_STATUS Status;\r
+ UINTN ShowingLength;\r
\r
gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);\r
- return Print (L"%s", String);\r
+\r
+ gST->ConOut->QueryMode (\r
+ gST->ConOut,\r
+ gST->ConOut->Mode->Mode,\r
+ &ScreenWidth,\r
+ &ScreenRows\r
+ );\r
+\r
+ if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) {\r
+ return 0;\r
+ }\r
+\r
+ if ((StrLen (String) + Column) > (ScreenWidth - 1)) {\r
+ //\r
+ // | - ScreenWidth - |\r
+ // ...Column.....................\r
+ // TurncateString length should leave one character for draw box and\r
+ // require one character for string end.\r
+ //\r
+ ShowingLength = ScreenWidth - Column - 1;\r
+ TurncateString = AllocatePool ((ShowingLength + 1) * sizeof (CHAR16));\r
+\r
+ if (TurncateString == NULL) {\r
+ return 0;\r
+ }\r
+\r
+ Status = StrnCpyS (TurncateString, ShowingLength + 1, String, ShowingLength - 3);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (TurncateString);\r
+ return 0;\r
+ }\r
+\r
+ *(TurncateString + ShowingLength - 3) = L'.';\r
+ *(TurncateString + ShowingLength - 2) = L'.';\r
+ *(TurncateString + ShowingLength - 1) = L'.';\r
+ *(TurncateString + ShowingLength) = L'\0';\r
+ ShowingLength = Print (L"%s", TurncateString);\r
+ FreePool (TurncateString);\r
+ return ShowingLength;\r
+ } else {\r
+ return Print (L"%s", String);\r
+ }\r
}\r
\r
/**\r
CHAR16 Character\r
)\r
{\r
+ UINTN ScreenWidth;\r
+ UINTN ScreenRows;\r
+\r
gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);\r
+\r
+ gST->ConOut->QueryMode (\r
+ gST->ConOut,\r
+ gST->ConOut->Mode->Mode,\r
+ &ScreenWidth,\r
+ &ScreenRows\r
+ );\r
+\r
+ if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) {\r
+ return 0;\r
+ }\r
+\r
return Print (L"%c", Character);\r
}\r
\r
\r
MaxPrintRows = Row - 6;\r
UnSelectableItmes = TITLE_TOKEN_COUNT + 2 + HELP_TOKEN_COUNT + 2;\r
- BootMenuData->MenuScreen.Width = MaxStrWidth + 8;\r
+ if (MaxStrWidth + 8 > Column) {\r
+ BootMenuData->MenuScreen.Width = Column;\r
+ } else {\r
+ BootMenuData->MenuScreen.Width = MaxStrWidth + 8;\r
+ }\r
if (BootMenuData->ItemCount + UnSelectableItmes > MaxPrintRows) {\r
BootMenuData->MenuScreen.Height = MaxPrintRows;\r
BootMenuData->ScrollBarControl.HasScrollBar = TRUE;\r