.texxd

texxd - A hex editor built with Textual.

.texxd.hex_editor

Hex editor widget.

HexEditor Objects

class HexEditor(Static)

A hex editor widget.

compose

def compose() -> ComposeResult

Compose the hex editor layout.

open

def open(file_path: Path) -> None

Open a file for hex editing.

.texxd.highlighters.highlights

Composite highlighter that manages multiple highlighters in order.

Highlights Objects

class Highlights(dict, Highlighter)

A composite highlighter that manages multiple highlighters in insertion order.

Acts as both a dict (for managing highlighters by name) and a Highlighter (for applying all highlighters in order).

highlight

def highlight(data: bytes, file_offset: int,
              styles: List[Optional[Style]]) -> None

Apply all highlighters in insertion order.

.texxd.highlighters

Highlighter implementations for hex editor.

.texxd.highlighters.highlighter

Highlighter interface for styling bytes in hex editor.

Highlighter Objects

class Highlighter()

A highlighter takes a block of bytes with their file offset and current styles, then modifies the styles array to apply highlighting effects.

highlight

def highlight(data: bytes, file_offset: int,
              styles: List[Optional[Style]]) -> None

Apply highlighting to the styles array.

Arguments:

.texxd.highlighters.data

Data-based highlighter for different byte types and data formats.

DataHighlighter Objects

class DataHighlighter(Highlighter)

Highlights bytes based on data types and content.

highlight

def highlight(data: bytes, file_offset: int,
              styles: List[Optional[Style]]) -> None

Apply highlighting based on byte values.

.texxd.cursors

Cursor types for hex editor interaction.

.texxd.cursors.cursor

Base cursor class for hex editor navigation and highlighting.

CursorMoved Objects

class CursorMoved(Message)

Message sent when cursor position changes.

ScrollRequest Objects

class ScrollRequest(Message)

Message sent to request scrolling to a specific line.

Cursor Objects

class Cursor(Highlighter, Widget)

Base cursor class that handles navigation and provides highlighting.

A cursor is a special highlighter that:

__init__

def __init__(bytes_per_line: int = 16,
             view_height: int = 10,
             parent_column=None,
             name: Optional[str] = None,
             id: Optional[str] = None,
             classes: Optional[str] = None,
             disabled: bool = False)

Initialize cursor.

Arguments:

file_size

@property
def file_size() -> int

Get current file size from parent column.

view_height

@property
def view_height() -> int

Get current view height from hex view.

x

@property
def x() -> int

Get x coordinate (column within line).

y

@property
def y() -> int

Get y coordinate (line number).

highlight

def highlight(data: bytes, file_offset: int,
              styles: List[Optional[Style]]) -> None

Apply cursor highlighting to the styles array.

handle_event

def handle_event(event: events.Event) -> bool

Handle navigation events.

Arguments:

Returns:

True if the event was handled, False otherwise

move_x

def move_x(delta: int) -> None

Move cursor horizontally with wrapping.

move_y

def move_y(delta: int) -> None

Move cursor vertically, preserving x position.

set_x

def set_x(x: int) -> None

Set x coordinate (column within line).

set_y

def set_y(y: int) -> None

Set y coordinate (line number), preserving x position.

on_focus

def on_focus() -> None

Called when cursor gains focus.

on_blur

def on_blur() -> None

Called when cursor loses focus.

.texxd.cursors.hex_cursor

Hex cursor class for hex editing.

HexCursor Objects

class HexCursor(Cursor)

Hex cursor that handles hex input and delegates writing to the file class.

handle_event

def handle_event(event: events.Event) -> bool

Handle hex editing events.

.texxd.cursors.ascii_cursor

ASCII cursor class for ASCII editing.

AsciiCursor Objects

class AsciiCursor(Cursor)

ASCII cursor that handles ASCII input and delegates writing to the file class.

handle_event

def handle_event(event: events.Event) -> bool

Handle ASCII editing events.

.texxd.log

setup_logging

def setup_logging(log_level: str = "INFO",
                  log_file: Optional[Path] = None) -> None

Setup logging configuration.

Arguments:

get_logger

def get_logger(name: str) -> logging.Logger

Get a logger instance.

.texxd.app

Main application for texxd hex editor.

TexxdApp Objects

class TexxdApp(App)

A hex editor application built with Textual.

compose

def compose() -> ComposeResult

Compose the application layout.

on_mount

def on_mount() -> None

Handle mount event.

action_quit

def action_quit() -> None

Quit the application.

action_save

def action_save() -> None

Save the current file.

main

def main() -> None

Main entry point for the application.

.texxd.hex_file

File-like object with memory view and write buffer overlay.

HexFile Objects

class HexFile(RawIOBase, Highlighter)

A file-like object that wraps a file with memory view and write buffer.

size

@property
def size() -> int

Get the current size of the file including unsaved changes.

tell

def tell() -> int

Get current position.

seek

def seek(offset: int, whence: int = 0) -> int

Seek to position.

readable

def readable() -> bool

Return True if the stream can be read from.

readinto

def readinto(b: bytearray) -> int

Read bytes into a pre-allocated bytearray.

read

def read(size: int = -1) -> bytes

Read bytes from current position.

writable

def writable() -> bool

Return True if the stream can be written to.

write

def write(data: bytes) -> int

Write bytes to buffer at current position.

has_unsaved_changes

def has_unsaved_changes() -> bool

Check if there are unsaved changes.

get_unsaved_ranges

def get_unsaved_ranges() -> list[Tuple[int, int]]

Get list of (start, end) tuples for unsaved byte ranges.

highlight

def highlight(data: bytes, file_offset: int,
              styles: List[Optional[Style]]) -> None

Apply edit highlighting to the styles array.

flush

def flush() -> None

Flush all changes to the underlying file.

revert

def revert() -> None

Discard all unsaved changes.

close

def close() -> None

Close the underlying file.

.texxd.columns

Column types for hex editor display.

.texxd.columns.ascii

ASCII column widget for displaying data in ASCII format.

AsciiColumn Objects

class AsciiColumn(Column)

Widget that displays data in ASCII format.

get_content_width

def get_content_width() -> int

Calculate content width.

render_line

def render_line(y: int) -> Strip

Render a line of ASCII data.

calculate_click_position

def calculate_click_position(click_offset: int) -> Optional[int]

Calculate byte position within ASCII column from click offset.

on_key

def on_key(event: events.Key) -> bool

Handle key events for the column.

get_byte_position

def get_byte_position(x: int, y: int) -> Optional[int]

Get byte position from column coordinates.

.texxd.columns.column

Base class for all columns.

Column Objects

class Column(Static)

Base class for all columns.

add_highlighter

def add_highlighter(name: str, highlighter: Highlighter) -> None

Add a highlighter to this column with a name.

get_content_width

def get_content_width() -> int

Get the width of the column’s content.

render_line

def render_line(y: int) -> Strip

Render a single line of the column.

on_key

def on_key(event: events.Key) -> bool

Handle key events for the column.

Arguments:

Returns:

True if the event was handled, False otherwise.

.texxd.columns.hex

Hex column widget for displaying data in hexadecimal format.

HexColumn Objects

class HexColumn(Column)

Widget that displays data in hexadecimal format.

get_content_width

def get_content_width() -> int

Calculate content width.

render_line

def render_line(y: int) -> Strip

Render a line of hex data.

calculate_click_position

def calculate_click_position(click_offset: int) -> Optional[int]

Calculate byte position within hex column from click offset.

on_key

def on_key(event: events.Key) -> bool

Handle key events for the column.

get_byte_position

def get_byte_position(x: int, y: int) -> Optional[int]

Get byte position from column coordinates.

.texxd.columns.address

Address column widget for displaying file offsets.

AddressColumn Objects

class AddressColumn(Column)

Widget that displays file offset addresses.

get_content_width

def get_content_width() -> int

Calculate content width based on file size.

render_line

def render_line(y: int) -> Strip

Render a line of addresses.

.texxd.hex_view

Hex view widget using Textual widget-based columns.

HexView Objects

class HexView(ScrollView)

A widget that displays binary data using widget-based columns.

compose

def compose() -> ComposeResult

Compose the hex view layout.

on_mount

def on_mount() -> None

Handle mount event.

set_file

def set_file(file) -> None

Set the file to read from.

on_cursor_moved

def on_cursor_moved(message: CursorMoved) -> None

Handle cursor movement messages from columns.

on_scroll_request

def on_scroll_request(message: ScrollRequest) -> None

Handle scroll request messages from columns.

on_key

def on_key(event: events.Key) -> None

Handle key events.

on_mouse_down

def on_mouse_down(event: events.MouseDown) -> None

Handle mouse click events.

render_line

def render_line(y: int) -> Strip

Render a single line of the hex view.