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.

DesiredCursorVisibility

Get / Set the wished cursor when the field is focused

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.

Frame

Gets or sets the frame for the view. The frame is relative to the view's container (SuperView).

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.

MouseEvent(MouseEvent)

Method invoked when a mouse event is generated

OnEdited(KeyValuePair<long, byte>)

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

OnEnter(View)

Method invoked when a view gets focus.

OnPositionChanged()

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

PositionCursor()

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

ProcessKey(KeyEvent)

If the view is focused, gives the view a chance to process the keystroke.

Redraw(Rect)

Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.

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.