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