/** Refresh function for the menu bar. @param[in] LastRow The last printable row. @param[in] LastCol The last printable column. @retval EFI_SUCCESS The refresh was successful. **/ EFI_STATUS EFIAPI MenuBarRefresh ( IN CONST UINTN LastRow, IN CONST UINTN LastCol ) { EDITOR_MENU_ITEM *Item; UINTN Col; UINTN Row; UINTN Width; CHAR16 *NameString; CHAR16 *FunctionKeyString; // // variable initialization // Col = 1; Row = (LastRow - 2); // // clear menu bar rows // EditorClearLine (LastRow - 2, LastCol, LastRow); EditorClearLine (LastRow - 1, LastCol, LastRow); EditorClearLine (LastRow , LastCol, LastRow); // // print out the menu items // for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) { NameString = HiiGetString(gShellDebug1HiiHandle, Item->NameToken, NULL); Width = MAX ((StrLen (NameString) + 6), 20); if (((Col + Width) > LastCol)) { Row++; Col = 1; } FunctionKeyString = HiiGetString(gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL); ShellPrintEx ((INT32)(Col) - 1, (INT32)(Row) - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString); FreePool (NameString); FreePool (FunctionKeyString); Col += Width; } return EFI_SUCCESS; }
// // Name: // MainInputHide -- Clear input bar and restore file buffer cursor position // In: // VOID // Out: // EFI_SUCCESS // EFI_STATUS MainInputBarHide ( VOID ) { // // Clear the input bar line // EditorClearLine (INPUT_BAR_LOCATION); FileBufferRestorePosition (); return EFI_SUCCESS; }
/** The refresh function for InputBar, it will wait for user input @param[in] LastRow The last printable row. @param[in] LastColumn The last printable column. @retval EFI_SUCCESS The operation was successful. **/ EFI_STATUS EFIAPI InputBarRefresh ( UINTN LastRow, UINTN LastColumn ) { INPUT_BAR_COLOR_UNION Orig; INPUT_BAR_COLOR_UNION New; EFI_INPUT_KEY Key; UINTN Size; EFI_STATUS Status; BOOLEAN NoDisplay; UINTN Limit; UINTN mPromptLen; UINTN EventIndex; UINTN CursorRow; UINTN CursorCol; // // variable initialization // Size = 0; Status = EFI_SUCCESS; // // back up the old screen attributes // CursorCol = gST->ConOut->Mode->CursorColumn; CursorRow = gST->ConOut->Mode->CursorRow; Orig.Data = gST->ConOut->Mode->Attribute; New.Colors.Foreground = Orig.Colors.Background; New.Colors.Background = Orig.Colors.Foreground; gST->ConOut->SetAttribute (gST->ConOut, New.Data); // // clear input bar // EditorClearLine (LastRow , LastColumn, LastRow); gST->ConOut->SetCursorPosition (gST->ConOut, 0, LastRow - 1); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt); // // that's the maximum input length that can be displayed on screen // mPromptLen = StrLen (mPrompt); Limit = LastColumn - mPromptLen; // // this is a selection mPrompt, cursor will stay in edit area // actually this is for search , search/replace // if (StrStr (mPrompt, L"Yes/No")) { NoDisplay = TRUE; gST->ConOut->SetCursorPosition (gST->ConOut, CursorCol, CursorRow); gST->ConOut->SetAttribute (gST->ConOut, Orig.Data); } else { NoDisplay = FALSE; } // // wait for user input // for (;;) { gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex); Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); if (EFI_ERROR (Status)) { continue; } // // pressed ESC // if (Key.ScanCode == SCAN_ESC) { Size = 0; Status = EFI_NOT_READY; break; } // // return pressed // if (Key.UnicodeChar == CHAR_LINEFEED || Key.UnicodeChar == CHAR_CARRIAGE_RETURN) { break; } else if (Key.UnicodeChar == CHAR_BACKSPACE) { // // backspace // if (Size > 0) { Size--; mReturnString[Size] = CHAR_NULL; if (!NoDisplay) { InputBarPrintInput (LastColumn, LastRow); } } } else if (Key.UnicodeChar <= 127 && Key.UnicodeChar >= 32) { // // VALID ASCII char pressed // mReturnString[Size] = Key.UnicodeChar; // // should be less than specified length // if (Size >= StringSize) { continue; } Size++; mReturnString[Size] = CHAR_NULL; if (!NoDisplay) { InputBarPrintInput (LastColumn, LastRow); } else { // // if just choose yes/no // break; } } } mReturnString[Size] = CHAR_NULL; // // restore screen attributes // gST->ConOut->SetCursorPosition (gST->ConOut, CursorCol, CursorRow); gST->ConOut->SetAttribute (gST->ConOut, Orig.Data); return Status; }
EFI_STATUS MainTitleBarRefresh ( VOID ) /*++ Routine Description: Refresh function for MainTitleBar Arguments: VOID Returns: EFI_SUCCESS --*/ { EFI_EDITOR_COLOR_UNION Orig; EFI_EDITOR_COLOR_UNION New; CHAR16 *FileNameTmp; INTN i; // // if it's first time when editor launch, so refresh is mandatory // if (!EditorFirst) { // // if all the fields are unchanged, no need to refresh // if (StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) == 0 && FileBufferBackupVar.FileType == FileBuffer.FileType && FileBufferBackupVar.FileModified == FileBuffer.FileModified && FileBufferBackupVar.ReadOnly == FileBuffer.ReadOnly ) { return EFI_SUCCESS; } } // // backup the old screen attributes // Orig = MainEditor.ColorAttributes; New.Colors.Foreground = Orig.Colors.Background; New.Colors.Background = Orig.Colors.Foreground; Out->SetAttribute (Out, New.Data); // // clear the old title bar // EditorClearLine (TITLE_BAR_LOCATION); // // print the new title bar prefix // totally 25 chars // PrintAt ( TEXT_START_COLUMN - 1, TITLE_BAR_LOCATION - 1, L"%s ", MainTitleBar.TitlePrefix ); if (MainEditor.FileBuffer->FileName == NULL) { Out->SetAttribute (Out, Orig.Data); FileBufferRestorePosition (); return EFI_SUCCESS; } // // First Extract the FileName from fullpath // FileNameTmp = MainEditor.FileBuffer->FileName; for (i = StrLen (FileNameTmp) - 1; i >= 0; i--) { if (FileNameTmp[i] == L'\\') { break; } } i++; FileNameTmp = FileNameTmp + i; // // the space for file name is 20 characters // if (StrLen (FileNameTmp) <= 20) { Print (L"%s ", FileNameTmp); for (i = StrLen (FileNameTmp); i < 20; i++) { Print (L" "); } } else { for (i = 0; i < 17; i++) { Print (L"%c", FileNameTmp[i]); } // // print "..." // Print (L"... "); } // // print file type field // if (MainEditor.FileBuffer->FileType == ASCII_FILE) { Print (L" ASCII "); } else { Print (L" UNICODE "); } // // print read-only field // if (MainEditor.FileBuffer->ReadOnly) { Print (L"ReadOnly "); } else { Print (L" "); } // // print modified field // if (MainEditor.FileBuffer->FileModified) { Print (L"Modified"); } // // restore the old attribute // Out->SetAttribute (Out, Orig.Data); // // restore edit area cursor position // FileBufferRestorePosition (); return EFI_SUCCESS; }
/** Cause the status bar to refresh it's printing on the screen. @param[in] EditorFirst TRUE to indicate the first launch of the editor. FALSE otherwise. @param[in] LastRow LastPrintable row. @param[in] LastCol Last printable column. @param[in] FileRow Row in the file. @param[in] FileCol Column in the file. @param[in] InsertMode TRUE to indicate InsertMode. FALSE otherwise. @retval EFI_SUCCESS The operation was successful. **/ EFI_STATUS EFIAPI StatusBarRefresh ( IN BOOLEAN EditorFirst, IN UINTN LastRow, IN UINTN LastCol, IN UINTN FileRow, IN UINTN FileCol, IN BOOLEAN InsertMode ) { STATUS_BAR_COLOR_UNION Orig; STATUS_BAR_COLOR_UNION New; if (!StatusStringChanged && StatusBarNeedRefresh) { StatusBarSetStatusString (L"\0"); } // // when it's called first time after editor launch, so refresh is mandatory // if (!StatusBarNeedRefresh && !StatusStringChanged) { return EFI_SUCCESS; } // // back up the screen attributes // Orig.Data = gST->ConOut->Mode->Attribute; New.Data = 0; New.Colors.Foreground = Orig.Colors.Background; New.Colors.Background = Orig.Colors.Foreground; gST->ConOut->EnableCursor (gST->ConOut, FALSE); gST->ConOut->SetAttribute (gST->ConOut, New.Data); // // clear status bar // EditorClearLine (LastRow, LastCol, LastRow); // // print row, column fields // if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) { ShellPrintEx ( 0, (INT32)(LastRow) - 1, L" %d,%d %s", FileRow, FileCol, StatusString ); } else { ShellPrintEx ( 0, (INT32)(LastRow) - 1, L" %s", StatusString ); } // // print insert mode field // if (InsertMode) { ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"INS"); } else { ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR"); } // // restore the old screen attributes // gST->ConOut->SetAttribute (gST->ConOut, Orig.Data); // // restore position in edit area // gST->ConOut->EnableCursor (gST->ConOut, TRUE); StatusBarNeedRefresh = FALSE; StatusStringChanged = FALSE; return EFI_SUCCESS; }
EFI_STATUS MainInputBarRefresh ( VOID ) /*++ Routine Description: refresh function for MainInputBar, it will wait for user input Arguments: VOID Returns: EFI_SUCCESS --*/ { EFI_EDITOR_COLOR_UNION Orig; EFI_EDITOR_COLOR_UNION New; EFI_INPUT_KEY Key; UINTN Size; EFI_STATUS Status; BOOLEAN NoDisplay; UINTN Limit; UINTN PromptLen; // // variable initialization // Size = 0; Status = EFI_SUCCESS; // // free status string // EditorFreePool (MainEditor.StatusBar->StatusString); MainEditor.StatusBar->StatusString = PoolPrint (L""); if (MainEditor.StatusBar->StatusString == NULL) { return EFI_OUT_OF_RESOURCES; } // // back up the old screen attributes // Orig = MainEditor.ColorAttributes; New.Colors.Foreground = Orig.Colors.Background; New.Colors.Background = Orig.Colors.Foreground; Out->SetAttribute (Out, New.Data); // // clear input bar // EditorClearLine (INPUT_BAR_LOCATION); Out->SetCursorPosition (Out, 0, INPUT_BAR_LOCATION - 1); PrintToken (STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), HiiHandle, MainInputBar.Prompt); // // that's the maximum input length that can be displayed on screen // PromptLen = StrLen (MainInputBar.Prompt); Limit = MainEditor.ScreenSize.Column - PromptLen; // // this is a selection prompt, cursor will stay in edit area // actually this is for search , search/replace // if (StrStr (MainInputBar.Prompt, L"Yes/No")) { NoDisplay = TRUE; FileBufferRestorePosition (); Out->SetAttribute (Out, Orig.Data); } else { NoDisplay = FALSE; } // // wait for user input // for (;;) { WaitForSingleEvent (In->WaitForKey, 0); Status = In->ReadKeyStroke (In, &Key); if (EFI_ERROR (Status)) { continue; } // // pressed ESC // if (Key.ScanCode == SCAN_CODE_ESC) { Size = 0; Status = EFI_NOT_READY; break; } // // return pressed // if (Key.UnicodeChar == CHAR_LF || Key.UnicodeChar == CHAR_CR) { break; } else if (Key.UnicodeChar == CHAR_BS) { // // backspace // if (Size > 0) { Size--; MainInputBar.ReturnString[Size] = L'\0'; if (!NoDisplay) { MainInputBarPrintInput (); } } } else if (Key.UnicodeChar <= 127 && Key.UnicodeChar >= 32) { // // VALID ASCII char pressed // MainInputBar.ReturnString[Size] = Key.UnicodeChar; // // should be less than specified length // if (Size >= MainInputBar.StringSize) { continue; } Size++; MainInputBar.ReturnString[Size] = L'\0'; if (!NoDisplay) { MainInputBarPrintInput (); } else { // // if just choose yes/no // break; } } } MainInputBar.ReturnString[Size] = 0; FileBufferRestorePosition (); // // restore screen attributes // Out->SetAttribute (Out, Orig.Data); StatusBarNeedRefresh = TRUE; return Status; }