24BOOLEAN EditorMouseAction;
28extern BOOLEAN FileBufferNeedRefresh;
30extern BOOLEAN FileBufferOnlyLineNeedRefresh;
32extern BOOLEAN FileBufferMouseNeedRefresh;
183MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = {
317 if (MainEditor.FileBuffer->FileModified) {
319 if (EFI_ERROR (Status)) {
327 if (EFI_ERROR (Status)) {
337 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
343 if (Status == EFI_NOT_READY) {
354 if (EFI_ERROR (Status)) {
358 MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
382 if (EFI_ERROR (Status)) {
388 if (EFI_ERROR (Status)) {
394 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
400 if (Status == EFI_NOT_READY) {
426 if (EFI_ERROR (Status)) {
428 return EFI_LOAD_ERROR;
449 if (MainEditor.FileBuffer->ReadOnly) {
454 if (MainEditor.FileBuffer->FileType == FileTypeUnicode) {
455 MainEditor.FileBuffer->FileType = FileTypeAscii;
457 MainEditor.FileBuffer->FileType = FileTypeUnicode;
460 MainEditor.FileBuffer->FileModified =
TRUE;
490 if (Status == EFI_NOT_FOUND) {
494 if (EFI_ERROR (Status)) {
498 MainEditor.CutLine = Line;
524 if (MainEditor.CutLine ==
NULL) {
570 if (EFI_ERROR (Status)) {
575 if (EFI_ERROR (Status)) {
579 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
585 if (Status == EFI_NOT_READY) {
597 if (Buffer ==
NULL) {
598 return EFI_OUT_OF_RESOURCES;
614 if (Status == EFI_NOT_FOUND) {
622 if (EFI_ERROR (Status)) {
628 if (EFI_ERROR (Status)) {
635 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
641 if (Status == EFI_NOT_READY) {
696 BOOLEAN ReplaceOption;
701 ReplaceOption =
FALSE;
734 if (EFI_ERROR (Status)) {
739 if (EFI_ERROR (Status)) {
743 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
749 if (Status == EFI_NOT_READY) {
761 if (Search ==
NULL) {
762 return EFI_OUT_OF_RESOURCES;
765 SearchLen =
StrLen (Search);
771 if (EFI_ERROR (Status)) {
776 if (EFI_ERROR (Status)) {
780 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
786 if (Status == EFI_NOT_READY) {
791 if (Replace ==
NULL) {
793 return EFI_OUT_OF_RESOURCES;
796 ReplaceLen =
StrLen (Replace);
821 if (Status == EFI_NOT_FOUND) {
830 if (EFI_ERROR (Status)) {
837 if (EFI_ERROR (Status)) {
845 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
851 if (Status == EFI_NOT_READY) {
861 ReplaceOption =
TRUE;
867 ReplaceOption =
FALSE;
873 ReplaceOption =
TRUE;
897 if (MainEditor.FileBuffer->ReadOnly) {
916 if (EFI_ERROR (Status)) {
927 if (EFI_ERROR (Status)) {
934 if (EFI_ERROR (Status)) {
942 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
948 if (Status == EFI_NOT_READY) {
1018 if (MainEditor.FileBuffer->FileModified) {
1020 if (EFI_ERROR (Status)) {
1025 if (EFI_ERROR (Status)) {
1030 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
1036 if (Status == EFI_NOT_READY) {
1047 if (!EFI_ERROR (Status)) {
1095 if (EFI_ERROR (Status)) {
1103 if (EFI_ERROR (Status)) {
1107 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
1113 if (Status == EFI_NOT_READY) {
1129 if ((Row > MainEditor.FileBuffer->NumLines) || (Row <= 0)) {
1159 SHELL_FILE_HANDLE FileHandle;
1198 Str =
CatSPrint (
NULL, L
"File to Save: [%s]", MainEditor.FileBuffer->FileName);
1200 return EFI_OUT_OF_RESOURCES;
1203 if (
StrLen (Str) >= 50) {
1211 Str[50] = CHAR_NULL;
1217 if (EFI_ERROR (Status)) {
1222 if (EFI_ERROR (Status)) {
1229 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
1235 if (Status == EFI_NOT_READY) {
1243 FileName =
CatSPrint (
NULL, L
"%s", MainEditor.FileBuffer->FileName);
1248 if (FileName ==
NULL) {
1249 return EFI_OUT_OF_RESOURCES;
1271 if (MainEditor.FileBuffer->ReadOnly ==
TRUE) {
1285 if (EFI_ERROR (Status)) {
1298 if (Info->
Attribute & EFI_FILE_READ_ONLY) {
1311 if (EFI_ERROR (Status)) {
1312 SHELL_FREE_NON_NULL (FileName);
1317 if (EFI_ERROR (Status)) {
1318 SHELL_FREE_NON_NULL (FileName);
1323 Status =
InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
1329 if (Status == EFI_NOT_READY) {
1330 SHELL_FREE_NON_NULL (FileName);
1343 SHELL_FREE_NON_NULL (FileName);
1355 SHELL_FREE_NON_NULL (FileName);
1381 if (InfoString !=
NULL) {
1382 ShellPrintEx (0, CurrentLine+1, L
"%E%s%N", InfoString);
1390 Status =
gBS->WaitForEvent (1, &MainEditor.TextInputEx->
WaitForKeyEx, &EventIndex);
1391 if (EFI_ERROR (Status) || (EventIndex != 0)) {
1395 Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);
1396 if (EFI_ERROR (Status)) {
1407 if (KeyData.
Key.UnicodeChar == L
'W' - L
'A' + 1) {
1412 ((KeyData.
KeyState.
KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0))
1418 if ((KeyData.
Key.UnicodeChar ==
'w') || (KeyData.
Key.UnicodeChar ==
'W')) {
1428 FileBufferNeedRefresh =
TRUE;
1429 FileBufferOnlyLineNeedRefresh =
FALSE;
1475 CopyMem (&MainEditor, &MainEditorConst,
sizeof (MainEditor));
1483 OriginalColors = MainEditor.ColorAttributes.Colors;
1493 &(MainEditor.ScreenSize.Column),
1494 &(MainEditor.ScreenSize.Row)
1501 Status =
gBS->HandleProtocol (
1503 &gEfiSimpleTextInputExProtocolGuid,
1504 (VOID **)&MainEditor.TextInputEx
1506 if (EFI_ERROR (Status)) {
1513 Status =
gBS->HandleProtocol (
1515 &gEfiSimplePointerProtocolGuid,
1516 (VOID **)&MainEditor.MouseInterface
1518 if (EFI_ERROR (Status)) {
1522 HandleBuffer =
NULL;
1523 MainEditor.MouseInterface =
NULL;
1524 Status =
gBS->LocateHandleBuffer (
1526 &gEfiSimplePointerProtocolGuid,
1531 if (!EFI_ERROR (Status) && (HandleCount > 0)) {
1535 for (Index = 0; Index < HandleCount; Index++) {
1536 Status =
gBS->HandleProtocol (
1537 HandleBuffer[Index],
1538 &gEfiSimplePointerProtocolGuid,
1539 (VOID **)&MainEditor.MouseInterface
1541 if (!EFI_ERROR (Status)) {
1547 if (HandleBuffer !=
NULL) {
1552 if (!EFI_ERROR (Status) && (MainEditor.MouseInterface !=
NULL)) {
1553 MainEditor.MouseAccumulatorX = 0;
1554 MainEditor.MouseAccumulatorY = 0;
1555 MainEditor.MouseSupported =
TRUE;
1562 if (EFI_ERROR (Status)) {
1564 return EFI_LOAD_ERROR;
1569 if (EFI_ERROR (Status)) {
1571 return EFI_LOAD_ERROR;
1575 if (EFI_ERROR (Status)) {
1577 return EFI_LOAD_ERROR;
1583 if (EFI_ERROR (Status)) {
1585 return EFI_LOAD_ERROR;
1599 EditorMouseAction =
FALSE;
1628 if (EFI_ERROR (Status)) {
1644 EFI_TEXT_ATTR (OriginalColors.Foreground, OriginalColors.Background)
1669 || (
StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0)
1670 || (FileBufferBackupVar.FileType != FileBuffer.FileType)
1671 || (FileBufferBackupVar.FileModified != FileBuffer.FileModified)
1672 || (FileBufferBackupVar.ReadOnly != FileBuffer.ReadOnly))
1674 MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
1679 || (FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row)
1680 || (FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column)
1681 || (FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert)
1684 StatusBarRefresh (EditorFirst, MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column, MainEditor.FileBuffer->FilePosition.Row, MainEditor.FileBuffer->FilePosition.Column, MainEditor.FileBuffer->ModeInsert);
1697 EditorFirst =
FALSE;
1714 MainEditor.MouseAccumulatorX += GuidX;
1715 Gap = (MainEditor.MouseAccumulatorX * (INT32)MainEditor.ScreenSize.Column) / (INT32)(50 * (INT32)MainEditor.MouseInterface->
Mode->
ResolutionX);
1716 MainEditor.MouseAccumulatorX = (MainEditor.MouseAccumulatorX * (INT32)MainEditor.ScreenSize.Column) % (INT32)(50 * (INT32)MainEditor.MouseInterface->
Mode->
ResolutionX);
1717 MainEditor.MouseAccumulatorX = MainEditor.MouseAccumulatorX / (INT32)MainEditor.ScreenSize.Column;
1735 MainEditor.MouseAccumulatorY += GuidY;
1736 Gap = (MainEditor.MouseAccumulatorY * (INT32)MainEditor.ScreenSize.Row) / (INT32)(50 * (INT32)MainEditor.MouseInterface->
Mode->
ResolutionY);
1737 MainEditor.MouseAccumulatorY = (MainEditor.MouseAccumulatorY * (INT32)MainEditor.ScreenSize.Row) % (INT32)(50 * (INT32)MainEditor.MouseInterface->
Mode->
ResolutionY);
1738 MainEditor.MouseAccumulatorY = MainEditor.MouseAccumulatorY / (INT32)MainEditor.ScreenSize.Row;
1777 if (MouseState.RelativeMovementX || MouseState.RelativeMovementY) {
1781 TextX =
GetTextX (MouseState.RelativeMovementX);
1782 TextY =
GetTextY (MouseState.RelativeMovementY);
1792 if (MouseState.LeftButton) {
1793 FCol = MainEditor.FileBuffer->MousePosition.Column - 1 + 1;
1795 FRow = MainEditor.FileBuffer->FilePosition.Row +
1796 MainEditor.FileBuffer->MousePosition.Row -
1797 MainEditor.FileBuffer->DisplayPosition.Row;
1802 if (MainEditor.FileBuffer->NumLines < FRow) {
1803 FRow = MainEditor.FileBuffer->NumLines;
1806 Link = MainEditor.FileBuffer->ListHead->ForwardLink;
1807 for (Index = 0; Index < FRow - 1; Index++) {
1808 Link = Link->ForwardLink;
1816 if (FCol > Line->Size + 1) {
1817 FCol = Line->Size + 1;
1822 MainEditor.FileBuffer->MousePosition.Row = MainEditor.FileBuffer->DisplayPosition.Row;
1824 MainEditor.FileBuffer->MousePosition.Column = MainEditor.FileBuffer->DisplayPosition.Column;
1839 return EFI_NOT_FOUND;
1857 BOOLEAN NoShiftState;
1861 EditorMouseAction =
FALSE;
1873 if (MainEditor.MouseSupported) {
1874 Status = MainEditor.MouseInterface->GetState (
1875 MainEditor.MouseInterface,
1878 if (!EFI_ERROR (Status)) {
1881 if (!EFI_ERROR (Status)) {
1882 EditorMouseAction =
TRUE;
1883 FileBufferMouseNeedRefresh =
TRUE;
1884 }
else if (Status == EFI_LOAD_ERROR) {
1894 if (!EFI_ERROR (Status)) {
1895 Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);
1896 if (!EFI_ERROR (Status)) {
1901 FileBufferMouseNeedRefresh =
TRUE;
1915 }
else if (NoShiftState && ((KeyData.
Key.ScanCode == SCAN_NULL) || ((KeyData.
Key.ScanCode >= SCAN_UP) && (KeyData.
Key.ScanCode <= SCAN_PAGE_DOWN)))) {
1917 }
else if (NoShiftState && (KeyData.
Key.ScanCode >= SCAN_F1) && (KeyData.
Key.ScanCode <= SCAN_F12)) {
1921 FileBufferMouseNeedRefresh =
FALSE;
1924 if ((Status !=
EFI_SUCCESS) && (Status != EFI_OUT_OF_RESOURCES)) {
1939 }
while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);
1961 if (MainEditor.CutLine !=
NULL) {
1971 MainEditor.CutLine =
LineDup (Line);
1972 if (MainEditor.CutLine ==
NULL) {
1973 return EFI_OUT_OF_RESOURCES;
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
STATIC VOID FileBufferInit(OUT FILE_BUFFER *FileBuffer)
VOID StatusBarSetRefresh(VOID)
EFI_STATUS StatusBarRefresh(IN BOOLEAN EditorFirst, IN UINTN LastRow, IN UINTN LastCol, IN UINTN FileRow, IN UINTN FileCol, IN BOOLEAN InsertMode)
EFI_STATUS StatusBarSetStatusString(IN CHAR16 *Str)
CONST CHAR16 * StatusBarGetString(VOID)
BOOLEAN StatusBarGetRefresh(VOID)
EFI_STATUS StatusBarInit(VOID)
VOID StatusBarCleanup(VOID)
EFI_STATUS MainTitleBarInit(CONST CHAR16 *Prompt)
EFI_STATUS MainTitleBarRefresh(IN CONST CHAR16 *FileName OPTIONAL, IN CONST EDIT_FILE_TYPE FileType, IN CONST BOOLEAN ReadOnly, IN CONST BOOLEAN Modified, IN CONST UINTN LastCol, IN CONST UINTN LastRow, IN CONST UINTN Offset, IN CONST UINTN Size)
VOID MainTitleBarCleanup(VOID)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID FileBufferMovePosition(IN CONST UINTN NewFilePosRow, IN CONST UINTN NewFilePosCol)
VOID FileBufferSetModified(VOID)
EFI_STATUS FileBufferRefresh(VOID)
EFI_STATUS FileBufferCleanup(VOID)
EFI_STATUS FileBufferRead(IN CONST CHAR16 *FileName, IN CONST BOOLEAN Recover)
EFI_STATUS FileBufferRestorePosition(VOID)
EFI_STATUS FileBufferCutLine(OUT EFI_EDITOR_LINE **CutLine)
EFI_STATUS FileBufferSave(IN CONST CHAR16 *FileName)
EFI_STATUS FileBufferSearch(IN CONST CHAR16 *Str, IN CONST UINTN Offset)
EFI_STATUS FileBufferHandleInput(IN CONST EFI_INPUT_KEY *Key)
EFI_STATUS FileBufferReplace(IN CONST CHAR16 *Replace, IN CONST UINTN SearchLen)
EFI_STATUS FileBufferBackup(VOID)
VOID FileBufferAdjustMousePosition(IN CONST INT32 TextX, IN CONST INT32 TextY)
EFI_STATUS FileBufferReplaceAll(IN CHAR16 *SearchStr, IN CHAR16 *ReplaceStr, IN UINTN Offset)
EFI_STATUS FileBufferPasteLine(VOID)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
EFI_STATUS MainEditorSetCutLine(EFI_EDITOR_LINE *Line)
EFI_STATUS MainCommandDisplayHelp(VOID)
EFI_STATUS MainEditorBackup(VOID)
EFI_STATUS MainCommandGotoLine(VOID)
EFI_STATUS MainEditorCleanup(VOID)
EFI_STATUS MainCommandOpenFile(VOID)
INT32 GetTextY(IN INT32 GuidY)
INT32 GetTextX(IN INT32 GuidX)
EFI_STATUS MainEditorInit(VOID)
EFI_STATUS MainCommandCutLine(VOID)
EFI_STATUS MainEditorKeyInput(VOID)
EFI_STATUS MainEditorHandleMouseInput(IN EFI_SIMPLE_POINTER_STATE MouseState)
EFI_STATUS MainCommandExit(VOID)
EFI_STATUS MainCommandSwitchFileType(VOID)
EFI_STATUS MainCommandPasteLine(VOID)
EFI_STRING_ID MainMenuHelpInfo[]
VOID MainEditorRefresh(VOID)
EFI_STATUS MainCommandSearchReplace(VOID)
EFI_STATUS MainCommandSaveFile(VOID)
EFI_STATUS MainCommandSearch(VOID)
#define CR(Record, TYPE, Field, TestSignature)
EFI_FILE_INFO *EFIAPI ShellGetFileInfo(IN SHELL_FILE_HANDLE FileHandle)
UINTN EFIAPI ShellStrToUintn(IN CONST CHAR16 *String)
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS EFIAPI ShellFileExists(IN CONST CHAR16 *Name)
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
VOID LineFree(IN EFI_EDITOR_LINE *Src)
EFI_EDITOR_LINE * LineDup(IN EFI_EDITOR_LINE *Src)
INTN EFIAPI StringNoCaseCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
CHAR16 *EFIAPI CatSPrint(IN CHAR16 *String OPTIONAL, IN CONST CHAR16 *FormatString,...)
BOOLEAN IsValidFileName(IN CONST CHAR16 *Name)
EFI_SIMPLE_POINTER_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_HANDLE ConsoleInHandle
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut