forked from Lephenixnoir/hex-editor
52 lines
1.5 KiB
C
52 lines
1.5 KiB
C
|
// heditor: A hexadecimal editor widget
|
||
|
//
|
||
|
// This widget basically holds a view for a data source. The controller is the
|
||
|
// source API.
|
||
|
|
||
|
#pragma once
|
||
|
#include "source.h"
|
||
|
#include <justui/defs.h>
|
||
|
#include <justui/jwidget.h>
|
||
|
#include <gint/display.h>
|
||
|
|
||
|
/* heditor: Hexadecimal editor
|
||
|
|
||
|
Events:
|
||
|
* HEDITOR_CHANGED when the view changes due to scroll or a file change. This
|
||
|
does *not* include cursor changes that don't scroll. */
|
||
|
typedef struct {
|
||
|
jwidget widget;
|
||
|
|
||
|
/* Current data source. We don't own the source */
|
||
|
source_t *source;
|
||
|
/* Current scroll offset, in bytes */
|
||
|
int scroll;
|
||
|
/* Number of visible lines */
|
||
|
int8_t visible_lines;
|
||
|
/* Number of bytes printed per line */
|
||
|
int8_t bytes_per_line;
|
||
|
/* Additional spacing between lines, in pixels */
|
||
|
int8_t line_spacing;
|
||
|
/* Rendering font */
|
||
|
font_t const *font;
|
||
|
|
||
|
} heditor;
|
||
|
|
||
|
/* Type IDs */
|
||
|
extern uint16_t HEDITOR_CHANGED;
|
||
|
|
||
|
/* heditor_create(): Create a new editor
|
||
|
Initially there is no data source, so most features are disabled. */
|
||
|
heditor *heditor_create(jwidget *parent);
|
||
|
|
||
|
/* Switch the source. The old source is not freed by the editor. */
|
||
|
void heditor_set_source(heditor *e, source_t *source);
|
||
|
|
||
|
/* Scroll to the requested offset. */
|
||
|
bool heditor_scroll_to(heditor *e, int offset);
|
||
|
|
||
|
/* Trivial properties */
|
||
|
void heditor_set_font(heditor *e, font_t const *font);
|
||
|
void heditor_set_line_spacing(heditor *e, int line_spacig);
|
||
|
void heditor_set_bytes_per_lines(heditor *e, int bytes_per_line);
|