2011-03-25 22:15:07 +01:00
|
|
|
/** @file
|
2018-06-27 15:13:38 +02:00
|
|
|
Defines BufferImage - the view of the file that is visible at any point,
|
2011-03-25 22:15:07 +01:00
|
|
|
as well as the event handlers for editing the file
|
2018-06-27 15:13:38 +02:00
|
|
|
|
|
|
|
Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
|
2019-04-04 01:07:06 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2011-03-25 22:15:07 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _LIB_BUFFER_IMAGE_H_
|
|
|
|
#define _LIB_BUFFER_IMAGE_H_
|
|
|
|
|
|
|
|
#include "HexEditor.h"
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Initialization function for HBufferImage
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
2020-08-01 02:52:32 +02:00
|
|
|
@retval EFI_LOAD_ERROR A load error occurred.
|
2011-04-05 22:55:45 +02:00
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageInit (
|
|
|
|
VOID
|
|
|
|
);
|
2011-04-05 22:55:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cleanup function for HBufferImage
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageCleanup (
|
|
|
|
VOID
|
|
|
|
);
|
2011-04-05 22:55:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Refresh function for HBufferImage.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
2020-08-01 02:52:32 +02:00
|
|
|
@retval EFI_LOAD_ERROR A Load error occurred.
|
2011-04-05 22:55:45 +02:00
|
|
|
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageRefresh (
|
|
|
|
VOID
|
|
|
|
);
|
2011-04-05 22:55:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Dispatch input to different handler
|
|
|
|
|
|
|
|
@param[in] Key The input key:
|
|
|
|
the keys can be:
|
|
|
|
ASCII KEY
|
|
|
|
Backspace/Delete
|
|
|
|
Direction key: up/down/left/right/pgup/pgdn
|
|
|
|
Home/End
|
|
|
|
INS
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
2020-08-01 02:52:32 +02:00
|
|
|
@retval EFI_LOAD_ERROR A load error occurred.
|
2011-04-05 22:55:45 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES A Memory allocation failed.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageHandleInput (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN EFI_INPUT_KEY *Key
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
2011-04-05 22:55:45 +02:00
|
|
|
|
|
|
|
/**
|
2018-06-27 15:13:38 +02:00
|
|
|
Backup function for HBufferImage. Only a few fields need to be backup.
|
2011-04-05 22:55:45 +02:00
|
|
|
This is for making the file buffer refresh as few as possible.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageBackup (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Read an image into a buffer friom a source.
|
|
|
|
|
|
|
|
@param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
|
|
|
|
@param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
|
|
|
@param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
|
|
|
@param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
|
|
|
@param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
|
|
|
|
@param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
|
|
|
|
@param[in] BufferType The type of buffer to save. IGNORED.
|
|
|
|
@param[in] Recover TRUE for recovermode, FALSE otherwise.
|
|
|
|
|
|
|
|
@return EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageRead (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN CONST CHAR16 *FileName,
|
|
|
|
IN CONST CHAR16 *DiskName,
|
|
|
|
IN UINTN DiskOffset,
|
|
|
|
IN UINTN DiskSize,
|
|
|
|
IN UINTN MemOffset,
|
|
|
|
IN UINTN MemSize,
|
|
|
|
IN EDIT_FILE_TYPE BufferType,
|
|
|
|
IN BOOLEAN Recover
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Save the current image.
|
2011-03-25 22:15:07 +01:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
@param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
|
|
|
|
@param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
|
|
|
@param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
|
|
|
@param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
|
|
|
|
@param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
|
|
|
|
@param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
|
|
|
|
@param[in] BufferType The type of buffer to save. IGNORED.
|
2011-03-25 22:15:07 +01:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
@return EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
2011-04-05 22:55:45 +02:00
|
|
|
HBufferImageSave (
|
|
|
|
IN CHAR16 *FileName,
|
|
|
|
IN CHAR16 *DiskName,
|
|
|
|
IN UINTN DiskOffset,
|
|
|
|
IN UINTN DiskSize,
|
|
|
|
IN UINTN MemOffset,
|
|
|
|
IN UINTN MemSize,
|
|
|
|
IN EDIT_FILE_TYPE BufferType
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
According to cursor's file position, adjust screen display.
|
|
|
|
|
|
|
|
@param[in] NewFilePosRow Row of file position ( start from 1 ).
|
|
|
|
@param[in] NewFilePosCol Column of file position ( start from 1 ).
|
|
|
|
@param[in] HighBits Cursor will on high4 bits or low4 bits.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
VOID
|
|
|
|
HBufferImageMovePosition (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN UINTN NewFilePosRow,
|
|
|
|
IN UINTN NewFilePosCol,
|
|
|
|
IN BOOLEAN HighBits
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Create a new line and append it to the line list.
|
|
|
|
Fields affected:
|
|
|
|
NumLines
|
2018-06-27 15:13:38 +02:00
|
|
|
Lines
|
2011-03-25 22:15:07 +01:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
@retval NULL create line failed.
|
|
|
|
@return the line created.
|
2011-03-25 22:15:07 +01:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
**/
|
|
|
|
HEFI_EDITOR_LINE *
|
|
|
|
HBufferImageCreateLine (
|
2011-03-25 22:15:07 +01:00
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
2011-04-02 00:16:01 +02:00
|
|
|
Free the current image.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageFree (
|
|
|
|
VOID
|
2011-04-02 00:16:01 +02:00
|
|
|
);
|
2011-03-25 22:15:07 +01:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Delete character from buffer.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
@param[in] Pos Position, Pos starting from 0.
|
|
|
|
@param[in] Count The Count of characters to delete.
|
|
|
|
@param[out] DeleteBuffer The DeleteBuffer.
|
|
|
|
|
2018-06-27 15:13:38 +02:00
|
|
|
@retval EFI_SUCCESS Success
|
2011-04-05 22:55:45 +02:00
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageDeleteCharacterFromBuffer (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN UINTN Pos,
|
|
|
|
IN UINTN Count,
|
|
|
|
OUT UINT8 *DeleteBuffer
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Add character to buffer, add before pos.
|
|
|
|
|
|
|
|
@param[in] Pos Position, Pos starting from 0.
|
|
|
|
@param[in] Count Count of characters to add.
|
|
|
|
@param[in] AddBuffer Add buffer.
|
|
|
|
|
2018-06-27 15:13:38 +02:00
|
|
|
@retval EFI_SUCCESS Success.
|
2011-04-05 22:55:45 +02:00
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageAddCharacterToBuffer (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN UINTN Pos,
|
|
|
|
IN UINTN Count,
|
|
|
|
IN UINT8 *AddBuffer
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Change the raw buffer to a list of lines for the UI.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
@param[in] Buffer The pointer to the buffer to fill.
|
|
|
|
@param[in] Bytes The size of the buffer in bytes.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageBufferToList (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN VOID *Buffer,
|
|
|
|
IN UINTN Bytes
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Change the list of lines from the UI to a raw buffer.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
@param[in] Buffer The pointer to the buffer to fill.
|
|
|
|
@param[in] Bytes The size of the buffer in bytes.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
EFI_STATUS
|
|
|
|
HBufferImageListToBuffer (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN VOID *Buffer,
|
|
|
|
IN UINTN Bytes
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Move the mouse in the image buffer.
|
|
|
|
|
|
|
|
@param[in] TextX The x-coordinate.
|
|
|
|
@param[in] TextY The y-coordinate.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
VOID
|
|
|
|
HBufferImageAdjustMousePosition (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN INT32 TextX,
|
|
|
|
IN INT32 TextY
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Function to decide if a column number is stored in the high bits.
|
|
|
|
|
|
|
|
@param[in] Column The column to examine.
|
|
|
|
@param[out] FCol The actual column number.
|
|
|
|
|
|
|
|
@retval TRUE The actual column was in high bits and is now in FCol.
|
|
|
|
@retval FALSE There was not a column number in the high bits.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
BOOLEAN
|
|
|
|
HBufferImageIsAtHighBits (
|
2011-04-05 22:55:45 +02:00
|
|
|
IN UINTN Column,
|
|
|
|
OUT UINTN *FCol
|
2011-03-25 22:15:07 +01:00
|
|
|
);
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
/**
|
|
|
|
Get the size of the open buffer.
|
|
|
|
|
|
|
|
@retval The size in bytes.
|
|
|
|
**/
|
2011-03-25 22:15:07 +01:00
|
|
|
UINTN
|
|
|
|
HBufferImageGetTotalSize (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|