Class TCustomMPHexEditor
Unit
MPHexEditor
Declaration
type TCustomMPHexEditor = class(TCustomGrid)
Description
protected ancestor of the hex editor componentsMethods
Overview
 | procedure AddSelectionUndo(const AStart, ACount: integer); |
 | procedure AdjustMetrics; |
 | procedure AppendBuffer(aBuffer: PChar; const aSize: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = True); |
 | procedure BookmarkChanged; virtual; |
 | function BufferFromFile(const aPos: integer; var aCount: integer): PChar; |
 | procedure Changed; virtual; |
 | procedure CombineUndo(const aCount: integer; const sDesc: string = ''); |
 | procedure ConvertRange(const aFrom, aTo: integer; const aTransFrom, aTransTo: TMPHTranslationKind; const UndoDesc: string = ''); |
 | procedure CreateEmptyFile(const TempName: string); |
 | procedure DefineProperties(Filer: TFiler); override; |
 | function DeleteNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean; |
 | procedure DeleteSelection(const UndoDesc: string = ''); |
 | function DisplayEnd: integer; |
 | function DisplayStart: integer; |
 | procedure DoSetCellWidth(const Index: integer; Value: integer); |
 | function DropPosition: integer; |
 | function Find(aBuffer: PChar; aCount: integer; const aStart, aEnd: integer; const IgnoreCase: boolean): integer; |
 | function FindWithWildcard(aBuffer: PChar; aCount: integer; const aStart, aEnd: integer; const IgnoreCase: boolean; const Wildcard: char): integer; |
 | function GetAnyOffsetString(const Position: integer): string; virtual; |
 | function GetCursorPos: integer; |
 | function GetDataSize: integer; |
 | function GetOffsetString(const Position: cardinal): string; virtual; |
 | function GetSelectionAsHex: string; |
 | function GetSelectionAsText: string; |
 | function GetTopLeftPosition(var oInCharField: boolean): integer; |
 | function GotoBookmark(const Index: integer): boolean; |
 | procedure HideDragCell; |
 | procedure InsertBuffer(aBuffer: PChar; const aSize, aPos: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = True); |
 | function InsertNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean; |
 | function IsSelected(const APosition: integer): boolean; |
 | procedure LoadFromFile(const Filename: string); |
 | procedure LoadFromStream(Strm: TStream); |
 | procedure OldCursor; |
 | function PrepareFindReplaceData(StrData: string; const IgnoreCase, IsText: boolean): string; |
 | procedure PrepareOverwriteDiskFile; virtual; |
 | procedure ReadBuffer(var Buffer; const Index, Count: Integer); |
 | procedure ReadMaskChar(Reader: TReader); |
 | procedure ReadMaskChar_I(Reader: TReader); |
 | function Redo: boolean; |
 | function Replace(aBuffer: PChar; aPosition, aOldCount, aNewCount: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = False): integer; |
 | procedure ReplaceSelection(aBuffer: PChar; aSize: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = True); |
 | procedure ResetSelection(const aDraw: boolean); |
 | procedure ResetUndo; |
 | function RowHeight: integer; |
 | procedure SaveRangeToStream(Strm: TStream; const APosition, ACount: integer); |
 | procedure SaveToFile(const Filename: string; const aUnModify: boolean = True); |
 | procedure SaveToStream(Strm: TStream); |
 | function Seek(const aOffset, aOrigin: integer): integer; |
 | procedure SeekToEOF; |
 | procedure SelectAll; |
 | procedure SetSelectionAsHex(const s: string); |
 | procedure SetSelectionAsText(const s: string); |
 | procedure SetTopLeftPosition(const aPosition: integer; const aInCharField: boolean); |
 | function ShowDragCell(const X, Y: integer): integer; |
 | procedure Stream2Stream(strFrom, strTo: TStream; const Operation: TMPHProgressKind; const Count: integer = -1); |
 | procedure SyncView(Source: TCustomMPHexEditor; SyncOffset: integer = 0); |
 | function TranslateFromAnsiChar(const aByte: byte): char; |
 | function TranslateToAnsiChar(const aByte: byte): char; |
 | function Undo: boolean; |
 | function UndoBeginUpdate: integer; virtual; |
 | function UndoEndUpdate: integer; virtual; |
 | procedure UpdateGetOffsetText; |
 | procedure WaitCursor; |
 | procedure WriteBuffer(const Buffer; const Index, Count: Integer); virtual; |
 | procedure WriteMaskChar_I(Writer: TWriter); |
Description
store a selection as undo record, so you can restore the selection start and end by using Undo
. this can be useful e.g. to show position of replaced data
adjust cell widths/heigths depending on font, offset format, bytes per row/column...
append some data at the end of the data buffer
fire OnBookmarkChanged
returns a buffer containing parts of the data buffer's contents. the buffer is allocated in this routine and must be freed by the caller
call changed on every undo creation for OnChange event
combine two or more changes, so Undo
will discard the at once
convert a part of the data buffer's content from one character table to a different one
empty the data buffer and set the filename (e.g. "Untitled")
delete 4 bits (=half byte = nibble) from the data buffer (see also InsertNibble
)
delete the currently selected data
return the offset of the last displayed data
return the offset of the first displayed data
returns the drop file position after a drag'n'drop operation
searches for text or data in the data buffer, returns the find position (-1, if data have not been found):
- aBuffer: data to search for
- aCount: size of data in aBuffer
- aStart: start search at this position
- aEnd: searches up to this position
- IgnoreCase: if True, lowercase and uppercase characters are treated as if they were equal
- SearchText: if True, the current Translation
is taken into account when searching textual data
NOTE: call PrepareFindReplaceData
before the first Find call
searches for text or data in the data buffer using a wildcard character returns the find position (-1, if data have not been found):
- aBuffer: data to search for
- aCount: size of data in aBuffer
- aStart: start search at this position
- aEnd: searches up to this position
- IgnoreCase: if True, lowercase and uppercase characters are treated as if they were equal
- SearchText: if True, the current Translation
is taken into account when searching textual data
- Wildcard: this character is a placeholder for any character
NOTE: call PrepareFindReplaceData
before the first FindWithWildcard call
returns the given position as it would be drawn in the offset gutter, exception: if OffsetFormat
is set to an empty string, returns the hexadecimal representation of the Position value (see also GetOffsetString
)
get the current data position (depending on the cursor/caret)
get the size of the contained data
returns the given position as it would be drawn in the offset gutter, see also OffsetFormat
returns the current selection in hex format ('00010203...') as string, uses SwapNibbles
returns a string containing the currently selected data
returns the data position of the top left cell and also whether the caret is in the character pane, see also SetTopLeftPosition
call this procedure to navigate to a bookmarked position
hide the drop position marker (see also ShowDragCell
)
insert some data at the specified position into the data buffer
insert 4 bits (0000) into the data buffer (see also DeleteNibble
)
is the given position part of the selection?
load the contents of a file into the data buffer
load the contents of a stream into the data buffer
reset the Cursor to the previous value (see also WaitCursor
)
allows descendants to take special action if contents are to be saved to the file from where the data was load
read data into a buffer
discard the last undo action (only one single redo is possible)
replace some amount of data
replace the currently selected data with some other data
remove selection state from all data
free the undo storage (discard all possible undo steps)
returns the height of one row in pixels
save a range of bytes to a stream
save the contents of the data buffer to a file
save the contents of the data buffer into a stream
set the current position (like TStream.Seek)
seek behind the last position if InsertMode
= True, goto last position otherwise
select all data
replace the current selection by a string containing data in hex format ('00 01 02 03' or similar), uses SwapNibbles
replaces the currently selected data with the string's contents
set top left cell to the given data position and also whether the caret is in the character pane (see also GetTopLeftPosition
)
show a drop position marker on the cell at the given mouse cursor position (see also HideDragCell
)
copy a stream to a second one and fire the OnProgress handler
synchronize another TCustomMPHexEditor view (top, left, selection), the optional SyncOffset parameter may be used for a different viewpoint
translate a byte from Windows Codepage to the current Translation
(see also TranslateToAnsiChar
)
translate a byte from the current Translation
to the Windows Codepage (see also TranslateFromAnsiChar
)
undo the last modification, multiple undos are possible
each call to UndoBeginUpdate increments an internal counter that prevents using undo storage and also disables undo functionality (see also UndoEndUpdate
)
each call to UndoEndUpdate decrements an internal counter that prevents using undo storage and also disables undo functionality. the return value is the value of this counter. if the counter is reset to zero, undo creation is permitted again (see also UndoBeginUpdate
)
call this function if the external offset formatting changed (see OnGetOffsetText
)
store the current Cursor and set it to crHourGlass (see also OldCursor
)
write a buffer to the file data
Properties
Overview
Description
if set to False, switching between overwrite and insert mode is not allowed (see also InsertMode
and NoSizeChange
)
retrieve or set the data as hex formatted string (00 01 02 03...)
retrieve or set the data as string
retrieve or set bookmarks programmatically (see also TMPHBookmark
)
bitmap containing 20 10x10 pixels pictures for bokkmarks (they are displayed in the offset gutter), the first ten pictures represent the bookmarks 0(10)..9, if they are set in the hexpane, the last 10 pics are shown if bookmarks are set in the character pane (see also TMPHBookmark
)
has the byte at the given position been modified ? (only in overwrite mode)
how many bytes form one block in a row? blocks are separated by a one character wide blank. -1 means no block separation (see also SeparateBlocksInCharField
)
number of bytes to show in each column
number of bytes to show in each row
setting this property changes the way how mouse/keyboard selection works:
e.g. if set to two, two bytes will be treated as a unit, that means you cannot select a single byte, only two, four, six... bytes can be selected. also drag/drop and clipboard pasting is affected (data size is always a multiple of BytesPerUnit). See also RulerBytesPerUnit
is Redo
possible?
is Undo
possible?
the control's canvas
look of the editor's caret (see TMPHCaretKind
)
current column (grid column)
retrieves the number of columns (grid columns)
colors to display (see TMPHColors
)
get the data value at the current caret position, returns -1 if an error occured
array to the data buffer's content
tells which value to use to fill the new data
during OnDrawCell event handlers, this property tells the data position currently being drawn (-1, if offset or ruler are drawn)
if set to True, a grid is drawn
if set to True, a 3d line is drawn at the right of the offset gutter
name of the file that has been loaded into the data buffer
if set to True, the find* routines also fire OnProgress events (default is False)
precompiled character comparison table for custom find routines, see also FindTableI
, OnFind
, OnWildcardFind
, case sensitive, not public under BCB!
precompiled character comparison table for custom find routines, see also FindTable
, OnFind
, OnWildcardFind
, case insensitive, not public under BCB!
if FocusFrame is set to True, the current caret position will be displayed in the second field (hex - characters) as a dotted focus frame, if set to False, it will be shown as an ordinary rectangle
if set to True and HideSelection
is False, then the current selection will be grayed when the hex editor looses focus (the values from the Colors
property will be converted to grayscale colors)
width of the offset display gutter, if set to -1, automatically adjust the gutter's width
has data been load from/saved to a file (or is the filename valid)
if set to True, hex data and hex offsets are displayed in lower case
hide the current selection when the hex editor looses focus (see also GraySelectionIfNotFocused
)
is the caret in the character or the hex pane ?
insert mode (typed characters are inserted at the current position) or overwrite mode (typed characters replace values at the current position), see also AllowInsertMode
, NoSizeChange
and ReadOnlyView
is the given col in the hex or the character pane?
during OnDrawCell event handlers, this property tells whether the cell is to be draw in selected style (only valid if DrawDataPosition <> -1)
this property is valid only in the OnGetOffsetText
event. if True, the component asks for the string of the highest possible offset, if False, a row's offset text is queried
first visible column
replace whitespaces (#0..#31) with the following character in the character pane
maximum memory that is used for undo storage (in bytes, approximately)
if True, changes have been made to the data buffer content
returns True if the mouse cursor is positionned over selected data
if set to True, the data size is readonly, e.g. no data may be appended, deleted or inserted, just overwriting is allowed. this also affects InsertMode
.
offset display ("line numbers") format, in the form
[r|c|<HEXNUM>%][-|<HEXNUM>!]<HEXNUM>:[Prefix]|[Suffix]
(<HEXNUM> means a number in hexadecimal format (without prefix/suffix))
- first field (up to the percent sign):
- sets the "bytes per unit field" of the offset display format
- if it's set to 1, each row offset displays the data position in bytes
- if it's set to 2, each row offset displays the data position in words
- if it's set to 4, each row offset displays the data position in dwords
- if it's set to "r", each row offset displays the current row number (1st row=0, see also
BytesPerRow
) - if it's set to "c", each row offset displays the current column number (1st column=0, see also
BytesPerColumn
) - if this field is omitted, bytes per unit is set to the value of the
RulerBytesPerUnit
property
- second field (up to the exclamation mark):
- sets the minimum width of the number part, if the number is shorter, it will be padded by '0' chars at the left
- if this field reads -!, the the minimum width is automatically set to the longest number that can appear in the editor (the data's size)
- if this field is omitted, the minimum width is set to 1
- third field (up to the colon):
- sets the radix (base) of the offset format in hex notation
- set this to '10' (without quotes) for hexadecimal offset display, set it to '08' for octal and to '0a' for decimal offset display
- this field cannot be omitted, but the whole format string my be blank to avoid the display of offset identifiers
- fourth field (up to the pipe ('|') char):
- the prefix that is put in front of the "number" string (e.g. '0x' or '$' to show that numbers are in hex format)
- this field may be omitted (but not the pipe char!)
- fifth (and last) field:
- the suffix to put after the "number string" (e.g. 'h' to show hex numbers)
- this field may be omitted
this event is fired when a bookmark is added/modifed/removed
this event is called on every data change (load/empty/undo/redo)
use this event to implement owner drawing. see also TMPHDrawCellEvent
see also OnWildcardFind
if this handler is assigned, the OffsetFormat
is not used to create "line numbers", but the application tells the editor how to format the offset text
this event is fired if an invalid character has been typed (like non-hex characters in the hex pane)
this event is called in LoadFromFile
, SaveToFile
, Find
and FindWithWildcard
routines, so a progress indicator may be updated (see also TMPHProgressEvent
, FindProgress
)
this event is fired when the selection/caret position has changed
this event is fired if the first visible row or column have been changed (e.g. on scrolling)
to this handler, see also OnFind
calculate a data position from a col/row pair
if True, the currently loaded file cannot be overwritten
if set to True, the data can not be edited, just cursor movement is allowed ("Hex Viewer" mode)
current row (grid row)
retrieves the number of rows (grid rows)
setting this property affects the offset/ruler drawing:
e.g. if set to two, two bytes will be treated as a unit, that means the offset and ruler values will step by one each two bytes. if this property is set to -1, it will use the value of the BytesPerUnit
property
number base (i.e. radix) for the ruler display (2-16), tells the component which number format to use when drawing the ruler
retrieve the size of the selected data
see GetSelectionAsHex
and SetSelectionAsHex
see GetSelectionAsText
and SetSelectionAsText
retrieve or set the selection end
retrieve or set the selection start
if BytesPerBlock
is used, this property tells the editor whether it should separate blocks of bytes in the character pane too or not
enlarges the stream
mark the current position even if the editor is not focused
if set to True, a ruler is shown above the first row
if SwapNibbles is set to True, the hex pane will show all bytes in the order lower 4 bits-higher 4 bits (i.e. the value 192 dec = C0 hex will be drawn as 0C). if set to False, hex values will be displayed in usual order. this setting also affects hex data input and hex-string conversions
first visible row (grid row)
translation kind of the data (used to show characters on and to handle key presses in the char pane), (see also TMPHTranslationKind
)
description of the next Undo
action
if set to True, big endian unicode mode is used if UnicodeChars
is enabled
if set to True, the character pane displays unicode characters and the BytesPerUnit
property is set to 2. Translation
is set to tkAsIs. BytesPerRow
and BytesPerColumn
must be a multiple of two to be able to use the unicode mode. see also UnicodeBigEndian
current version of the hex editor component (returns the build data), readonly
retrieves the number of visible columns
retrieves the number of visible rows
if set to True, the Tab key is used to switch the caret between hex and character pane. if set to False, the Tab key can be used to switch between controls. then the combination CTRL+T is used to switch the panes
Generated by DIPasDoc 0.8.7 on Di 15. Jun 2004 20:02:30