2 Declares filebuffer interface functions.
4 Copyright (c) 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 #ifndef _LIB_FILE_BUFFER_H_
16 #define _LIB_FILE_BUFFER_H_
18 #include "TextEditorTypes.h"
21 Initialization function for FileBuffer.
23 @param EFI_SUCCESS The initialization was successful.
24 @param EFI_LOAD_ERROR A default name could not be created.
25 @param EFI_OUT_OF_RESOURCES A memory allocation failed.
33 Cleanup function for FileBuffer.
35 @retval EFI_SUCCESS The cleanup was successful.
43 Refresh the screen with whats in the buffer.
45 @retval EFI_SUCCESS The refresh was successful.
46 @retval EFI_LOAD_ERROR There was an error finding what to write.
54 Dispatch input to different handler
55 @param[in] Key The input key. One of:
59 Direction key: up/down/left/right/pgup/pgdn
63 @retval EFI_SUCCESS The dispatch was done successfully.
64 @retval EFI_LOAD_ERROR The dispatch was not successful.
65 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
68 FileBufferHandleInput (
69 IN CONST EFI_INPUT_KEY
* Key
73 Backup function for FileBuffer. Only backup the following items:
75 File Name, Type, ReadOnly, Modified
78 This is for making the file buffer refresh as few as possible.
80 @retval EFI_SUCCESS The backup operation was successful.
88 Set the cursor position according to FileBuffer.DisplayPosition.
90 @retval EFI_SUCCESS The operation was successful.
93 FileBufferRestorePosition (
98 Set FileName field in FileBuffer.
100 @param Str The file name to set.
102 @retval EFI_SUCCESS The filename was successfully set.
103 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
104 @retval EFI_INVALID_PARAMETER Str is not a valid filename.
107 FileBufferSetFileName (
112 Read a file from disk into the FileBuffer.
114 @param[in] FileName The filename to read.
115 @param[in] Recover TRUE if is for recover mode, no information printouts.
117 @retval EFI_SUCCESS The load was successful.
118 @retval EFI_LOAD_ERROR The load failed.
119 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
120 @retval EFI_INVALID_PARAMETER FileName is a directory.
124 IN CONST CHAR16
*FileName
,
125 IN CONST BOOLEAN Recover
129 Save lines in FileBuffer to disk
131 @param[in] FileName The file name for writing.
133 @retval EFI_SUCCESS Data was written.
134 @retval EFI_LOAD_ERROR
135 @retval EFI_OUT_OF_RESOURCES There were not enough resources to write the file.
139 CONST CHAR16
*FileName
143 According to cursor's file position, adjust screen display
145 @param[in] NewFilePosRow The row of file position ( start from 1 ).
146 @param[in] NewFilePosCol The column of file position ( start from 1 ).
149 FileBufferMovePosition (
150 IN CONST UINTN NewFilePosRow
,
151 IN CONST UINTN NewFilePosCol
155 Cut current line out and return a pointer to it.
157 @param[out] CutLine Upon a successful return pointer to the pointer to
158 the allocated cut line.
160 @retval EFI_SUCCESS The cut was successful.
161 @retval EFI_NOT_FOUND There was no selection to cut.
162 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
166 OUT EFI_EDITOR_LINE
**CutLine
170 Paste a line into line list.
172 @retval EFI_SUCCESS The paste was successful.
173 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
176 FileBufferPasteLine (
181 Search string from current position on in file
183 @param[in] Str The search string.
184 @param[in] Offset The offset from current position.
186 @retval EFI_SUCCESS The operation was successful.
187 @retval EFI_NOT_FOUND The string Str was not found.
191 IN CONST CHAR16
*Str
,
192 IN CONST UINTN Offset
196 Replace SearchLen characters from current position on with Replace.
198 This will modify the current buffer at the current position.
200 @param[in] Replace The string to replace.
201 @param[in] SearchLen Search string's length.
203 @retval EFI_SUCCESS The operation was successful.
204 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
208 IN CONST CHAR16
*Replace
,
209 IN CONST UINTN SearchLen
213 Search and replace operation.
215 @param[in] SearchStr The string to search for.
216 @param[in] ReplaceStr The string to replace with.
217 @param[in] Offset The column to start at.
220 FileBufferReplaceAll (
221 IN CHAR16
*SearchStr
,
222 IN CHAR16
*ReplaceStr
,
227 Move the mouse cursor position.
229 @param[in] TextX The new x-coordinate.
230 @param[in] TextY The new y-coordinate.
233 FileBufferAdjustMousePosition (
234 IN CONST INT32 TextX
,
239 Set the modified state to TRUE.
242 FileBufferSetModified (