2 Implementation of various string and line routines
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 extern BOOLEAN HEditorMouseAction
;
14 Free a line and it's internal buffer.
16 @param[in] Src The line to be freed.
20 IN HEFI_EDITOR_LINE
*Src
27 SHELL_FREE_NON_NULL (Src
);
32 Advance to the next Count lines.
34 @param[in] Count The line number to advance.
36 @retval NULL An error occurred.
37 @return A pointer to the line after advance.
45 HEFI_EDITOR_LINE
*Line
;
47 Line
= HMainEditor
.BufferImage
->CurrentLine
;
52 for (Index
= 0; Index
< Count
; Index
++) {
54 // if already last line
56 if (Line
->Link
.ForwardLink
== HMainEditor
.BufferImage
->ListHead
) {
60 Line
= CR (Line
->Link
.ForwardLink
, HEFI_EDITOR_LINE
, Link
, EFI_EDITOR_LINE_LIST
);
67 Retreat to the previous Count lines.
69 @param[in] Count The line number to retreat.
71 @retval NULL An error occurred.
72 @return A pointer to the line after retreat.
80 HEFI_EDITOR_LINE
*Line
;
82 Line
= HMainEditor
.BufferImage
->CurrentLine
;
87 for (Index
= 0; Index
< Count
; Index
++) {
89 // already the first line
91 if (Line
->Link
.BackLink
== HMainEditor
.BufferImage
->ListHead
) {
95 Line
= CR (Line
->Link
.BackLink
, HEFI_EDITOR_LINE
, Link
, EFI_EDITOR_LINE_LIST
);
102 Advance/Retreat lines.
104 @param[in] Count The line number to advance/retreat.
108 @retval NULL An error occurred.
109 @return A pointer to the line after move.
116 HEFI_EDITOR_LINE
*Line
;
120 // difference with MoveCurrentLine
122 // do not set currentline to Line
125 AbsCount
= (UINTN
)ABS(Count
);
126 Line
= HLineRetreat (AbsCount
);
128 Line
= HLineAdvance ((UINTN
)Count
);
135 Advance/Retreat lines and set CurrentLine in BufferImage to it.
137 @param[in] Count The line number to advance/retreat.
141 @retval NULL An error occurred.
142 @return A pointer to the line after move.
149 HEFI_EDITOR_LINE
*Line
;
157 AbsCount
= (UINTN
)ABS(Count
);
158 Line
= HLineRetreat (AbsCount
);
160 Line
= HLineAdvance ((UINTN
)Count
);
167 HMainEditor
.BufferImage
->CurrentLine
= Line
;
174 Free all the lines in HBufferImage.
181 @param[in] ListHead The list head.
182 @param[in] Lines The lines.
184 @retval EFI_SUCCESS The operation was successful.
188 IN LIST_ENTRY
*ListHead
,
189 IN HEFI_EDITOR_LINE
*Lines
193 HEFI_EDITOR_LINE
*Line
;
196 // release all the lines
201 Link
= &(Line
->Link
);
203 Line
= CR (Link
, HEFI_EDITOR_LINE
, Link
, EFI_EDITOR_LINE_LIST
);
204 Link
= Link
->ForwardLink
;
206 } while (Link
!= ListHead
);
209 ListHead
->ForwardLink
= ListHead
;
210 ListHead
->BackLink
= ListHead
;
216 Get the X information for the mouse.
218 @param[in] GuidX The change.
220 @return the new information.
229 HMainEditor
.MouseAccumulatorX
+= GuidX
;
230 Gap
= (HMainEditor
.MouseAccumulatorX
* (INT32
) HMainEditor
.ScreenSize
.Column
) / (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionX
);
231 HMainEditor
.MouseAccumulatorX
= (HMainEditor
.MouseAccumulatorX
* (INT32
) HMainEditor
.ScreenSize
.Column
) % (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionX
);
232 HMainEditor
.MouseAccumulatorX
= HMainEditor
.MouseAccumulatorX
/ (INT32
) HMainEditor
.ScreenSize
.Column
;
237 Get the Y information for the mouse.
239 @param[in] GuidY The change.
241 @return the new information.
250 HMainEditor
.MouseAccumulatorY
+= GuidY
;
251 Gap
= (HMainEditor
.MouseAccumulatorY
* (INT32
) HMainEditor
.ScreenSize
.Row
) / (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionY
);
252 HMainEditor
.MouseAccumulatorY
= (HMainEditor
.MouseAccumulatorY
* (INT32
) HMainEditor
.ScreenSize
.Row
) % (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionY
);
253 HMainEditor
.MouseAccumulatorY
= HMainEditor
.MouseAccumulatorY
/ (INT32
) HMainEditor
.ScreenSize
.Row
;