2 Declares filebuffer interface functions.
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _LIB_FILE_BUFFER_H_
10 #define _LIB_FILE_BUFFER_H_
12 #include "TextEditorTypes.h"
15 Initialization function for FileBuffer.
17 @param EFI_SUCCESS The initialization was successful.
18 @param EFI_LOAD_ERROR A default name could not be created.
19 @param EFI_OUT_OF_RESOURCES A memory allocation failed.
27 Cleanup function for FileBuffer.
29 @retval EFI_SUCCESS The cleanup was successful.
37 Refresh the screen with whats in the buffer.
39 @retval EFI_SUCCESS The refresh was successful.
40 @retval EFI_LOAD_ERROR There was an error finding what to write.
48 Dispatch input to different handler
49 @param[in] Key The input key. One of:
53 Direction key: up/down/left/right/pgup/pgdn
57 @retval EFI_SUCCESS The dispatch was done successfully.
58 @retval EFI_LOAD_ERROR The dispatch was not successful.
59 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
62 FileBufferHandleInput (
63 IN CONST EFI_INPUT_KEY
*Key
67 Backup function for FileBuffer. Only backup the following items:
69 File Name, Type, ReadOnly, Modified
72 This is for making the file buffer refresh as few as possible.
74 @retval EFI_SUCCESS The backup operation was successful.
82 Set the cursor position according to FileBuffer.DisplayPosition.
84 @retval EFI_SUCCESS The operation was successful.
87 FileBufferRestorePosition (
92 Set FileName field in FileBuffer.
94 @param Str The file name to set.
96 @retval EFI_SUCCESS The filename was successfully set.
97 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
98 @retval EFI_INVALID_PARAMETER Str is not a valid filename.
101 FileBufferSetFileName (
106 Read a file from disk into the FileBuffer.
108 @param[in] FileName The filename to read.
109 @param[in] Recover TRUE if is for recover mode, no information printouts.
111 @retval EFI_SUCCESS The load was successful.
112 @retval EFI_LOAD_ERROR The load failed.
113 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
114 @retval EFI_INVALID_PARAMETER FileName is a directory.
118 IN CONST CHAR16
*FileName
,
119 IN CONST BOOLEAN Recover
123 Save lines in FileBuffer to disk
125 @param[in] FileName The file name for writing.
127 @retval EFI_SUCCESS Data was written.
128 @retval EFI_LOAD_ERROR
129 @retval EFI_OUT_OF_RESOURCES There were not enough resources to write the file.
133 CONST CHAR16
*FileName
137 According to cursor's file position, adjust screen display
139 @param[in] NewFilePosRow The row of file position ( start from 1 ).
140 @param[in] NewFilePosCol The column of file position ( start from 1 ).
143 FileBufferMovePosition (
144 IN CONST UINTN NewFilePosRow
,
145 IN CONST UINTN NewFilePosCol
149 Cut current line out and return a pointer to it.
151 @param[out] CutLine Upon a successful return pointer to the pointer to
152 the allocated cut line.
154 @retval EFI_SUCCESS The cut was successful.
155 @retval EFI_NOT_FOUND There was no selection to cut.
156 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
160 OUT EFI_EDITOR_LINE
**CutLine
164 Paste a line into line list.
166 @retval EFI_SUCCESS The paste was successful.
167 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
170 FileBufferPasteLine (
175 Search string from current position on in file
177 @param[in] Str The search string.
178 @param[in] Offset The offset from current position.
180 @retval EFI_SUCCESS The operation was successful.
181 @retval EFI_NOT_FOUND The string Str was not found.
185 IN CONST CHAR16
*Str
,
186 IN CONST UINTN Offset
190 Replace SearchLen characters from current position on with Replace.
192 This will modify the current buffer at the current position.
194 @param[in] Replace The string to replace.
195 @param[in] SearchLen Search string's length.
197 @retval EFI_SUCCESS The operation was successful.
198 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
202 IN CONST CHAR16
*Replace
,
203 IN CONST UINTN SearchLen
207 Search and replace operation.
209 @param[in] SearchStr The string to search for.
210 @param[in] ReplaceStr The string to replace with.
211 @param[in] Offset The column to start at.
214 FileBufferReplaceAll (
215 IN CHAR16
*SearchStr
,
216 IN CHAR16
*ReplaceStr
,
221 Move the mouse cursor position.
223 @param[in] TextX The new x-coordinate.
224 @param[in] TextY The new y-coordinate.
227 FileBufferAdjustMousePosition (
228 IN CONST INT32 TextX
,
233 Set the modified state to TRUE.
236 FileBufferSetModified (