BufferImage.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /** @file
  2. Defines BufferImage - the view of the file that is visible at any point,
  3. as well as the event handlers for editing the file
  4. Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _LIB_BUFFER_IMAGE_H_
  8. #define _LIB_BUFFER_IMAGE_H_
  9. #include "HexEditor.h"
  10. /**
  11. Initialization function for HBufferImage
  12. @retval EFI_SUCCESS The operation was successful.
  13. @retval EFI_LOAD_ERROR A load error occurred.
  14. **/
  15. EFI_STATUS
  16. HBufferImageInit (
  17. VOID
  18. );
  19. /**
  20. Cleanup function for HBufferImage
  21. @retval EFI_SUCCESS The operation was successful.
  22. **/
  23. EFI_STATUS
  24. HBufferImageCleanup (
  25. VOID
  26. );
  27. /**
  28. Refresh function for HBufferImage.
  29. @retval EFI_SUCCESS The operation was successful.
  30. @retval EFI_LOAD_ERROR A Load error occurred.
  31. **/
  32. EFI_STATUS
  33. HBufferImageRefresh (
  34. VOID
  35. );
  36. /**
  37. Dispatch input to different handler
  38. @param[in] Key The input key:
  39. the keys can be:
  40. ASCII KEY
  41. Backspace/Delete
  42. Direction key: up/down/left/right/pgup/pgdn
  43. Home/End
  44. INS
  45. @retval EFI_SUCCESS The operation was successful.
  46. @retval EFI_LOAD_ERROR A load error occurred.
  47. @retval EFI_OUT_OF_RESOURCES A Memory allocation failed.
  48. **/
  49. EFI_STATUS
  50. HBufferImageHandleInput (
  51. IN EFI_INPUT_KEY *Key
  52. );
  53. /**
  54. Backup function for HBufferImage. Only a few fields need to be backup.
  55. This is for making the file buffer refresh as few as possible.
  56. @retval EFI_SUCCESS The operation was successful.
  57. **/
  58. EFI_STATUS
  59. HBufferImageBackup (
  60. VOID
  61. );
  62. /**
  63. Read an image into a buffer friom a source.
  64. @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
  65. @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
  66. @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
  67. @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
  68. @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
  69. @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
  70. @param[in] BufferType The type of buffer to save. IGNORED.
  71. @param[in] Recover TRUE for recovermode, FALSE otherwise.
  72. @return EFI_SUCCESS The operation was successful.
  73. **/
  74. EFI_STATUS
  75. HBufferImageRead (
  76. IN CONST CHAR16 *FileName,
  77. IN CONST CHAR16 *DiskName,
  78. IN UINTN DiskOffset,
  79. IN UINTN DiskSize,
  80. IN UINTN MemOffset,
  81. IN UINTN MemSize,
  82. IN EDIT_FILE_TYPE BufferType,
  83. IN BOOLEAN Recover
  84. );
  85. /**
  86. Save the current image.
  87. @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
  88. @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
  89. @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
  90. @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
  91. @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
  92. @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
  93. @param[in] BufferType The type of buffer to save. IGNORED.
  94. @return EFI_SUCCESS The operation was successful.
  95. **/
  96. EFI_STATUS
  97. HBufferImageSave (
  98. IN CHAR16 *FileName,
  99. IN CHAR16 *DiskName,
  100. IN UINTN DiskOffset,
  101. IN UINTN DiskSize,
  102. IN UINTN MemOffset,
  103. IN UINTN MemSize,
  104. IN EDIT_FILE_TYPE BufferType
  105. );
  106. /**
  107. According to cursor's file position, adjust screen display.
  108. @param[in] NewFilePosRow Row of file position ( start from 1 ).
  109. @param[in] NewFilePosCol Column of file position ( start from 1 ).
  110. @param[in] HighBits Cursor will on high4 bits or low4 bits.
  111. **/
  112. VOID
  113. HBufferImageMovePosition (
  114. IN UINTN NewFilePosRow,
  115. IN UINTN NewFilePosCol,
  116. IN BOOLEAN HighBits
  117. );
  118. /**
  119. Create a new line and append it to the line list.
  120. Fields affected:
  121. NumLines
  122. Lines
  123. @retval NULL create line failed.
  124. @return the line created.
  125. **/
  126. HEFI_EDITOR_LINE *
  127. HBufferImageCreateLine (
  128. VOID
  129. );
  130. /**
  131. Free the current image.
  132. @retval EFI_SUCCESS The operation was successful.
  133. **/
  134. EFI_STATUS
  135. HBufferImageFree (
  136. VOID
  137. );
  138. /**
  139. Delete character from buffer.
  140. @param[in] Pos Position, Pos starting from 0.
  141. @param[in] Count The Count of characters to delete.
  142. @param[out] DeleteBuffer The DeleteBuffer.
  143. @retval EFI_SUCCESS Success
  144. **/
  145. EFI_STATUS
  146. HBufferImageDeleteCharacterFromBuffer (
  147. IN UINTN Pos,
  148. IN UINTN Count,
  149. OUT UINT8 *DeleteBuffer
  150. );
  151. /**
  152. Add character to buffer, add before pos.
  153. @param[in] Pos Position, Pos starting from 0.
  154. @param[in] Count Count of characters to add.
  155. @param[in] AddBuffer Add buffer.
  156. @retval EFI_SUCCESS Success.
  157. **/
  158. EFI_STATUS
  159. HBufferImageAddCharacterToBuffer (
  160. IN UINTN Pos,
  161. IN UINTN Count,
  162. IN UINT8 *AddBuffer
  163. );
  164. /**
  165. Change the raw buffer to a list of lines for the UI.
  166. @param[in] Buffer The pointer to the buffer to fill.
  167. @param[in] Bytes The size of the buffer in bytes.
  168. @retval EFI_SUCCESS The operation was successful.
  169. @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
  170. **/
  171. EFI_STATUS
  172. HBufferImageBufferToList (
  173. IN VOID *Buffer,
  174. IN UINTN Bytes
  175. );
  176. /**
  177. Change the list of lines from the UI to a raw buffer.
  178. @param[in] Buffer The pointer to the buffer to fill.
  179. @param[in] Bytes The size of the buffer in bytes.
  180. @retval EFI_SUCCESS The operation was successful.
  181. **/
  182. EFI_STATUS
  183. HBufferImageListToBuffer (
  184. IN VOID *Buffer,
  185. IN UINTN Bytes
  186. );
  187. /**
  188. Move the mouse in the image buffer.
  189. @param[in] TextX The x-coordinate.
  190. @param[in] TextY The y-coordinate.
  191. **/
  192. VOID
  193. HBufferImageAdjustMousePosition (
  194. IN INT32 TextX,
  195. IN INT32 TextY
  196. );
  197. /**
  198. Function to decide if a column number is stored in the high bits.
  199. @param[in] Column The column to examine.
  200. @param[out] FCol The actual column number.
  201. @retval TRUE The actual column was in high bits and is now in FCol.
  202. @retval FALSE There was not a column number in the high bits.
  203. **/
  204. BOOLEAN
  205. HBufferImageIsAtHighBits (
  206. IN UINTN Column,
  207. OUT UINTN *FCol
  208. );
  209. /**
  210. Get the size of the open buffer.
  211. @retval The size in bytes.
  212. **/
  213. UINTN
  214. HBufferImageGetTotalSize (
  215. VOID
  216. );
  217. #endif