mirror of https://github.com/acidanthera/audk.git
ShellPkg: Make the USB mouse behavior in 'edit' consistent with 'hexedit'.
1. Make the USB mouse cursor move smoothly in 'edit'. 2. Make the USB mouse can drag and select text in 'edit'. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
parent
a5acc84226
commit
ee60bd2b6a
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Implements filebuffer interface functions.
|
||||
|
||||
Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved. <BR>
|
||||
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. <BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -256,6 +256,71 @@ MoveLine (
|
|||
return Line;
|
||||
}
|
||||
|
||||
/**
|
||||
Decide if a point is in the already selected area.
|
||||
|
||||
@param[in] MouseRow The row of the point to test.
|
||||
@param[in] MouseCol The col of the point to test.
|
||||
|
||||
@retval TRUE The point is in the selected area.
|
||||
@retval FALSE The point is not in the selected area.
|
||||
**/
|
||||
BOOLEAN
|
||||
FileBufferIsInSelectedArea (
|
||||
IN UINTN MouseRow,
|
||||
IN UINTN MouseCol
|
||||
)
|
||||
{
|
||||
UINTN FRow;
|
||||
UINTN RowStart;
|
||||
UINTN RowEnd;
|
||||
UINTN ColStart;
|
||||
UINTN ColEnd;
|
||||
UINTN MouseColStart;
|
||||
UINTN MouseColEnd;
|
||||
|
||||
//
|
||||
// judge mouse position whether is in selected area
|
||||
//
|
||||
//
|
||||
// not select
|
||||
//
|
||||
if (MainEditor.SelectStart == 0 || MainEditor.SelectEnd == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
//
|
||||
// calculate the select area
|
||||
//
|
||||
RowStart = (MainEditor.SelectStart - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
RowEnd = (MainEditor.SelectEnd - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
|
||||
ColStart = (MainEditor.SelectStart - 1) % SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
ColEnd = (MainEditor.SelectEnd - 1) % SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
|
||||
FRow = FileBuffer.LowVisibleRange.Row + MouseRow - 2;
|
||||
if (FRow < RowStart || FRow > RowEnd) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (FRow > RowStart) {
|
||||
ColStart = 1;
|
||||
}
|
||||
|
||||
if (FRow < RowEnd) {
|
||||
ColEnd = SHELL_EDIT_MAX_LINE_SIZE;
|
||||
}
|
||||
|
||||
MouseColStart = ColStart;
|
||||
|
||||
MouseColEnd = ColEnd;
|
||||
|
||||
if (MouseCol < MouseColStart || MouseCol > MouseColEnd) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
Function to update the 'screen' to display the mouse position.
|
||||
|
||||
|
@ -311,6 +376,29 @@ FileBufferRestoreMousePosition (
|
|||
|
||||
FColumn = FileBuffer.LowVisibleRange.Column + FileBufferBackupVar.MousePosition.Column - 1;
|
||||
|
||||
if (FRow <= FileBuffer.NumLines) {
|
||||
CurrentLine = FileBuffer.CurrentLine;
|
||||
Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
|
||||
FileBuffer.CurrentLine = CurrentLine;
|
||||
}
|
||||
|
||||
//
|
||||
// if in selected area,
|
||||
// so do not need to refresh mouse
|
||||
//
|
||||
if (!FileBufferIsInSelectedArea (
|
||||
FileBufferBackupVar.MousePosition.Row,
|
||||
FileBufferBackupVar.MousePosition.Column
|
||||
) ||
|
||||
(Line == NULL || FColumn > Line->Size)
|
||||
) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
} else {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
|
||||
}
|
||||
|
||||
Line = NULL;
|
||||
|
||||
HasCharacter = TRUE;
|
||||
if (FRow > FileBuffer.NumLines) {
|
||||
HasCharacter = FALSE;
|
||||
|
@ -343,8 +431,15 @@ FileBufferRestoreMousePosition (
|
|||
//
|
||||
// set the new mouse position
|
||||
//
|
||||
gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
|
||||
|
||||
if (!FileBufferIsInSelectedArea (
|
||||
FileBuffer.MousePosition.Row,
|
||||
FileBuffer.MousePosition.Column
|
||||
)
|
||||
) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
|
||||
} else {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
}
|
||||
//
|
||||
// clear the old mouse position
|
||||
//
|
||||
|
@ -472,18 +567,25 @@ FileBufferCleanup (
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Print a line specified by Line on a row specified by Row of the screen.
|
||||
Print Line on Row
|
||||
|
||||
@param[in] Line The line to print.
|
||||
@param[in] Row The row on the screen to print onto (begin from 1).
|
||||
@param[in] Line The lline to print.
|
||||
@param[in] Row The row on screen ( begin from 1 ).
|
||||
@param[in] FRow The FRow.
|
||||
@param[in] Orig The original color.
|
||||
@param[in] New The color to print with.
|
||||
|
||||
@retval EFI_SUCCESS The printing was successful.
|
||||
@retval EFI_SUCCESS The operation was successful.
|
||||
**/
|
||||
EFI_STATUS
|
||||
FileBufferPrintLine (
|
||||
IN CONST EFI_EDITOR_LINE *Line,
|
||||
IN CONST UINTN Row
|
||||
IN CONST EFI_EDITOR_LINE *Line,
|
||||
IN CONST UINTN Row,
|
||||
IN CONST UINTN FRow,
|
||||
IN EFI_EDITOR_COLOR_UNION Orig,
|
||||
IN EFI_EDITOR_COLOR_UNION New
|
||||
)
|
||||
{
|
||||
|
||||
|
@ -491,7 +593,42 @@ FileBufferPrintLine (
|
|||
UINTN Limit;
|
||||
CHAR16 *PrintLine;
|
||||
CHAR16 *PrintLine2;
|
||||
CHAR16 *TempString;
|
||||
UINTN BufLen;
|
||||
BOOLEAN Selected;
|
||||
UINTN RowStart;
|
||||
UINTN RowEnd;
|
||||
UINTN ColStart;
|
||||
UINTN ColEnd;
|
||||
|
||||
ColStart = 0;
|
||||
ColEnd = 0;
|
||||
Selected = FALSE;
|
||||
TempString = NULL;
|
||||
|
||||
//
|
||||
// print the selected area in opposite color
|
||||
//
|
||||
if (MainEditor.SelectStart != 0 && MainEditor.SelectEnd != 0) {
|
||||
RowStart = (MainEditor.SelectStart - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
RowEnd = (MainEditor.SelectEnd - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
|
||||
ColStart = (MainEditor.SelectStart - 1) % SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
ColEnd = (MainEditor.SelectEnd - 1) % SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
|
||||
if (FRow >= RowStart && FRow <= RowEnd) {
|
||||
Selected = TRUE;
|
||||
}
|
||||
|
||||
if (FRow > RowStart) {
|
||||
ColStart = 1;
|
||||
}
|
||||
|
||||
if (FRow < RowEnd) {
|
||||
ColEnd = Line->Size + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// print start from correct character
|
||||
|
@ -519,15 +656,64 @@ FileBufferPrintLine (
|
|||
|
||||
ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
|
||||
|
||||
ShellPrintEx (
|
||||
0,
|
||||
(INT32)Row - 1,
|
||||
L"%s",
|
||||
PrintLine2
|
||||
);
|
||||
if (!Selected) {
|
||||
ShellPrintEx (
|
||||
0,
|
||||
(INT32)Row - 1,
|
||||
L"%s",
|
||||
PrintLine2
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// If the current line is selected.
|
||||
//
|
||||
if (ColStart != 1) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
|
||||
TempString = AllocateCopyPool ((ColStart - 1) * sizeof(CHAR16), PrintLine2);
|
||||
ASSERT (TempString != NULL);
|
||||
ShellPrintEx (
|
||||
0,
|
||||
(INT32)Row - 1,
|
||||
L"%s",
|
||||
TempString
|
||||
);
|
||||
FreePool (TempString);
|
||||
}
|
||||
|
||||
gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
|
||||
TempString = AllocateCopyPool (
|
||||
(ColEnd - ColStart + 1) * sizeof(CHAR16),
|
||||
PrintLine2 + ColStart - 1
|
||||
);
|
||||
ASSERT (TempString != NULL);
|
||||
ShellPrintEx (
|
||||
(INT32)ColStart - 1,
|
||||
(INT32)Row - 1,
|
||||
L"%s",
|
||||
TempString
|
||||
);
|
||||
FreePool (TempString);
|
||||
|
||||
if (ColEnd != SHELL_EDIT_MAX_LINE_SIZE) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
|
||||
TempString = AllocateCopyPool (
|
||||
(SHELL_EDIT_MAX_LINE_SIZE - ColEnd + 1) * sizeof(CHAR16),
|
||||
PrintLine2 + ColEnd - 1
|
||||
);
|
||||
ASSERT (TempString != NULL);
|
||||
ShellPrintEx (
|
||||
(INT32)ColEnd - 1,
|
||||
(INT32)Row - 1,
|
||||
L"%s",
|
||||
TempString
|
||||
);
|
||||
FreePool (TempString);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (PrintLine);
|
||||
FreePool (PrintLine2);
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -568,6 +754,18 @@ FileBufferRefresh (
|
|||
LIST_ENTRY *Link;
|
||||
EFI_EDITOR_LINE *Line;
|
||||
UINTN Row;
|
||||
EFI_EDITOR_COLOR_UNION Orig;
|
||||
EFI_EDITOR_COLOR_UNION New;
|
||||
|
||||
UINTN StartRow;
|
||||
UINTN EndRow;
|
||||
UINTN FStartRow;
|
||||
UINTN Tmp;
|
||||
|
||||
Orig = MainEditor.ColorAttributes;
|
||||
New.Data = 0;
|
||||
New.Colors.Foreground = Orig.Colors.Background;
|
||||
New.Colors.Background = Orig.Colors.Foreground;
|
||||
|
||||
//
|
||||
// if it's the first time after editor launch, so should refresh
|
||||
|
@ -579,13 +777,10 @@ FileBufferRefresh (
|
|||
//
|
||||
if (!FileBufferNeedRefresh &&
|
||||
!FileBufferOnlyLineNeedRefresh &&
|
||||
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row &&
|
||||
FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column
|
||||
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row
|
||||
) {
|
||||
|
||||
FileBufferRestoreMousePosition ();
|
||||
FileBufferRestorePosition ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -596,19 +791,60 @@ FileBufferRefresh (
|
|||
// only need to refresh current line
|
||||
//
|
||||
if (FileBufferOnlyLineNeedRefresh &&
|
||||
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row &&
|
||||
FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column
|
||||
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row
|
||||
) {
|
||||
|
||||
EditorClearLine (FileBuffer.DisplayPosition.Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
|
||||
FileBufferPrintLine (
|
||||
FileBuffer.CurrentLine,
|
||||
FileBuffer.DisplayPosition.Row
|
||||
FileBuffer.DisplayPosition.Row,
|
||||
FileBuffer.FilePosition.Row,
|
||||
Orig,
|
||||
New
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// the whole edit area need refresh
|
||||
//
|
||||
if (EditorMouseAction && MainEditor.SelectStart != 0 && MainEditor.SelectEnd != 0) {
|
||||
if (MainEditor.SelectStart != MainEditorBackupVar.SelectStart) {
|
||||
if (MainEditor.SelectStart >= MainEditorBackupVar.SelectStart && MainEditorBackupVar.SelectStart != 0) {
|
||||
StartRow = (MainEditorBackupVar.SelectStart - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
} else {
|
||||
StartRow = (MainEditor.SelectStart - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
}
|
||||
} else {
|
||||
StartRow = (MainEditor.SelectStart - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
}
|
||||
|
||||
if (MainEditor.SelectEnd <= MainEditorBackupVar.SelectEnd) {
|
||||
EndRow = (MainEditorBackupVar.SelectEnd - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
} else {
|
||||
EndRow = (MainEditor.SelectEnd - 1) / SHELL_EDIT_MAX_LINE_SIZE + 1;
|
||||
}
|
||||
|
||||
//
|
||||
// swap
|
||||
//
|
||||
if (StartRow > EndRow) {
|
||||
Tmp = StartRow;
|
||||
StartRow = EndRow;
|
||||
EndRow = Tmp;
|
||||
}
|
||||
|
||||
FStartRow = StartRow;
|
||||
|
||||
StartRow = 2 + StartRow - FileBuffer.LowVisibleRange.Row;
|
||||
EndRow = 2 + EndRow - FileBuffer.LowVisibleRange.Row;
|
||||
|
||||
} else {
|
||||
//
|
||||
// not mouse selection actions
|
||||
//
|
||||
FStartRow = FileBuffer.LowVisibleRange.Row;
|
||||
StartRow = 2;
|
||||
EndRow = (MainEditor.ScreenSize.Row - 1);
|
||||
}
|
||||
|
||||
//
|
||||
// no line
|
||||
|
@ -638,15 +874,20 @@ FileBufferRefresh (
|
|||
//
|
||||
// print line at row
|
||||
//
|
||||
FileBufferPrintLine (Line, Row);
|
||||
FileBufferPrintLine (Line,
|
||||
Row,
|
||||
FileBuffer.LowVisibleRange.Row + Row - 2,
|
||||
Orig,
|
||||
New
|
||||
);
|
||||
|
||||
Link = Link->ForwardLink;
|
||||
Row++;
|
||||
} while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 1));
|
||||
} while (Link != FileBuffer.ListHead && Row <= EndRow);
|
||||
//
|
||||
// while not file end and not screen full
|
||||
//
|
||||
while (Row <= (MainEditor.ScreenSize.Row - 1)) {
|
||||
while (Row <= EndRow) {
|
||||
EditorClearLine (Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
|
||||
Row++;
|
||||
}
|
||||
|
@ -3369,3 +3610,39 @@ FileBufferSetModified (
|
|||
FileBuffer.FileModified = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the size of the open buffer.
|
||||
|
||||
@retval The size in bytes.
|
||||
**/
|
||||
UINTN
|
||||
FileBufferGetTotalSize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
|
||||
EFI_EDITOR_LINE *Line;
|
||||
|
||||
//
|
||||
// calculate the total size of whole line list's buffer
|
||||
//
|
||||
if (FileBuffer.Lines == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Line = CR (
|
||||
FileBuffer.ListHead->BackLink,
|
||||
EFI_EDITOR_LINE,
|
||||
Link,
|
||||
LINE_LIST_SIGNATURE
|
||||
);
|
||||
//
|
||||
// one line at most 0x50
|
||||
//
|
||||
Size = SHELL_EDIT_MAX_LINE_SIZE * (FileBuffer.NumLines - 1) + Line->Size;
|
||||
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Declares filebuffer interface functions.
|
||||
|
||||
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. <BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -260,4 +260,14 @@ FileBufferSetModified (
|
|||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Get the size of the open buffer.
|
||||
|
||||
@retval The size in bytes.
|
||||
**/
|
||||
UINTN
|
||||
FileBufferGetTotalSize (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,7 @@ extern BOOLEAN FileBufferMouseNeedRefresh;
|
|||
extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
|
||||
|
||||
EFI_EDITOR_GLOBAL_EDITOR MainEditor;
|
||||
EFI_EDITOR_GLOBAL_EDITOR MainEditorBackupVar;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1689,7 +1690,8 @@ GetTextY (
|
|||
/**
|
||||
Support mouse movement. Move the cursor.
|
||||
|
||||
@param[in] MouseState The current mouse state.
|
||||
@param[in] MouseState The current mouse state.
|
||||
@param[out] BeforeLeftButtonDown TRUE if the left button down. Helps with selections.
|
||||
|
||||
@retval EFI_SUCCESS The operation was successful.
|
||||
@retval EFI_NOT_FOUND There was no mouse support found.
|
||||
|
@ -1697,7 +1699,8 @@ GetTextY (
|
|||
EFI_STATUS
|
||||
EFIAPI
|
||||
MainEditorHandleMouseInput (
|
||||
IN EFI_SIMPLE_POINTER_STATE MouseState
|
||||
IN EFI_SIMPLE_POINTER_STATE MouseState,
|
||||
OUT BOOLEAN *BeforeLeftButtonDown
|
||||
)
|
||||
{
|
||||
|
||||
|
@ -1705,10 +1708,8 @@ MainEditorHandleMouseInput (
|
|||
INT32 TextY;
|
||||
UINTN FRow;
|
||||
UINTN FCol;
|
||||
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *Link;
|
||||
EFI_EDITOR_LINE *Line;
|
||||
|
||||
UINTN Index;
|
||||
BOOLEAN Action;
|
||||
|
||||
|
@ -1761,10 +1762,27 @@ MainEditorHandleMouseInput (
|
|||
Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
|
||||
|
||||
//
|
||||
// dragging
|
||||
// beyond the line's column length
|
||||
//
|
||||
if (FCol > Line->Size + 1) {
|
||||
FCol = Line->Size + 1;
|
||||
if (FCol > Line->Size ) {
|
||||
if (*BeforeLeftButtonDown) {
|
||||
|
||||
if (Line->Size == 0) {
|
||||
if (FRow > 1) {
|
||||
FRow--;
|
||||
FCol = SHELL_EDIT_MAX_LINE_SIZE;
|
||||
} else {
|
||||
FRow = 1;
|
||||
FCol = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
FCol = Line->Size ;
|
||||
}
|
||||
} else {
|
||||
FCol = Line->Size + 1;
|
||||
}
|
||||
}
|
||||
|
||||
FileBufferMovePosition (FRow, FCol);
|
||||
|
@ -1773,8 +1791,24 @@ MainEditorHandleMouseInput (
|
|||
|
||||
MainEditor.FileBuffer->MousePosition.Column = MainEditor.FileBuffer->DisplayPosition.Column;
|
||||
|
||||
*BeforeLeftButtonDown = TRUE;
|
||||
|
||||
Action = TRUE;
|
||||
} else {
|
||||
//
|
||||
// else of if LButton
|
||||
//
|
||||
// release LButton
|
||||
//
|
||||
if (*BeforeLeftButtonDown) {
|
||||
Action = TRUE;
|
||||
}
|
||||
//
|
||||
// mouse up
|
||||
//
|
||||
*BeforeLeftButtonDown = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// mouse has action
|
||||
//
|
||||
|
@ -1804,6 +1838,23 @@ MainEditorKeyInput (
|
|||
EFI_INPUT_KEY Key;
|
||||
EFI_STATUS Status;
|
||||
EFI_SIMPLE_POINTER_STATE MouseState;
|
||||
BOOLEAN BeforeMouseIsDown;
|
||||
BOOLEAN MouseIsDown;
|
||||
BOOLEAN FirstDown;
|
||||
BOOLEAN MouseDrag;
|
||||
UINTN FRow;
|
||||
UINTN FCol;
|
||||
UINTN SelectStartBackup;
|
||||
UINTN SelectEndBackup;
|
||||
|
||||
//
|
||||
// variable initialization
|
||||
//
|
||||
FRow = 0;
|
||||
FCol = 0;
|
||||
MouseIsDown = FALSE;
|
||||
FirstDown = FALSE;
|
||||
MouseDrag = FALSE;
|
||||
|
||||
do {
|
||||
|
||||
|
@ -1826,10 +1877,105 @@ MainEditorKeyInput (
|
|||
&MouseState
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
BeforeMouseIsDown = MouseIsDown;
|
||||
|
||||
Status = MainEditorHandleMouseInput (MouseState);
|
||||
Status = MainEditorHandleMouseInput (MouseState, &MouseIsDown);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (!BeforeMouseIsDown) {
|
||||
//
|
||||
// mouse down
|
||||
//
|
||||
if (MouseIsDown) {
|
||||
FRow = FileBuffer.FilePosition.Row;
|
||||
FCol = FileBuffer.FilePosition.Column;
|
||||
SelectStartBackup = MainEditor.SelectStart;
|
||||
SelectEndBackup = MainEditor.SelectEnd;
|
||||
|
||||
FirstDown = TRUE;
|
||||
}
|
||||
} else {
|
||||
|
||||
SelectStartBackup = MainEditor.SelectStart;
|
||||
SelectEndBackup = MainEditor.SelectEnd;
|
||||
|
||||
//
|
||||
// begin to drag
|
||||
//
|
||||
if (MouseIsDown) {
|
||||
if (FirstDown) {
|
||||
if (MouseState.RelativeMovementX || MouseState.RelativeMovementY) {
|
||||
MainEditor.SelectStart = 0;
|
||||
MainEditor.SelectEnd = 0;
|
||||
MainEditor.SelectStart = (FRow - 1) * SHELL_EDIT_MAX_LINE_SIZE + FCol;
|
||||
|
||||
MouseDrag = TRUE;
|
||||
FirstDown = FALSE;
|
||||
}
|
||||
} else {
|
||||
if ((
|
||||
(FileBuffer.FilePosition.Row - 1) *
|
||||
SHELL_EDIT_MAX_LINE_SIZE +
|
||||
FileBuffer.FilePosition.Column
|
||||
) >= MainEditor.SelectStart
|
||||
) {
|
||||
MainEditor.SelectEnd = (FileBuffer.FilePosition.Row - 1) *
|
||||
SHELL_EDIT_MAX_LINE_SIZE +
|
||||
FileBuffer.FilePosition.Column;
|
||||
} else {
|
||||
MainEditor.SelectEnd = 0;
|
||||
}
|
||||
}
|
||||
//
|
||||
// end of if RelativeX/Y
|
||||
//
|
||||
} else {
|
||||
//
|
||||
// mouse is up
|
||||
//
|
||||
if (MouseDrag) {
|
||||
if (FileBufferGetTotalSize () == 0) {
|
||||
MainEditor.SelectStart = 0;
|
||||
MainEditor.SelectEnd = 0;
|
||||
FirstDown = FALSE;
|
||||
MouseDrag = FALSE;
|
||||
}
|
||||
|
||||
if ((
|
||||
(FileBuffer.FilePosition.Row - 1) *
|
||||
SHELL_EDIT_MAX_LINE_SIZE +
|
||||
FileBuffer.FilePosition.Column
|
||||
) >= MainEditor.SelectStart
|
||||
) {
|
||||
MainEditor.SelectEnd = (FileBuffer.FilePosition.Row - 1) *
|
||||
SHELL_EDIT_MAX_LINE_SIZE +
|
||||
FileBuffer.FilePosition.Column;
|
||||
} else {
|
||||
MainEditor.SelectEnd = 0;
|
||||
}
|
||||
|
||||
if (MainEditor.SelectEnd == 0) {
|
||||
MainEditor.SelectStart = 0;
|
||||
}
|
||||
}
|
||||
|
||||
FirstDown = FALSE;
|
||||
MouseDrag = FALSE;
|
||||
}
|
||||
|
||||
if (SelectStartBackup != MainEditor.SelectStart || SelectEndBackup != MainEditor.SelectEnd) {
|
||||
if ((SelectStartBackup - 1) / SHELL_EDIT_MAX_LINE_SIZE != (MainEditor.SelectStart - 1) / SHELL_EDIT_MAX_LINE_SIZE) {
|
||||
FileBufferNeedRefresh = TRUE;
|
||||
} else {
|
||||
if ((SelectEndBackup - 1) / SHELL_EDIT_MAX_LINE_SIZE != (MainEditor.SelectEnd - 1) / SHELL_EDIT_MAX_LINE_SIZE) {
|
||||
FileBufferNeedRefresh = TRUE;
|
||||
} else {
|
||||
FileBufferOnlyLineNeedRefresh = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorMouseAction = TRUE;
|
||||
FileBufferMouseNeedRefresh = TRUE;
|
||||
} else if (Status == EFI_LOAD_ERROR) {
|
||||
|
@ -1930,7 +2076,11 @@ MainEditorBackup (
|
|||
VOID
|
||||
)
|
||||
{
|
||||
MainEditorBackupVar.SelectStart = MainEditor.SelectStart;
|
||||
MainEditorBackupVar.SelectEnd = MainEditor.SelectEnd;
|
||||
FileBufferBackup ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main include file for Edit shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. <BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include "Misc.h"
|
||||
|
||||
extern EFI_EDITOR_GLOBAL_EDITOR MainEditor;
|
||||
extern EFI_EDITOR_GLOBAL_EDITOR MainEditorBackupVar;
|
||||
extern BOOLEAN EditorFirst;
|
||||
extern BOOLEAN EditorExit;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Declares editor types.
|
||||
|
||||
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. <BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -19,8 +19,9 @@
|
|||
#include "EditTitleBar.h"
|
||||
#include "EditMenuBar.h"
|
||||
|
||||
#define MIN_POOL_SIZE 125
|
||||
#define MAX_STRING_LENGTH 127
|
||||
#define MIN_POOL_SIZE 125
|
||||
#define MAX_STRING_LENGTH 127
|
||||
#define SHELL_EDIT_MAX_LINE_SIZE 0x50
|
||||
|
||||
typedef struct {
|
||||
UINTN Row;
|
||||
|
@ -97,6 +98,8 @@ typedef struct {
|
|||
INT32 MouseAccumulatorX;
|
||||
INT32 MouseAccumulatorY;
|
||||
|
||||
UINTN SelectStart; // starting from 1
|
||||
UINTN SelectEnd; // starting from 1
|
||||
} EFI_EDITOR_GLOBAL_EDITOR;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue