1 | /** @file
|
---|
2 | Defines BufferImage - the view of the file that is visible at any point,
|
---|
3 | as well as the event handlers for editing the file
|
---|
4 |
|
---|
5 | Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef _LIB_BUFFER_IMAGE_H_
|
---|
11 | #define _LIB_BUFFER_IMAGE_H_
|
---|
12 |
|
---|
13 | #include "HexEditor.h"
|
---|
14 |
|
---|
15 | /**
|
---|
16 | Initialization function for HBufferImage
|
---|
17 |
|
---|
18 | @retval EFI_SUCCESS The operation was successful.
|
---|
19 | @retval EFI_LOAD_ERROR A load error occurred.
|
---|
20 | **/
|
---|
21 | EFI_STATUS
|
---|
22 | HBufferImageInit (
|
---|
23 | VOID
|
---|
24 | );
|
---|
25 |
|
---|
26 | /**
|
---|
27 | Cleanup function for HBufferImage
|
---|
28 |
|
---|
29 | @retval EFI_SUCCESS The operation was successful.
|
---|
30 | **/
|
---|
31 | EFI_STATUS
|
---|
32 | HBufferImageCleanup (
|
---|
33 | VOID
|
---|
34 | );
|
---|
35 |
|
---|
36 | /**
|
---|
37 | Refresh function for HBufferImage.
|
---|
38 |
|
---|
39 | @retval EFI_SUCCESS The operation was successful.
|
---|
40 | @retval EFI_LOAD_ERROR A Load error occurred.
|
---|
41 |
|
---|
42 | **/
|
---|
43 | EFI_STATUS
|
---|
44 | HBufferImageRefresh (
|
---|
45 | VOID
|
---|
46 | );
|
---|
47 |
|
---|
48 | /**
|
---|
49 | Dispatch input to different handler
|
---|
50 |
|
---|
51 | @param[in] Key The input key:
|
---|
52 | the keys can be:
|
---|
53 | ASCII KEY
|
---|
54 | Backspace/Delete
|
---|
55 | Direction key: up/down/left/right/pgup/pgdn
|
---|
56 | Home/End
|
---|
57 | INS
|
---|
58 |
|
---|
59 | @retval EFI_SUCCESS The operation was successful.
|
---|
60 | @retval EFI_LOAD_ERROR A load error occurred.
|
---|
61 | @retval EFI_OUT_OF_RESOURCES A Memory allocation failed.
|
---|
62 | **/
|
---|
63 | EFI_STATUS
|
---|
64 | HBufferImageHandleInput (
|
---|
65 | IN EFI_INPUT_KEY *Key
|
---|
66 | );
|
---|
67 |
|
---|
68 | /**
|
---|
69 | Backup function for HBufferImage. Only a few fields need to be backup.
|
---|
70 | This is for making the file buffer refresh as few as possible.
|
---|
71 |
|
---|
72 | @retval EFI_SUCCESS The operation was successful.
|
---|
73 | **/
|
---|
74 | EFI_STATUS
|
---|
75 | HBufferImageBackup (
|
---|
76 | VOID
|
---|
77 | );
|
---|
78 |
|
---|
79 | /**
|
---|
80 | Read an image into a buffer friom a source.
|
---|
81 |
|
---|
82 | @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
|
---|
83 | @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
---|
84 | @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
---|
85 | @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
---|
86 | @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
|
---|
87 | @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
|
---|
88 | @param[in] BufferType The type of buffer to save. IGNORED.
|
---|
89 | @param[in] Recover TRUE for recovermode, FALSE otherwise.
|
---|
90 |
|
---|
91 | @return EFI_SUCCESS The operation was successful.
|
---|
92 | **/
|
---|
93 | EFI_STATUS
|
---|
94 | HBufferImageRead (
|
---|
95 | IN CONST CHAR16 *FileName,
|
---|
96 | IN CONST CHAR16 *DiskName,
|
---|
97 | IN UINTN DiskOffset,
|
---|
98 | IN UINTN DiskSize,
|
---|
99 | IN UINTN MemOffset,
|
---|
100 | IN UINTN MemSize,
|
---|
101 | IN EDIT_FILE_TYPE BufferType,
|
---|
102 | IN BOOLEAN Recover
|
---|
103 | );
|
---|
104 |
|
---|
105 | /**
|
---|
106 | Save the current image.
|
---|
107 |
|
---|
108 | @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
|
---|
109 | @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
---|
110 | @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
---|
111 | @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
---|
112 | @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
|
---|
113 | @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
|
---|
114 | @param[in] BufferType The type of buffer to save. IGNORED.
|
---|
115 |
|
---|
116 | @return EFI_SUCCESS The operation was successful.
|
---|
117 | **/
|
---|
118 | EFI_STATUS
|
---|
119 | HBufferImageSave (
|
---|
120 | IN CHAR16 *FileName,
|
---|
121 | IN CHAR16 *DiskName,
|
---|
122 | IN UINTN DiskOffset,
|
---|
123 | IN UINTN DiskSize,
|
---|
124 | IN UINTN MemOffset,
|
---|
125 | IN UINTN MemSize,
|
---|
126 | IN EDIT_FILE_TYPE BufferType
|
---|
127 | );
|
---|
128 |
|
---|
129 | /**
|
---|
130 | According to cursor's file position, adjust screen display.
|
---|
131 |
|
---|
132 | @param[in] NewFilePosRow Row of file position ( start from 1 ).
|
---|
133 | @param[in] NewFilePosCol Column of file position ( start from 1 ).
|
---|
134 | @param[in] HighBits Cursor will on high4 bits or low4 bits.
|
---|
135 | **/
|
---|
136 | VOID
|
---|
137 | HBufferImageMovePosition (
|
---|
138 | IN UINTN NewFilePosRow,
|
---|
139 | IN UINTN NewFilePosCol,
|
---|
140 | IN BOOLEAN HighBits
|
---|
141 | );
|
---|
142 |
|
---|
143 | /**
|
---|
144 | Create a new line and append it to the line list.
|
---|
145 | Fields affected:
|
---|
146 | NumLines
|
---|
147 | Lines
|
---|
148 |
|
---|
149 | @retval NULL create line failed.
|
---|
150 | @return the line created.
|
---|
151 |
|
---|
152 | **/
|
---|
153 | HEFI_EDITOR_LINE *
|
---|
154 | HBufferImageCreateLine (
|
---|
155 | VOID
|
---|
156 | );
|
---|
157 |
|
---|
158 | /**
|
---|
159 | Free the current image.
|
---|
160 |
|
---|
161 | @retval EFI_SUCCESS The operation was successful.
|
---|
162 | **/
|
---|
163 | EFI_STATUS
|
---|
164 | HBufferImageFree (
|
---|
165 | VOID
|
---|
166 | );
|
---|
167 |
|
---|
168 | /**
|
---|
169 | Delete character from buffer.
|
---|
170 |
|
---|
171 | @param[in] Pos Position, Pos starting from 0.
|
---|
172 | @param[in] Count The Count of characters to delete.
|
---|
173 | @param[out] DeleteBuffer The DeleteBuffer.
|
---|
174 |
|
---|
175 | @retval EFI_SUCCESS Success
|
---|
176 | **/
|
---|
177 | EFI_STATUS
|
---|
178 | HBufferImageDeleteCharacterFromBuffer (
|
---|
179 | IN UINTN Pos,
|
---|
180 | IN UINTN Count,
|
---|
181 | OUT UINT8 *DeleteBuffer
|
---|
182 | );
|
---|
183 |
|
---|
184 | /**
|
---|
185 | Add character to buffer, add before pos.
|
---|
186 |
|
---|
187 | @param[in] Pos Position, Pos starting from 0.
|
---|
188 | @param[in] Count Count of characters to add.
|
---|
189 | @param[in] AddBuffer Add buffer.
|
---|
190 |
|
---|
191 | @retval EFI_SUCCESS Success.
|
---|
192 | **/
|
---|
193 | EFI_STATUS
|
---|
194 | HBufferImageAddCharacterToBuffer (
|
---|
195 | IN UINTN Pos,
|
---|
196 | IN UINTN Count,
|
---|
197 | IN UINT8 *AddBuffer
|
---|
198 | );
|
---|
199 |
|
---|
200 | /**
|
---|
201 | Change the raw buffer to a list of lines for the UI.
|
---|
202 |
|
---|
203 | @param[in] Buffer The pointer to the buffer to fill.
|
---|
204 | @param[in] Bytes The size of the buffer in bytes.
|
---|
205 |
|
---|
206 | @retval EFI_SUCCESS The operation was successful.
|
---|
207 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
|
---|
208 | **/
|
---|
209 | EFI_STATUS
|
---|
210 | HBufferImageBufferToList (
|
---|
211 | IN VOID *Buffer,
|
---|
212 | IN UINTN Bytes
|
---|
213 | );
|
---|
214 |
|
---|
215 | /**
|
---|
216 | Change the list of lines from the UI to a raw buffer.
|
---|
217 |
|
---|
218 | @param[in] Buffer The pointer to the buffer to fill.
|
---|
219 | @param[in] Bytes The size of the buffer in bytes.
|
---|
220 |
|
---|
221 | @retval EFI_SUCCESS The operation was successful.
|
---|
222 | **/
|
---|
223 | EFI_STATUS
|
---|
224 | HBufferImageListToBuffer (
|
---|
225 | IN VOID *Buffer,
|
---|
226 | IN UINTN Bytes
|
---|
227 | );
|
---|
228 |
|
---|
229 | /**
|
---|
230 | Move the mouse in the image buffer.
|
---|
231 |
|
---|
232 | @param[in] TextX The x-coordinate.
|
---|
233 | @param[in] TextY The y-coordinate.
|
---|
234 | **/
|
---|
235 | VOID
|
---|
236 | HBufferImageAdjustMousePosition (
|
---|
237 | IN INT32 TextX,
|
---|
238 | IN INT32 TextY
|
---|
239 | );
|
---|
240 |
|
---|
241 | /**
|
---|
242 | Function to decide if a column number is stored in the high bits.
|
---|
243 |
|
---|
244 | @param[in] Column The column to examine.
|
---|
245 | @param[out] FCol The actual column number.
|
---|
246 |
|
---|
247 | @retval TRUE The actual column was in high bits and is now in FCol.
|
---|
248 | @retval FALSE There was not a column number in the high bits.
|
---|
249 | **/
|
---|
250 | BOOLEAN
|
---|
251 | HBufferImageIsAtHighBits (
|
---|
252 | IN UINTN Column,
|
---|
253 | OUT UINTN *FCol
|
---|
254 | );
|
---|
255 |
|
---|
256 | /**
|
---|
257 | Get the size of the open buffer.
|
---|
258 |
|
---|
259 | @retval The size in bytes.
|
---|
260 | **/
|
---|
261 | UINTN
|
---|
262 | HBufferImageGetTotalSize (
|
---|
263 | VOID
|
---|
264 | );
|
---|
265 |
|
---|
266 | #endif
|
---|