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.
34 Cleanup function for FileBuffer.
36 @retval EFI_SUCCESS The cleanup was successful.
45 Refresh the screen with whats in the buffer.
47 @retval EFI_SUCCESS The refresh was successful.
48 @retval EFI_LOAD_ERROR There was an error finding what to write.
57 Dispatch input to different handler
58 @param[in] Key The input key. One of:
62 Direction key: up/down/left/right/pgup/pgdn
66 @retval EFI_SUCCESS The dispatch was done successfully.
67 @retval EFI_LOAD_ERROR The dispatch was not successful.
68 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
72 FileBufferHandleInput (
73 IN CONST EFI_INPUT_KEY
* Key
77 Backup function for FileBuffer. Only backup the following items:
79 File Name, Type, ReadOnly, Modified
82 This is for making the file buffer refresh as few as possible.
84 @retval EFI_SUCCESS The backup operation was successful.
93 Set the cursor position according to FileBuffer.DisplayPosition.
95 @retval EFI_SUCCESS The operation was successful.
99 FileBufferRestorePosition (
104 Set FileName field in FileBuffer.
106 @param Str The file name to set.
108 @retval EFI_SUCCESS The filename was successfully set.
109 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
110 @retval EFI_INVALID_PARAMETER Str is not a valid filename.
114 FileBufferSetFileName (
119 Read a file from disk into the FileBuffer.
121 @param[in] FileName The filename to read.
122 @param[in] Recover TRUE if is for recover mode, no information printouts.
124 @retval EFI_SUCCESS The load was successful.
125 @retval EFI_LOAD_ERROR The load failed.
126 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
127 @retval EFI_INVALID_PARAMETER FileName is a directory.
132 IN CONST CHAR16
*FileName
,
133 IN CONST BOOLEAN Recover
137 Save lines in FileBuffer to disk
139 @param[in] FileName The file name for writing.
141 @retval EFI_SUCCESS Data was written.
142 @retval EFI_LOAD_ERROR
143 @retval EFI_OUT_OF_RESOURCES There were not enough resources to write the file.
148 CONST CHAR16
*FileName
152 According to cursor's file position, adjust screen display
154 @param[in] NewFilePosRow The row of file position ( start from 1 ).
155 @param[in] NewFilePosCol The column of file position ( start from 1 ).
159 FileBufferMovePosition (
160 IN CONST UINTN NewFilePosRow
,
161 IN CONST UINTN NewFilePosCol
165 Cut current line out and return a pointer to it.
167 @param[out] CutLine Upon a successful return pointer to the pointer to
168 the allocated cut line.
170 @retval EFI_SUCCESS The cut was successful.
171 @retval EFI_NOT_FOUND There was no selection to cut.
172 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
177 OUT EFI_EDITOR_LINE
**CutLine
181 Paste a line into line list.
183 @retval EFI_SUCCESS The paste was successful.
184 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
188 FileBufferPasteLine (
193 Search string from current position on in file
195 @param[in] Str The search string.
196 @param[in] Offset The offset from current position.
198 @retval EFI_SUCCESS The operation was successful.
199 @retval EFI_NOT_FOUND The string Str was not found.
204 IN CONST CHAR16
*Str
,
205 IN CONST UINTN Offset
209 Replace SearchLen characters from current position on with Replace.
211 This will modify the current buffer at the current position.
213 @param[in] Replace The string to replace.
214 @param[in] SearchLen Search string's length.
216 @retval EFI_SUCCESS The operation was successful.
217 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
222 IN CONST CHAR16
*Replace
,
223 IN CONST UINTN SearchLen
227 Search and replace operation.
229 @param[in] SearchStr The string to search for.
230 @param[in] ReplaceStr The string to replace with.
231 @param[in] Offset The column to start at.
235 FileBufferReplaceAll (
236 IN CHAR16
*SearchStr
,
237 IN CHAR16
*ReplaceStr
,
242 Move the mouse cursor position.
244 @param[in] TextX The new x-coordinate.
245 @param[in] TextY The new y-coordinate.
249 FileBufferAdjustMousePosition (
250 IN CONST INT32 TextX
,
255 Set the modified state to TRUE.
259 FileBufferSetModified (