https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f6a2438c1fa92714b94bfa...
commit f6a2438c1fa92714b94bfa394fce70526a663417 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Fri Jan 7 22:47:58 2022 +0100 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Feb 6 17:52:40 2022 +0100
[FREELDR:UI] Cleanup for the DrawText* functions.
- Remove duplicated code from directui.c and use the one from TUI instead, with the latter properly #ifdef'ed for _M_ARM.
- Provide the minimal implementations for NoUiDrawText*(). - TuiDrawText() is just a particular case of TuiDrawText2().
- Isolate the TuiPrintf() and TuiDraw*Text*() functions as separate "Generic TUI utils".
- Fix "TAG_TAG" typo in TAG_TAG_TUI_PALETTE. - Add SAL annotations. --- boot/freeldr/freeldr/include/ui.h | 31 +++- boot/freeldr/freeldr/include/ui/noui.h | 31 +++- boot/freeldr/freeldr/include/ui/tui.h | 40 ++++- boot/freeldr/freeldr/ui/directui.c | 142 +++--------------- boot/freeldr/freeldr/ui/noui.c | 33 ++++- boot/freeldr/freeldr/ui/tui.c | 263 +++++++++++++++++++-------------- boot/freeldr/freeldr/ui/ui.c | 24 ++- 7 files changed, 317 insertions(+), 247 deletions(-)
diff --git a/boot/freeldr/freeldr/include/ui.h b/boot/freeldr/freeldr/include/ui.h index a42622f7d13..8ee46293eed 100644 --- a/boot/freeldr/freeldr/include/ui.h +++ b/boot/freeldr/freeldr/include/ui.h @@ -61,9 +61,34 @@ VOID UiDrawBackdrop(VOID); // Fills the en VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); // Draws a box around the area specified -VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr); // Draws text at coordinates specified -VOID UiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr); // Draws text at coordinates specified -VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges + +/* Draws text at coordinates specified */ +VOID +UiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr); + +/* Draws text at coordinates specified */ +VOID +UiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr); + +/* Draws centered text at the coordinates specified and clips the edges */ +VOID +UiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr); + VOID UiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen VOID UiUpdateDateTime(VOID); // Updates the date and time VOID UiInfoBox(PCSTR MessageText); // Displays a info box on the screen diff --git a/boot/freeldr/freeldr/include/ui/noui.h b/boot/freeldr/freeldr/include/ui/noui.h index 5772c3e3a5d..99b8bfa4ec5 100644 --- a/boot/freeldr/freeldr/include/ui/noui.h +++ b/boot/freeldr/freeldr/include/ui/noui.h @@ -21,9 +21,34 @@ VOID NoUiDrawBackdrop(VOID); VOID NoUiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr); VOID NoUiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); VOID NoUiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); -VOID NoUiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr); -VOID NoUiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr); -VOID NoUiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); + +/* Draws text at coordinates specified */ +VOID +NoUiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr); + +/* Draws text at coordinates specified */ +VOID +NoUiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr); + +/* Draws centered text at the coordinates specified and clips the edges */ +VOID +NoUiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr); + VOID NoUiDrawStatusText(PCSTR StatusText); VOID NoUiUpdateDateTime(VOID); VOID NoUiMessageBox(PCSTR MessageText); diff --git a/boot/freeldr/freeldr/include/ui/tui.h b/boot/freeldr/freeldr/include/ui/tui.h index ccad1e19ca3..729db425572 100644 --- a/boot/freeldr/freeldr/include/ui/tui.h +++ b/boot/freeldr/freeldr/include/ui/tui.h @@ -19,6 +19,13 @@
#pragma once
+/* GENERIC TUI UTILS *********************************************************/ + +INT +TuiPrintf( + _In_ PCSTR Format, ...); + + #define TUI_TITLE_BOX_CHAR_HEIGHT 5
/////////////////////////////////////////////////////////////////////////////////////// @@ -26,6 +33,7 @@ // Textual User Interface Functions // /////////////////////////////////////////////////////////////////////////////////////// + BOOLEAN TuiInitialize(VOID); // Initialize User-Interface VOID TuiUnInitialize(VOID); // Un-initialize User-Interface
@@ -33,9 +41,34 @@ VOID TuiDrawBackdrop(VOID); // Fills the e VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); // Draws a box around the area specified -VOID TuiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr); // Draws text at coordinates specified -VOID TuiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr); // Draws text at coordinates specified -VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges + +/* Draws text at coordinates specified */ +VOID +TuiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr); + +/* Draws text at coordinates specified */ +VOID +TuiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr); + +/* Draws centered text at the coordinates specified and clips the edges */ +VOID +TuiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr); + VOID TuiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen VOID TuiUpdateDateTime(VOID); // Updates the date and time VOID TuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later @@ -45,7 +78,6 @@ VOID TuiMessageBoxCritical(PCSTR MessageText); // Displays a m VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length); -int TuiPrintf(const char *format, ... ); UCHAR TuiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value UCHAR TuiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
diff --git a/boot/freeldr/freeldr/ui/directui.c b/boot/freeldr/freeldr/ui/directui.c index 6771bd498f9..8a132842041 100644 --- a/boot/freeldr/freeldr/ui/directui.c +++ b/boot/freeldr/freeldr/ui/directui.c @@ -5,16 +5,13 @@ * PURPOSE: FreeLDR UI Routines * PROGRAMMERS: ReactOS Portable Systems Group */ -#ifdef _M_ARM
-/* INCLUDES *******************************************************************/ +#ifdef _M_ARM
#include <freeldr.h>
/* GLOBALS ********************************************************************/
-/* FUNCTIONS ******************************************************************/ - ULONG UiScreenWidth; ULONG UiScreenHeight; UCHAR UiMenuFgColor = COLOR_GRAY; @@ -24,28 +21,7 @@ UCHAR UiSelectedTextColor = COLOR_BLACK; UCHAR UiSelectedTextBgColor = COLOR_GRAY; CHAR UiTimeText[260] = "Seconds until highlighted choice will be started automatically: ";
-INT -TuiPrintf(const char *Format, - ...) -{ - int i; - int Length; - va_list ap; - CHAR Buffer[512]; - - va_start(ap, Format); - Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap); - va_end(ap); - - if (Length == -1) Length = sizeof(Buffer); - - for (i = 0; i < Length; i++) - { - MachConsPutChar(Buffer[i]); - } - - return Length; -} +/* FUNCTIONS ******************************************************************/
BOOLEAN UiInitialize(IN BOOLEAN ShowUi) @@ -76,106 +52,36 @@ UiDrawBackdrop(VOID) }
VOID -UiDrawText(IN ULONG X, - IN ULONG Y, - IN PCSTR Text, - IN UCHAR Attr) +UiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr) { - ULONG i, j; - - /* Draw the text character by character, but don't exceed the width */ - for (i = X, j = 0; Text[j] && i < UiScreenWidth; i++, j++) - { - /* Write the character */ - MachVideoPutChar(Text[j], Attr, i, Y); - } + TuiDrawText2(X, Y, 0 /*(ULONG)strlen(Text)*/, Text, Attr); }
VOID -UiDrawText2(IN ULONG X, - IN ULONG Y, - IN ULONG MaxNumChars, - IN PCSTR Text, - IN UCHAR Attr) +UiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr) { - ULONG i, j; - - /* Draw the text character by character, but don't exceed the width */ - for (i = X, j = 0; Text[j] && i < UiScreenWidth && (MaxNumChars > 0 ? j < MaxNumChars : TRUE); i++, j++) - { - /* Write the character */ - MachVideoPutChar(Text[j], Attr, i, Y); - } + TuiDrawText2(X, Y, MaxNumChars, Text, Attr); }
VOID -UiDrawCenteredText(IN ULONG Left, - IN ULONG Top, - IN ULONG Right, - IN ULONG Bottom, - IN PCSTR TextString, - IN UCHAR Attr) +UiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr) { - ULONG TextLength, BoxWidth, BoxHeight, LineBreakCount, Index, LastIndex; - ULONG RealLeft, RealTop, X, Y; - CHAR Temp[2]; - - /* Query text length */ - TextLength = strlen(TextString); - - /* Count the new lines and the box width */ - LineBreakCount = 0; - BoxWidth = 0; - LastIndex = 0; - for (Index=0; Index < TextLength; Index++) - { - /* Scan for new lines */ - if (TextString[Index] == '\n') - { - /* Remember the new line */ - LastIndex = Index; - LineBreakCount++; - } - else - { - /* Check for new larger box width */ - if ((Index - LastIndex) > BoxWidth) - { - /* Update it */ - BoxWidth = (Index - LastIndex); - } - } - } - - /* Base the box height on the number of lines */ - BoxHeight = LineBreakCount + 1; - - /* Create the centered coordinates */ - RealLeft = (((Right - Left) - BoxWidth) / 2) + Left; - RealTop = (((Bottom - Top) - BoxHeight) / 2) + Top; - - /* Now go for a second scan */ - LastIndex = 0; - for (Index=0; Index < TextLength; Index++) - { - /* Look for new lines again */ - if (TextString[Index] == '\n') - { - /* Update where the text should start */ - RealTop++; - LastIndex = 0; - } - else - { - /* We've got a line of text to print, do it */ - X = RealLeft + LastIndex; - Y = RealTop; - LastIndex++; - Temp[0] = TextString[Index]; - Temp[1] = 0; - UiDrawText(X, Y, Temp, Attr); - } - } + TuiDrawCenteredText(Left, Top, Right, Bottom, TextString, Attr); }
VOID @@ -659,4 +565,4 @@ UiDisplayMenu( return TRUE; }
-#endif +#endif // _M_ARM diff --git a/boot/freeldr/freeldr/ui/noui.c b/boot/freeldr/freeldr/ui/noui.c index da5d482f750..1cbb42d40e9 100644 --- a/boot/freeldr/freeldr/ui/noui.c +++ b/boot/freeldr/freeldr/ui/noui.c @@ -5,6 +5,7 @@ * PURPOSE: No Text UI interface * PROGRAMMERS: Hervé Poussineau */ + #ifndef _M_ARM #include <freeldr.h>
@@ -33,16 +34,39 @@ VOID NoUiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertSty { }
-VOID NoUiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) +VOID +NoUiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr) { + printf("%s\n", Text); }
-VOID NoUiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr) +VOID +NoUiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr) { + if (MaxNumChars == 0) + MaxNumChars = (ULONG)strlen(Text); + printf("%*s\n", MaxNumChars, Text); }
-VOID NoUiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) +VOID +NoUiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr) { + printf("%s\n", TextString); }
VOID NoUiDrawStatusText(PCSTR StatusText) @@ -134,4 +158,5 @@ NoUiDisplayMenu( VOID NoUiDrawMenu(PUI_MENU_INFO MenuInfo) { } -#endif + +#endif // _M_ARM diff --git a/boot/freeldr/freeldr/ui/tui.c b/boot/freeldr/freeldr/ui/tui.c index f7a8e76a11f..b985989e699 100644 --- a/boot/freeldr/freeldr/ui/tui.c +++ b/boot/freeldr/freeldr/ui/tui.c @@ -16,23 +16,25 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _M_ARM -#include <freeldr.h>
-#define TAG_TUI_SCREENBUFFER 'SiuT' -#define TAG_TAG_TUI_PALETTE 'PiuT' +#include <freeldr.h>
+#ifndef _M_ARM PVOID TextVideoBuffer = NULL; -extern UCHAR MachDefaultTextColor; +#endif + +/* GENERIC TUI UTILS *********************************************************/
/* * TuiPrintf() - * Prints formatted text to the screen + * Prints formatted text to the screen. */ -int TuiPrintf(const char *Format, ...) +INT +TuiPrintf( + _In_ PCSTR Format, ...) { - int i; - int Length; + INT i; + INT Length; va_list ap; CHAR Buffer[512];
@@ -40,7 +42,8 @@ int TuiPrintf(const char *Format, ...) Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap); va_end(ap);
- if (Length == -1) Length = sizeof(Buffer); + if (Length == -1) + Length = (INT)sizeof(Buffer);
for (i = 0; i < Length; i++) { @@ -50,6 +53,138 @@ int TuiPrintf(const char *Format, ...) return Length; }
+/* + * DrawText() + * Displays a string on a single screen line. + * This function assumes coordinates are zero-based. + */ +VOID +TuiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr) +{ + TuiDrawText2(X, Y, 0 /*(ULONG)strlen(Text)*/, Text, Attr); +} + +/* + * DrawText2() + * Displays a string on a single screen line. + * This function assumes coordinates are zero-based. + * MaxNumChars is the maximum number of characters to display. + * If MaxNumChars == 0, then display the whole string. + */ +VOID +TuiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr) +{ +#ifndef _M_ARM + PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer; +#endif + ULONG i, j; + + /* Draw the text, not exceeding the width */ + for (i = X, j = 0; Text[j] && i < UiScreenWidth && (MaxNumChars > 0 ? j < MaxNumChars : TRUE); i++, j++) + { +#ifndef _M_ARM + ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)] = (UCHAR)Text[j]; + ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)+1] = Attr; +#else + /* Write the character */ + MachVideoPutChar(Text[j], Attr, i, Y); +#endif + } +} + +VOID +TuiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr) +{ + SIZE_T TextLength; + SIZE_T Index, LastIndex; + ULONG LineBreakCount; + ULONG BoxWidth, BoxHeight; + ULONG RealLeft, RealTop; + ULONG X, Y; + CHAR Temp[2]; + + /* Query text length */ + TextLength = strlen(TextString); + + /* Count the new lines and the box width */ + LineBreakCount = 0; + BoxWidth = 0; + LastIndex = 0; + for (Index = 0; Index < TextLength; Index++) + { + /* Scan for new lines */ + if (TextString[Index] == '\n') + { + /* Remember the new line */ + LastIndex = Index; + LineBreakCount++; + } + else + { + /* Check for new larger box width */ + if ((Index - LastIndex) > BoxWidth) + { + /* Update it */ + BoxWidth = (ULONG)(Index - LastIndex); + } + } + } + + /* Base the box height on the number of lines */ + BoxHeight = LineBreakCount + 1; + + /* Create the centered coordinates */ + RealLeft = (((Right - Left) - BoxWidth) / 2) + Left; + RealTop = (((Bottom - Top) - BoxHeight) / 2) + Top; + + /* Now go for a second scan */ + LastIndex = 0; + for (Index = 0; Index < TextLength; Index++) + { + /* Look for new lines again */ + if (TextString[Index] == '\n') + { + /* Update where the text should start */ + RealTop++; + LastIndex = 0; + } + else + { + /* We've got a line of text to print, do it */ + X = (ULONG)(RealLeft + LastIndex); + Y = RealTop; + LastIndex++; + Temp[0] = TextString[Index]; + Temp[1] = 0; + TuiDrawText(X, Y, Temp, Attr); + } + } +} + +/* FULL TUI THEME ************************************************************/ + +#ifndef _M_ARM + +#define TAG_TUI_SCREENBUFFER 'SiuT' +#define TAG_TUI_PALETTE 'PiuT' + +extern UCHAR MachDefaultTextColor; + BOOLEAN TuiInitialize(VOID) { MachVideoHideShowTextCursor(FALSE); @@ -305,103 +440,6 @@ VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyl } }
-/* - * DrawText() - * This function assumes coordinates are zero-based - */ -VOID TuiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) -{ - PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer; - ULONG i, j; - - // Draw the text - for (i = X, j = 0; Text[j] && i < UiScreenWidth; i++, j++) - { - ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)] = (UCHAR)Text[j]; - ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)+1] = Attr; - } -} - -/* - * DrawText2() - * This function assumes coordinates are zero-based. - * MaxNumChars is the maximum number of characters to display. - * If MaxNumChars == 0, then display the whole string. - */ -VOID TuiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr) -{ - PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer; - ULONG i, j; - - // Draw the text - for (i = X, j = 0; Text[j] && i < UiScreenWidth && (MaxNumChars > 0 ? j < MaxNumChars : TRUE); i++, j++) - { - ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)] = (UCHAR)Text[j]; - ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)+1] = Attr; - } -} - -VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) -{ - SIZE_T TextLength; - ULONG BoxWidth; - ULONG BoxHeight; - ULONG LineBreakCount; - SIZE_T Index; - SIZE_T LastIndex; - ULONG RealLeft; - ULONG RealTop; - ULONG X; - ULONG Y; - CHAR Temp[2]; - - TextLength = strlen(TextString); - - // Count the new lines and the box width - LineBreakCount = 0; - BoxWidth = 0; - LastIndex = 0; - for (Index=0; Index<TextLength; Index++) - { - if (TextString[Index] == '\n') - { - LastIndex = Index; - LineBreakCount++; - } - else - { - if ((Index - LastIndex) > BoxWidth) - { - BoxWidth = (ULONG)(Index - LastIndex); - } - } - } - - BoxHeight = LineBreakCount + 1; - - RealLeft = (((Right - Left) - BoxWidth) / 2) + Left; - RealTop = (((Bottom - Top) - BoxHeight) / 2) + Top; - - LastIndex = 0; - for (Index=0; Index<TextLength; Index++) - { - if (TextString[Index] == '\n') - { - RealTop++; - LastIndex = 0; - } - else - { - X = (ULONG)(RealLeft + LastIndex); - Y = RealTop; - LastIndex++; - Temp[0] = TextString[Index]; - Temp[1] = 0; - TuiDrawText(X, Y, Temp, Attr); - } - } -} - VOID TuiDrawStatusText(PCSTR StatusText) { SIZE_T i; @@ -755,7 +793,7 @@ VOID TuiFadeInBackdrop(VOID) if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed()) { TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64, - TAG_TAG_TUI_PALETTE); + TAG_TUI_PALETTE);
if (TuiFadePalette != NULL) { @@ -770,7 +808,7 @@ VOID TuiFadeInBackdrop(VOID) if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL) { VideoFadeIn(TuiFadePalette, 64); - FrLdrTempFree(TuiFadePalette, TAG_TAG_TUI_PALETTE); + FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE); } }
@@ -781,7 +819,7 @@ VOID TuiFadeOut(VOID) if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed()) { TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64, - TAG_TAG_TUI_PALETTE); + TAG_TUI_PALETTE);
if (TuiFadePalette != NULL) { @@ -799,7 +837,7 @@ VOID TuiFadeOut(VOID) if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL) { VideoRestorePaletteState(TuiFadePalette, 64); - FrLdrTempFree(TuiFadePalette, TAG_TAG_TUI_PALETTE); + FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE); }
} @@ -1062,4 +1100,5 @@ const UIVTBL TuiVtbl = TuiDisplayMenu, TuiDrawMenu, }; -#endif + +#endif // _M_ARM diff --git a/boot/freeldr/freeldr/ui/ui.c b/boot/freeldr/freeldr/ui/ui.c index 481f0983e54..de1d959d05a 100644 --- a/boot/freeldr/freeldr/ui/ui.c +++ b/boot/freeldr/freeldr/ui/ui.c @@ -239,17 +239,35 @@ VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle UiVtbl.DrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr); }
-VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) +VOID +UiDrawText( + _In_ ULONG X, + _In_ ULONG Y, + _In_ PCSTR Text, + _In_ UCHAR Attr) { UiVtbl.DrawText(X, Y, Text, Attr); }
-VOID UiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr) +VOID +UiDrawText2( + _In_ ULONG X, + _In_ ULONG Y, + _In_opt_ ULONG MaxNumChars, + _In_reads_or_z_(MaxNumChars) PCSTR Text, + _In_ UCHAR Attr) { UiVtbl.DrawText2(X, Y, MaxNumChars, Text, Attr); }
-VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) +VOID +UiDrawCenteredText( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ PCSTR TextString, + _In_ UCHAR Attr) { UiVtbl.DrawCenteredText(Left, Top, Right, Bottom, TextString, Attr); }