From c2d40e30115a79df73cac4e7c09969d26c3c6433 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sun, 17 Dec 2023 23:45:01 +0100 Subject: [PATCH] Do not print caption, nor message on the dialog box if not needed --- xtldr2/textui.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/xtldr2/textui.c b/xtldr2/textui.c index 1db83db..7fbf35d 100644 --- a/xtldr2/textui.c +++ b/xtldr2/textui.c @@ -341,16 +341,13 @@ BlpDrawDialogBox(IN OUT PXTBL_DIALOG_HANDLE Handle, Handle->DialogColor = EFI_TEXT_BGCOLOR_RED; Handle->TextColor = EFI_TEXT_FGCOLOR_WHITE; } - else + else if(Handle->Attributes & XTBL_TUI_DIALOG_GENERIC_BOX) { /* Generic dialog with blue background and cyan button */ Handle->DialogColor = EFI_TEXT_BGCOLOR_BLUE; Handle->TextColor = EFI_TEXT_FGCOLOR_WHITE; } - /* Get caption length */ - CaptionLength = RtlWideStringLength(Caption, 0); - /* Set dialog box colors */ BlSetConsoleAttributes(Handle->DialogColor | 0x0F); @@ -365,16 +362,30 @@ BlpDrawDialogBox(IN OUT PXTBL_DIALOG_HANDLE Handle, { /* Draw top line of the dialog box, starting from the left corner */ BoxLine[0] = EFI_TEXT_BOX_DOWN_RIGHT; - BoxLine[1] = EFI_TEXT_BOX_VERTICAL_LEFT; - /* Fill caption area with spaces */ - for(PosX = 2; PosX < CaptionLength + 4; PosX++) + /* Check if there is a caption for this dialog */ + if(Caption != NULL) { - BoxLine[PosX] = ' '; - } + /* Get caption length */ + CaptionLength = RtlWideStringLength(Caption, 0); - /* End caption area with vertical line */ - BoxLine[CaptionLength + 4] = EFI_TEXT_BOX_VERTICAL_RIGHT; + /* Start caption area with vertical line */ + BoxLine[1] = EFI_TEXT_BOX_VERTICAL_LEFT; + + /* Fill caption area with spaces */ + for(PosX = 2; PosX < CaptionLength + 4; PosX++) + { + BoxLine[PosX] = ' '; + } + + /* End caption area with vertical line */ + BoxLine[CaptionLength + 4] = EFI_TEXT_BOX_VERTICAL_RIGHT; + } + else + { + /* No caption, -4 because of left and right vertical lines and corresponding spaces */ + CaptionLength = -4; + } /* Draw bottom line */ for(PosX = CaptionLength + 5; PosX < Handle->Width - 1; PosX++) @@ -421,12 +432,20 @@ BlpDrawDialogBox(IN OUT PXTBL_DIALOG_HANDLE Handle, BlConsoleWrite(BoxLine); } + /* Make sure there is a caption to print */ + if(Caption != NULL) + { /* Write dialog box caption */ - BlSetCursorPosition(Handle->PosX + 3, Handle->PosY); - BlConsolePrint(L"%S", Caption); + BlSetCursorPosition(Handle->PosX + 3, Handle->PosY); + BlConsolePrint(L"%S", Caption); + } - /* Write a message on the dialog box */ - BlpDrawDialogMessage(Handle, Message); + /* Make sure there is a message to print */ + if(Message != NULL) + { + /* Write a message on the dialog box */ + BlpDrawDialogMessage(Handle, Message); + } } /**