#include "screen.h"
#include "config.h"
#include "libegint.h"
+#include "lib.h"
#include "../include/refit_call_wrapper.h"
#include "../include/egemb_refind_banner.h"
UINTN ConWidth;
UINTN ConHeight;
-CHAR16 *BlankLine;
+CHAR16 *BlankLine = NULL;
static VOID DrawScreenHeader(IN CHAR16 *Title);
static BOOLEAN haveError = FALSE;
+static VOID PrepareBlankLine(VOID) {
+ UINTN i;
+
+ MyFreePool(BlankLine);
+ // make a buffer for a whole text line
+ BlankLine = AllocatePool((ConWidth + 1) * sizeof(CHAR16));
+ for (i = 0; i < ConWidth; i++)
+ BlankLine[i] = ' ';
+ BlankLine[i] = 0;
+}
+
//
// Screen initialization and switching
//
VOID InitScreen(VOID)
{
- UINTN i;
-
// initialize libeg
egInitScreen();
ConHeight = 25;
}
- // make a buffer for a whole text line
- BlankLine = AllocatePool((ConWidth + 1) * sizeof(CHAR16));
- for (i = 0; i < ConWidth; i++)
- BlankLine[i] = ' ';
- BlankLine[i] = 0;
+ PrepareBlankLine();
// show the banner (even when in graphics mode)
DrawScreenHeader(L"Initializing...");
VOID SetupScreen(VOID)
{
+ GlobalConfig.RequestedTextMode = egSetTextMode(GlobalConfig.RequestedTextMode);
+
+ if ((GlobalConfig.RequestedScreenWidth > 0) && (GlobalConfig.RequestedScreenHeight > 0) &&
+ egSetScreenSize(GlobalConfig.RequestedScreenWidth, GlobalConfig.RequestedScreenHeight)) {
+ UGAWidth = GlobalConfig.RequestedScreenWidth;
+ UGAHeight = GlobalConfig.RequestedScreenHeight;
+ } // if user requested a particular screen resolution
+
if (GlobalConfig.TextOnly) {
// switch to text mode if requested
AllowGraphicsMode = FALSE;
} else if (AllowGraphicsMode) {
// clear screen and show banner
// (now we know we'll stay in graphics mode)
- if ((GlobalConfig.RequestedScreenWidth > 0) && (GlobalConfig.RequestedScreenHeight > 0) &&
- egSetScreenSize(GlobalConfig.RequestedScreenWidth, GlobalConfig.RequestedScreenHeight)) {
- UGAWidth = GlobalConfig.RequestedScreenWidth;
- UGAHeight = GlobalConfig.RequestedScreenHeight;
- } // if user requested a particular screen resolution
SwitchToGraphics();
BltClearScreen(TRUE);
}
{
egSetGraphicsModeEnabled(FALSE);
refit_call2_wrapper(ST->ConOut->EnableCursor, ST->ConOut, CursorEnabled);
+ // get size of text console
+ if (refit_call4_wrapper(ST->ConOut->QueryMode, ST->ConOut, ST->ConOut->Mode->Mode, &ConWidth, &ConHeight) != EFI_SUCCESS) {
+ // use default values on error
+ ConWidth = 80;
+ ConHeight = 25;
+ }
+ PrepareBlankLine();
}
VOID SwitchToGraphics(VOID)
VOID FinishTextScreen(IN BOOLEAN WaitAlways)
{
if (haveError || WaitAlways) {
- SwitchToText(FALSE);
- PauseForKey();
+ PauseForKey();
+ SwitchToText(FALSE);
}
// reset error flag
(*first)++;
}
-BOOLEAN line_edit(CHAR16 *line_in, CHAR16 **line_out, UINTN x_max, UINTN y_pos) {
+BOOLEAN line_edit(CHAR16 *line_in, CHAR16 **line_out, UINTN x_max) {
CHAR16 *line;
UINTN size;
UINTN len;
UINTN first;
+ UINTN y_pos = 3;
CHAR16 *print;
UINTN cursor;
BOOLEAN exit;
BOOLEAN enter;
+ DrawScreenHeader(L"Line Editor");
+ refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, (ConWidth - 71) / 2, ConHeight - 1);
+ 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_in)
line_in = L"";
size = StrLen(line_in) + 1024;