Units
Classes, Interfaces and Objects
Types
Variables
Constants
Functions and Procedures
Identifiers

Unit MPHexEditor

Description

TMPHexEditor displays and edits hexadecimal/binary files

TMPHexEditor v 10-25-2002
credits to :

- John Hamm, http://users.snapjax.com/john/

- Christophe Le Corfec for introducing the EBCDIC format and the nice idea about half byte insert/delete

- Philippe Chessa for his suggestions about AsText, AsHex and better support for the french keyboard layout

- Daniel Jensen for octal offset display and the INS-key recognition stuff

- Shmuel Zeigerman for introducing more flexible offset display formats

- Vaf, http://carradio.al.ru for reporting missing delver.inc and suggesting OnChange

- Eugene Tarasov for reporting that setting the BytesPerColumn value to 4 at design time didn't work.

history:

Classes, Interfaces and Objects

NameDescription
Class EMPHException custom Exception class
Class TCustomMPHexEditor protected ancestor of the hex editor components
Class TMPHColors persistent color storage (contains the colors in hex editors)
Class TMPHexEditor published hex editor component

Functions and Procedures

Overview

function CheckRadixToInt(Value: string): integer;
function ConvertBinToHex(aFrom, aTo: PChar; const aCount: integer; const SwapNibbles: boolean): PChar;
function ConvertHexToBin(aFrom, aTo: PChar; const aCount: integer; const SwapNibbles: boolean; var BytesTranslated: integer): PChar;
function GetTempName: string;
function GridCoord(aX, aY: longint): TGridCoord;
function IntToOctal(const Value: integer): string;
function IntToRadix(Value: integer; Radix: byte): string;
function IntToRadixLen(Value: integer; Radix, Len: byte): string;
function IsKeyDown(aKey: integer): boolean;
function Max(a1, a2: integer): integer;
function Min(a1, a2: integer): integer;
function OctalToInt(const Value: string): integer;
function RadixToInt(Value: string; Radix: byte): integer;
procedure TranslateBufferFromAnsi(const TType: TMPHTranslationKind; aBuffer, bBuffer: PChar; const aCount: integer);
procedure TranslateBufferToAnsi(const TType: TMPHTranslationKind; aBuffer, bBuffer: PChar; const aCount: integer);

Description

function CheckRadixToInt(Value: string): integer;

try to find the correct radix (based on prefix/suffix) and return the number, known prefixes/suffixes are:
0x<number>, 0X<number>, $<number>, <number>h, <number>H: radix 16
o<number>, O<number>, 0<number>, <number>o, <number>O: radix 8
%<number>, <number>%: radix 2
otherwise: radix 10

function ConvertBinToHex(aFrom, aTo: PChar; const aCount: integer; const SwapNibbles: boolean): PChar;

translate binary data to its hex representation (see ConvertHexToBin), (see SwapNibbles for the meaning of the SwapNibbles value)

function ConvertHexToBin(aFrom, aTo: PChar; const aCount: integer; const SwapNibbles: boolean; var BytesTranslated: integer): PChar;

translate a hexadecimal data representation ("a000 cc45 d3 42"...) to binary data (see SwapNibbles for the meaning of the SwapNibbles value)

function GetTempName: string;

get a unique filename in the temporary directory

function GridCoord(aX, aY: longint): TGridCoord;

convert X and Y into a TGridCoord record

function IntToOctal(const Value: integer): string;

translate an integer to an octal string (see also IntToRadix)

function IntToRadix(Value: integer; Radix: byte): string;

translate an integer to a radix (base) coded string, e.g.
- IntToRadix(100,16) converts into a hexadecimal (number) string
- IntToRadix(100,2) converts into a string consisting only of 0 and 1
- IntToRadix(100,8) means IntToOctal

hint: Radix must be in the range of 2..16

function IntToRadixLen(Value: integer; Radix, Len: byte): string;

translate an integer to a radix coded string and left fill with 0 (see also IntToRadix)

function IsKeyDown(aKey: integer): boolean;

check whether the given key (VK_...) is currently down

function Max(a1, a2: integer): integer;

returns the higer of the two numbers

function Min(a1, a2: integer): integer;

returns the lower of the two numbers

function OctalToInt(const Value: string): integer;

translate an number string built on radix 8 into an integer (see also RadixToInt)

function RadixToInt(Value: string; Radix: byte): integer;

translate a radix coded number string into an integer, e.g.
- RadixToInt('0f', 16) => 15
- RadixToInt('755', 8) => 493

procedure TranslateBufferFromAnsi(const TType: TMPHTranslationKind; aBuffer, bBuffer: PChar; const aCount: integer);

translate data from Ansi to a different character set (see also TMPHTranslationKind)
- TType: translate to this character set
- aBuffer: pointer to source data
- bBuffer: pointer to target data, must be allocated (may equal to aBuffer)
- aCount: number of bytes to translate

procedure TranslateBufferToAnsi(const TType: TMPHTranslationKind; aBuffer, bBuffer: PChar; const aCount: integer);

translate data from a different character set to Ansi (see also TranslateBufferFromAnsi)

Types

NameDescription
TMPHBookmark bookmark record:
defined by pressing SHIFT+CTRL+[0..9], goto bookmark by pressing CTRL+[0..9]

- mPosition: file position
- mInCharField: cursor in character pane (True) or hex number pane
TMPHBookmarks array of bookmarks, representing keys 0..9
TMPHCaretKind look of the editor's caret:
- ckFull: full block
- ckLeft: left line
- ckBottom: bottom line
- ckAuto: left line if InsertMode, full block otherwise
TMPHProgressEvent progress event handler, used in OnLoadSaveProgress

- ProgressType: am i loading or saving? (see TMPHProgressKind)
- aName: name of file to be load from/saved to
- Percent: current progress (0..100)
- Cancel: if set to true, the load/save procedure will abort
TMPHProgressKind action indicator used in OnLoadSaveProgress event handler:
- pkLoad: loading data
- pkSave: saving data
TMPHTranslationKind how to show a file's content in the character pane of the editor:
- tkAsIs: leave as is (current windows code page)
- tkDos8: current dos codepage
- tkASCII: 7 bit ascii
- tkMac: macintosh charset (translation always from/to ms cp 1252 (ms latin1)!!
- tkBCD: ibm ebcdic codepage 38 (translation always from/to ms cp 1252 (ms latin1)!!
- tkCustom: custom codepage stored in MPHCustTransFieldFrom[0..255] and MPHCustTransFieldTo[0..255]

Constants

NameDescription
MPHOffsetDec standard offset format: decimal
MPHOffsetHex standard offset format: hex, auto min width, prefixed by 0x
MPHOffsetOct standard offset format: octal, prefixed by 0 /except of 0 pos
MPHTranslationDesc long descriptions of the different translations (e.g. for menues)
MPHTranslationDescShort short descriptions of the different translations (e.g. for status bars)
MPTH_FILEIO_BLOCKSIZE block size in file i/o
MPTH_TK_ASCII7 tkASCII
MPTH_TK_ASCII7_S tkASCII
MPTH_TK_ASIS tkAsIs
MPTH_TK_ASIS_S tkAsIs
MPTH_TK_BCD38 tkBCD
MPTH_TK_BCD38_S tkBCD
MPTH_TK_CUSTOM tkCustom
MPTH_TK_CUSTOM_S tkCustom
MPTH_TK_DOS8 tkDos8
MPTH_TK_DOS8_S tkDos8
MPTH_TK_MAC tkMac
MPTH_TK_MAC_S tkMac
tblBCD2MSAnsi conversion ebcdic cp 38 .. ms ansi (cp 1252) (taken from recode 3.5)
tblMac2MSAnsi conversion macintosh .. ms ansi (cp 1252) (taken from recode 3.5)
tblMSAnsi2BCD conversion ms ansi (cp 1252) .. ebcdic cp 38 (taken from recode 3.5)
tblMSAnsi2Mac conversion ms ansi (cp 1252) .. macintosh (taken from recode 3.5)
WM_INTUPDATECARET this message is posted to the hex editor when it should update the caret position

Variables

NameDescription
MPHCustTransFieldFrom this table is used in translations from tkAsIs to tkCustom (see TMPHTranslationKind)
MPHCustTransFieldTo this table is used in translations from tkCustom to tkAsIs (see TMPHTranslationKind)

Author

(C) 1997-2002 markus stephany, merkes@mirkes.de, all rights reserved.

Last Modified

10-25-2002


Generated by DIPasDoc 0.8.0 on Fri 25 Oct 2002 15:49:59