5 Struct N_GUI_SYNTAXVIEW_DATA
gullradriel edited this page 2026-10-09 00:55:18 +02:00

N_GUI_SYNTAXVIEW_DATA

Module: GUI: allegro5 widget system with pseudo-windows

syntax view specific data: read-only highlighted text

#include "n_gui.h"

Public Attributes

Name
int width_valid
0 when cached_content_w is stale.
char * text
owned copy of the text, or NULL
int sel_start
selection start byte offset into text, or -1 when nothing is selected
int sel_end
selection end byte offset (tracks the cursor while a drag is in progress)
int sel_dragging
1 while a mouse drag is extending the selection, 0 otherwise
int scroll_offset
first visible line
int mode
highlighting mode: N_GUI_SYNTAX_*
const ALLEGRO_FONT * metrics_font
font cached_content_w was measured with (a text keeps its width only for as long as the font it was measured in stays the one in use)
int lines_valid
0 when cached_nb_lines / cached_headers_end are stale (rebuild on next use).
size_t len
text length in bytes
int h_scroll_dragging
1 while the horizontal scrollbar thumb is being dragged (so the shared scrollbar-drag handler routes the drag to h_scroll, not to the lines)
float h_scroll
horizontal scroll offset in pixels: the view does not wrap, so a line wider than the widget is reached by panning rather than by folding
int cached_nb_lines
cached line count (matches _text_line_count), valid when lines_valid
int cached_headers_end
cached first blank-line index (HTTP headers end), or INT_MAX; valid when lines_valid
float cached_content_w
cached pixel width of the widest line, valid when width_valid

Public Attributes Documentation

variable width_valid

int width_valid;

0 when cached_content_w is stale.

Cleared by n_gui_syntaxview_set_text and whenever the widget is drawn with a font other than metrics_font.

variable text

char * text;

owned copy of the text, or NULL

variable sel_start

int sel_start;

selection start byte offset into text, or -1 when nothing is selected

variable sel_end

int sel_end;

selection end byte offset (tracks the cursor while a drag is in progress)

variable sel_dragging

int sel_dragging;

1 while a mouse drag is extending the selection, 0 otherwise

variable scroll_offset

int scroll_offset;

first visible line

variable mode

int mode;

highlighting mode: N_GUI_SYNTAX_*

variable metrics_font

const ALLEGRO_FONT * metrics_font;

font cached_content_w was measured with (a text keeps its width only for as long as the font it was measured in stays the one in use)

variable lines_valid

int lines_valid;

0 when cached_nb_lines / cached_headers_end are stale (rebuild on next use).

Zero-initialised so a freshly created widget rebuilds on first draw; set back to 0 by n_gui_syntaxview_set_text.

variable len

size_t len;

text length in bytes

variable h_scroll_dragging

int h_scroll_dragging;

1 while the horizontal scrollbar thumb is being dragged (so the shared scrollbar-drag handler routes the drag to h_scroll, not to the lines)

variable h_scroll

float h_scroll;

horizontal scroll offset in pixels: the view does not wrap, so a line wider than the widget is reached by panning rather than by folding

variable cached_nb_lines

int cached_nb_lines;

cached line count (matches _text_line_count), valid when lines_valid

variable cached_headers_end

int cached_headers_end;

cached first blank-line index (HTTP headers end), or INT_MAX; valid when lines_valid

variable cached_content_w

float cached_content_w;

cached pixel width of the widest line, valid when width_valid