Table of Contents

Class HexView

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

An hex viewer and editor View over a Stream

public class HexView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
HexView
Implements
Inherited Members

Remarks

HexView provides a hex editor on top of a seekable Stream with the left side showing an hex dump of the values in the Stream and the right side showing the contents (filtered to non-control sequence ASCII characters).

Users can switch from one side to the other by using the tab key.

To enable editing, set AllowEdits to true. When AllowEdits is true the user can make changes to the hexadecimal values of the Stream. Any changes are tracked in the Edits property (a SortedDictionary<TKey, TValue>) indicating the position where the changes were made and the new values. A convenience method, ApplyEdits(Stream) will apply the edits to the Stream.

Control the first byte shown by setting the DisplayStart property to an offset in the stream.

Constructors

HexView()

Initializes a HexView class using Computed layout.

HexView(Stream)

Initializes a HexView class using Computed layout.

Properties

AllowEdits

Gets or sets whether this HexView allow editing of the Stream of the underlying Stream.

BytesPerLine

The bytes length per line.

CursorPosition

Gets the current cursor position starting at one for both, line and column.

DisplayStart

Sets or gets the offset into the Stream that will displayed at the top of the HexView

Edits

Gets a SortedDictionary<TKey, TValue> describing the edits done to the HexView. Each Key indicates an offset where an edit was made and the Value is the changed byte.

Position

Gets the current character position starting at one, related to the Stream.

Source

Sets or gets the Stream the HexView is operating on; the stream must support seeking ( CanSeek == true).

Methods

ApplyEdits(Stream)

This method applies and edits made to the Stream and resets the contents of the Edits property.

DiscardEdits()

This method discards the edits made to the Stream by resetting the contents of the Edits property.

OnDrawContent(Rectangle)

Draws the view's content, including Subviews.

OnEdited(HexViewEditEventArgs)

Method used to invoke the Edited event passing the KeyValuePair<TKey, TValue>.

OnMouseEvent(MouseEvent)

Called when a mouse event occurs within the view's Viewport.

OnPositionChanged()

Method used to invoke the PositionChanged event passing the HexViewEventArgs arguments.

OnProcessKeyDown(Key)

Low-level API called when the user presses a key, allowing views do things during key down events. This is called from NewKeyDownEvent(Key) after OnInvokingKeyBindings(Key).

PositionCursor()

Positions the cursor in the right position based on the currently focused view in the chain.

Events

Edited

Event to be invoked when an edit is made on the Stream.

PositionChanged

Event to be invoked when the position and cursor position changes.