2 Implementation of various string and line routines
4 Copyright (TempVarC) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "HexEditor.h"
17 extern BOOLEAN HEditorMouseAction
;
20 Free a line and it's internal buffer.
22 @param[in] Src The line to be freed.
26 IN HEFI_EDITOR_LINE
*Src
33 SHELL_FREE_NON_NULL (Src
);
38 Advance to the next Count lines.
40 @param[in] Count The line number to advance.
42 @retval NULL An error occured.
43 @return A pointer to the line after advance.
51 HEFI_EDITOR_LINE
*Line
;
53 Line
= HMainEditor
.BufferImage
->CurrentLine
;
58 for (Index
= 0; Index
< Count
; Index
++) {
60 // if already last line
62 if (Line
->Link
.ForwardLink
== HMainEditor
.BufferImage
->ListHead
) {
66 Line
= CR (Line
->Link
.ForwardLink
, HEFI_EDITOR_LINE
, Link
, EFI_EDITOR_LINE_LIST
);
73 Retreat to the previous Count lines.
75 @param[in] Count The line number to retreat.
77 @retval NULL An error occured.
78 @return A pointer to the line after retreat.
86 HEFI_EDITOR_LINE
*Line
;
88 Line
= HMainEditor
.BufferImage
->CurrentLine
;
93 for (Index
= 0; Index
< Count
; Index
++) {
95 // already the first line
97 if (Line
->Link
.BackLink
== HMainEditor
.BufferImage
->ListHead
) {
101 Line
= CR (Line
->Link
.BackLink
, HEFI_EDITOR_LINE
, Link
, EFI_EDITOR_LINE_LIST
);
108 Advance/Retreat lines.
110 @param[in] Count The line number to advance/retreat.
114 @retval NULL An error occured.
115 @return A pointer to the line after move.
122 HEFI_EDITOR_LINE
*Line
;
126 // difference with MoveCurrentLine
128 // do not set currentline to Line
131 AbsCount
= (UINTN
)ABS(Count
);
132 Line
= HLineRetreat (AbsCount
);
134 Line
= HLineAdvance ((UINTN
)Count
);
141 Advance/Retreat lines and set CurrentLine in BufferImage to it.
143 @param[in] Count The line number to advance/retreat.
147 @retval NULL An error occured.
148 @return A pointer to the line after move.
155 HEFI_EDITOR_LINE
*Line
;
163 AbsCount
= (UINTN
)ABS(Count
);
164 Line
= HLineRetreat (AbsCount
);
166 Line
= HLineAdvance ((UINTN
)Count
);
173 HMainEditor
.BufferImage
->CurrentLine
= Line
;
180 Free all the lines in HBufferImage.
187 @param[in] ListHead The list head.
188 @param[in] Lines The lines.
190 @retval EFI_SUCCESS The operation was successful.
194 IN LIST_ENTRY
*ListHead
,
195 IN HEFI_EDITOR_LINE
*Lines
199 HEFI_EDITOR_LINE
*Line
;
202 // release all the lines
207 Link
= &(Line
->Link
);
209 Line
= CR (Link
, HEFI_EDITOR_LINE
, Link
, EFI_EDITOR_LINE_LIST
);
210 Link
= Link
->ForwardLink
;
212 } while (Link
!= ListHead
);
215 ListHead
->ForwardLink
= ListHead
;
216 ListHead
->BackLink
= ListHead
;
222 Get the X information for the mouse.
224 @param[in] GuidX The change.
226 @return the new information.
235 HMainEditor
.MouseAccumulatorX
+= GuidX
;
236 Gap
= (HMainEditor
.MouseAccumulatorX
* (INT32
) HMainEditor
.ScreenSize
.Column
) / (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionX
);
237 HMainEditor
.MouseAccumulatorX
= (HMainEditor
.MouseAccumulatorX
* (INT32
) HMainEditor
.ScreenSize
.Column
) % (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionX
);
238 HMainEditor
.MouseAccumulatorX
= HMainEditor
.MouseAccumulatorX
/ (INT32
) HMainEditor
.ScreenSize
.Column
;
243 Get the Y information for the mouse.
245 @param[in] GuidY The change.
247 @return the new information.
256 HMainEditor
.MouseAccumulatorY
+= GuidY
;
257 Gap
= (HMainEditor
.MouseAccumulatorY
* (INT32
) HMainEditor
.ScreenSize
.Row
) / (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionY
);
258 HMainEditor
.MouseAccumulatorY
= (HMainEditor
.MouseAccumulatorY
* (INT32
) HMainEditor
.ScreenSize
.Row
) % (INT32
) (50 * (INT32
) HMainEditor
.MouseInterface
->Mode
->ResolutionY
);
259 HMainEditor
.MouseAccumulatorY
= HMainEditor
.MouseAccumulatorY
/ (INT32
) HMainEditor
.ScreenSize
.Row
;