]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.h
ShellPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Edit / FileBuffer.h
CommitLineData
632820d1 1/** @file\r
2 Declares filebuffer interface functions.\r
3\r
ba0014b9 4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>\r
56ba3746 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
632820d1 6\r
7**/\r
8\r
9#ifndef _LIB_FILE_BUFFER_H_\r
10#define _LIB_FILE_BUFFER_H_\r
11\r
12#include "TextEditorTypes.h"\r
13\r
14/**\r
15 Initialization function for FileBuffer.\r
16\r
17 @param EFI_SUCCESS The initialization was successful.\r
18 @param EFI_LOAD_ERROR A default name could not be created.\r
19 @param EFI_OUT_OF_RESOURCES A memory allocation failed.\r
20**/\r
21EFI_STATUS\r
632820d1 22FileBufferInit (\r
23 VOID\r
24 );\r
25\r
26/**\r
27 Cleanup function for FileBuffer.\r
28\r
29 @retval EFI_SUCCESS The cleanup was successful.\r
30**/\r
31EFI_STATUS\r
632820d1 32FileBufferCleanup (\r
33 VOID\r
34 );\r
35\r
36/**\r
37 Refresh the screen with whats in the buffer.\r
38\r
39 @retval EFI_SUCCESS The refresh was successful.\r
40 @retval EFI_LOAD_ERROR There was an error finding what to write.\r
41**/\r
42EFI_STATUS\r
632820d1 43FileBufferRefresh (\r
44 VOID\r
45 );\r
46\r
ba0014b9 47/**\r
632820d1 48 Dispatch input to different handler\r
49 @param[in] Key The input key. One of:\r
50 ASCII KEY\r
51 Backspace/Delete\r
52 Return\r
53 Direction key: up/down/left/right/pgup/pgdn\r
54 Home/End\r
55 INS\r
56\r
57 @retval EFI_SUCCESS The dispatch was done successfully.\r
58 @retval EFI_LOAD_ERROR The dispatch was not successful.\r
59 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
60**/\r
61EFI_STATUS\r
632820d1 62FileBufferHandleInput (\r
63 IN CONST EFI_INPUT_KEY * Key\r
64 );\r
65\r
66/**\r
67 Backup function for FileBuffer. Only backup the following items:\r
68 Mouse/Cursor position\r
69 File Name, Type, ReadOnly, Modified\r
70 Insert Mode\r
71\r
72 This is for making the file buffer refresh as few as possible.\r
73\r
74 @retval EFI_SUCCESS The backup operation was successful.\r
75**/\r
76EFI_STATUS\r
632820d1 77FileBufferBackup (\r
78 VOID\r
79 );\r
80\r
81/**\r
82 Set the cursor position according to FileBuffer.DisplayPosition.\r
83\r
84 @retval EFI_SUCCESS The operation was successful.\r
85**/\r
86EFI_STATUS\r
632820d1 87FileBufferRestorePosition (\r
88 VOID\r
89 );\r
90\r
91/**\r
92 Set FileName field in FileBuffer.\r
93\r
94 @param Str The file name to set.\r
ba0014b9 95\r
632820d1 96 @retval EFI_SUCCESS The filename was successfully set.\r
97 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
98 @retval EFI_INVALID_PARAMETER Str is not a valid filename.\r
99**/\r
100EFI_STATUS\r
632820d1 101FileBufferSetFileName (\r
102 IN CONST CHAR16 *Str\r
103 );\r
104\r
105/**\r
106 Read a file from disk into the FileBuffer.\r
ba0014b9 107\r
632820d1 108 @param[in] FileName The filename to read.\r
109 @param[in] Recover TRUE if is for recover mode, no information printouts.\r
ba0014b9 110\r
632820d1 111 @retval EFI_SUCCESS The load was successful.\r
112 @retval EFI_LOAD_ERROR The load failed.\r
113 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
114 @retval EFI_INVALID_PARAMETER FileName is a directory.\r
115**/\r
116EFI_STATUS\r
632820d1 117FileBufferRead (\r
118 IN CONST CHAR16 *FileName,\r
119 IN CONST BOOLEAN Recover\r
120 );\r
121\r
122/**\r
123 Save lines in FileBuffer to disk\r
124\r
125 @param[in] FileName The file name for writing.\r
126\r
127 @retval EFI_SUCCESS Data was written.\r
ba0014b9 128 @retval EFI_LOAD_ERROR\r
632820d1 129 @retval EFI_OUT_OF_RESOURCES There were not enough resources to write the file.\r
130**/\r
131EFI_STATUS\r
632820d1 132FileBufferSave (\r
133 CONST CHAR16 *FileName\r
134 );\r
135\r
136/**\r
137 According to cursor's file position, adjust screen display\r
138\r
139 @param[in] NewFilePosRow The row of file position ( start from 1 ).\r
140 @param[in] NewFilePosCol The column of file position ( start from 1 ).\r
141**/\r
142VOID\r
632820d1 143FileBufferMovePosition (\r
144 IN CONST UINTN NewFilePosRow,\r
145 IN CONST UINTN NewFilePosCol\r
146 );\r
147\r
148/**\r
149 Cut current line out and return a pointer to it.\r
150\r
ba0014b9 151 @param[out] CutLine Upon a successful return pointer to the pointer to\r
632820d1 152 the allocated cut line.\r
153\r
154 @retval EFI_SUCCESS The cut was successful.\r
155 @retval EFI_NOT_FOUND There was no selection to cut.\r
156 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
157**/\r
158EFI_STATUS\r
632820d1 159FileBufferCutLine (\r
160 OUT EFI_EDITOR_LINE **CutLine\r
161 );\r
162\r
163/**\r
164 Paste a line into line list.\r
165\r
166 @retval EFI_SUCCESS The paste was successful.\r
167 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
168**/\r
169EFI_STATUS\r
632820d1 170FileBufferPasteLine (\r
171 VOID\r
172 );\r
173\r
174/**\r
175 Search string from current position on in file\r
176\r
177 @param[in] Str The search string.\r
178 @param[in] Offset The offset from current position.\r
179\r
180 @retval EFI_SUCCESS The operation was successful.\r
181 @retval EFI_NOT_FOUND The string Str was not found.\r
182**/\r
183EFI_STATUS\r
632820d1 184FileBufferSearch (\r
185 IN CONST CHAR16 *Str,\r
186 IN CONST UINTN Offset\r
187 );\r
188\r
189/**\r
190 Replace SearchLen characters from current position on with Replace.\r
191\r
192 This will modify the current buffer at the current position.\r
193\r
194 @param[in] Replace The string to replace.\r
195 @param[in] SearchLen Search string's length.\r
196\r
197 @retval EFI_SUCCESS The operation was successful.\r
198 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
199**/\r
200EFI_STATUS\r
632820d1 201FileBufferReplace (\r
202 IN CONST CHAR16 *Replace,\r
203 IN CONST UINTN SearchLen\r
204 );\r
205\r
206/**\r
207 Search and replace operation.\r
208\r
209 @param[in] SearchStr The string to search for.\r
210 @param[in] ReplaceStr The string to replace with.\r
211 @param[in] Offset The column to start at.\r
212**/\r
213EFI_STATUS\r
632820d1 214FileBufferReplaceAll (\r
215 IN CHAR16 *SearchStr,\r
216 IN CHAR16 *ReplaceStr,\r
217 IN UINTN Offset\r
218 );\r
219\r
220/**\r
221 Move the mouse cursor position.\r
222\r
223 @param[in] TextX The new x-coordinate.\r
224 @param[in] TextY The new y-coordinate.\r
225**/\r
226VOID\r
632820d1 227FileBufferAdjustMousePosition (\r
228 IN CONST INT32 TextX,\r
229 IN CONST INT32 TextY\r
230 );\r
231\r
232/**\r
233 Set the modified state to TRUE.\r
234**/\r
235VOID\r
632820d1 236FileBufferSetModified (\r
237 VOID\r
238 );\r
239\r
240#endif\r