X-Git-Url: https://code.delx.au/refind/blobdiff_plain/2a9f0905f01f51c3f831af471ddfb2cab416e386..e0f6b77e5692ec112bb803202ae27f8c5d55de50:/refind/menu.c diff --git a/refind/menu.c b/refind/menu.c index ba1f78d..5f76da4 100644 --- a/refind/menu.c +++ b/refind/menu.c @@ -526,10 +526,24 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, // prepare strings for display DisplayStrings = AllocatePool(sizeof(CHAR16 *) * Screen->EntryCount); for (i = 0; i <= State->MaxIndex; i++) { - DisplayStrings[i] = AllocateZeroPool(256 * sizeof(CHAR16)); - SPrint(DisplayStrings[i], 255, L" %-.*s ", MenuWidth, Screen->Entries[i]->Title); - // TODO: use more elaborate techniques for shortening too long strings (ellipses in the middle) - // TODO: account for double-width characters + // Note: Theoretically, SPrint() is a cleaner way to do this; but the + // description of the StrSize parameter to SPrint implies it's measured + // in characters, but in practice both TianoCore and GNU-EFI seem to + // use bytes instead, resulting in truncated displays. I could just + // double the size of the StrSize parameter, but that seems unsafe in + // case a future library change starts treating this as characters, so + // I'm doing it the hard way in this instance. + // TODO: Review the above and possibly change other uses of SPrint() + DisplayStrings[i] = AllocateZeroPool(2 * sizeof(CHAR16)); + DisplayStrings[i][0] = L' '; + MergeStrings(&DisplayStrings[i], Screen->Entries[i]->Title, 0); + if (StrLen(DisplayStrings[i]) > MenuWidth) + DisplayStrings[i][MenuWidth - 1] = 0; +// DisplayStrings[i] = AllocateZeroPool(256 * sizeof(CHAR16)); +// SPrint(DisplayStrings[i], ((MenuWidth < 255) ? MenuWidth : 255) * sizeof(CHAR16), +// L" %s ", Screen->Entries[i]->Title); + // TODO: use more elaborate techniques for shortening too long strings (ellipses in the middle) + // TODO: account for double-width characters } // for // initial painting @@ -909,7 +923,7 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT static BOOLEAN EditOptions(LOADER_ENTRY *MenuEntry) { UINTN x_max, y_max; CHAR16 *EditedOptions; - CHAR16 message[] = L"Use cursor keys to edit, Esc to exit, Enter to boot with edited options"; +// CHAR16 message[] = L"Use cursor keys to edit, Esc to exit, Enter to boot with edited options"; EG_PIXEL DarkBackgroundPixel = { 0x0, 0x0, 0x0, 0 }; BOOLEAN retval = FALSE; @@ -921,7 +935,9 @@ static BOOLEAN EditOptions(LOADER_ENTRY *MenuEntry) { egClearScreen(&DarkBackgroundPixel); refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, y_max - 1); - refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, message); +// refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, message); + refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, + L"Use cursor keys to edit, Esc to exit, Enter to boot with edited options"); if (line_edit(MenuEntry->LoadOptions, &EditedOptions, x_max, 1)) { MyFreePool(MenuEntry->LoadOptions);