LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
harness.c File Reference

(475a4fe LLVM update: finally on 18.x!)

#include "vterm.h"
#include "../src/vterm_internal.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
+ Include dependency graph for harness.c:

Go to the source code of this file.

Macros

#define streq(a, b)   (!strcmp(a,b))
 
#define strstartswith(a, b)   (!strncmp(a,b,strlen(b)))
 
#define BOOLSTR(v)   ((v) ? "on" : "off")
 

Functions

static size_t inplace_hex2bytes (char *s)
 
static VTermModifier strpe_modifiers (char **strp)
 
static VTermKey strp_key (char *str)
 
static void print_color (const VTermColor *col)
 
static VTermColor strpe_color (char **strp)
 
static void term_output (const char *s, size_t len, void *user)
 
static void printhex (const char *s, size_t len)
 
static int parser_text (const char bytes[], size_t len, void *user)
 
static int parser_control (unsigned char control, void *user)
 
static int parser_escape (const char bytes[], size_t len, void *user)
 
static int parser_csi (const char *leader, const long args[], int argcount, const char *intermed, char command, void *user)
 
static int parser_osc (int command, VTermStringFragment frag, void *user)
 
static int parser_dcs (const char *command, size_t commandlen, VTermStringFragment frag, void *user)
 
static int parser_apc (VTermStringFragment frag, void *user)
 
static int parser_pm (VTermStringFragment frag, void *user)
 
static int parser_sos (VTermStringFragment frag, void *user)
 
static int movecursor (VTermPos pos, VTermPos oldpos, int visible, void *user)
 
static int scrollrect (VTermRect rect, int downward, int rightward, void *user)
 
static int moverect (VTermRect dest, VTermRect src, void *user)
 
static int settermprop (VTermProp prop, VTermValue *val, void *user)
 
static int state_putglyph (VTermGlyphInfo *info, VTermPos pos, void *user)
 
static int state_erase (VTermRect rect, int selective, void *user)
 
static int state_setpenattr (VTermAttr attr, VTermValue *val, void *user)
 
static int state_setlineinfo (int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user)
 
static int state_sb_clear (void *user)
 
static int selection_set (VTermSelectionMask mask, VTermStringFragment frag, void *user)
 
static int selection_query (VTermSelectionMask mask, void *user)
 
static int screen_damage (VTermRect rect, void *user)
 
static int screen_sb_pushline (int cols, const VTermScreenCell *cells, void *user)
 
static int screen_sb_popline (int cols, VTermScreenCell *cells, void *user)
 
static int screen_sb_clear (void *user)
 
int main (int argc, char **argv)
 

Variables

static VTermvt
 
static VTermStatestate
 
static VTermScreenscreen
 
static VTermEncodingInstance encoding
 
static VTermParserCallbacks parser_cbs
 
static VTermStateFallbacks fallbacks
 
static int want_movecursor = 0
 
static VTermPos state_pos
 
static int want_scrollrect = 0
 
static int want_moverect = 0
 
static int want_settermprop = 0
 
static int want_state_putglyph = 0
 
static int want_state_erase = 0
 
struct { 
 
int bold
 
int underline
 
int italic
 
int blink
 
int reverse
 
int conceal
 
int strike
 
int font
 
int small
 
int baseline
 
VTermColor foreground
 
VTermColor background
 
state_pen 
 
static int want_state_scrollback = 0
 
VTermStateCallbacks state_cbs
 
VTermSelectionCallbacks selection_cbs
 
static int want_screen_damage = 0
 
static int want_screen_damage_cells = 0
 
static int want_screen_scrollback = 0
 
VTermScreenCallbacks screen_cbs
 

Macro Definition Documentation

◆ BOOLSTR

#define BOOLSTR (   v)    ((v) ? "on" : "off")

◆ streq

#define streq (   a,
 
)    (!strcmp(a,b))

Definition at line 8 of file harness.c.

◆ strstartswith

#define strstartswith (   a,
 
)    (!strncmp(a,b,strlen(b)))

Definition at line 9 of file harness.c.

Function Documentation

◆ inplace_hex2bytes()

static size_t inplace_hex2bytes ( char *  s)
static

Definition at line 11 of file harness.c.

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 627 of file harness.c.

References VTermScreenCell::attrs, VTermScreenCellAttrs::baseline, VTermScreenCell::bg, VTermScreenCellAttrs::blink, VTermScreenCellAttrs::bold, VTermValue::boolean, BOOLSTR, VTermScreenCell::chars, VTermPos::col, cols, VTermEncodingInstance::data, VTermEncoding::decode, VTermScreenCellAttrs::dhl, VTermScreenCellAttrs::dwl, VTermEncodingInstance::enc, ENC_UTF8, encoding, VTermRect::end_col, VTermRect::end_row, fallbacks, VTermScreenCell::fg, VTermStringFragment::final, VTermScreenCellAttrs::font, free(), info, VTermEncoding::init, VTermStringFragment::initial, inplace_hex2bytes(), VTermScreenCellAttrs::italic, VTermStringFragment::len, malloc(), memset(), VTermValue::number, parser_cbs, print_color(), VTermScreenCellAttrs::reverse, VTermPos::row, rows, screen, screen_cbs, selection_cbs, VTermScreenCellAttrs::small, VTermRect::start_col, VTermRect::start_row, state, state_cbs, state_pen, state_pos, VTermStringFragment::str, streq, strp_key(), strpe_color(), strpe_modifiers(), strstartswith, term_output(), VTermScreenCellAttrs::underline, vt, VTERM_ATTR_BASELINE, VTERM_ATTR_BLINK, VTERM_ATTR_BOLD, VTERM_ATTR_FONT, VTERM_ATTR_ITALIC, VTERM_ATTR_REVERSE, VTERM_ATTR_SMALL, VTERM_ATTR_UNDERLINE, VTERM_BASELINE_LOWER, VTERM_BASELINE_RAISE, VTERM_DAMAGE_CELL, VTERM_DAMAGE_ROW, VTERM_DAMAGE_SCREEN, VTERM_DAMAGE_SCROLL, vterm_free(), vterm_get_size(), vterm_input_write(), vterm_keyboard_end_paste(), vterm_keyboard_key(), vterm_keyboard_start_paste(), vterm_keyboard_unichar(), vterm_lookup_encoding(), VTERM_MAX_CHARS_PER_CELL, vterm_mouse_button(), vterm_mouse_move(), vterm_new(), vterm_obtain_screen(), vterm_obtain_state(), vterm_output_get_buffer_current(), vterm_output_read(), vterm_output_set_callback(), vterm_parser_set_callbacks(), vterm_screen_convert_color_to_rgb(), vterm_screen_enable_altscreen(), vterm_screen_enable_reflow(), vterm_screen_flush_damage(), vterm_screen_get_attrs_extent(), vterm_screen_get_cell(), vterm_screen_get_chars(), vterm_screen_get_text(), vterm_screen_is_eol(), vterm_screen_reset(), vterm_screen_set_callbacks(), vterm_screen_set_damage_merge(), vterm_screen_set_default_colors(), vterm_set_size(), vterm_set_utf8(), vterm_state_focus_in(), vterm_state_focus_out(), vterm_state_get_cursorpos(), vterm_state_get_lineinfo(), vterm_state_get_penattr(), vterm_state_reset(), vterm_state_send_selection(), vterm_state_set_bold_highbright(), vterm_state_set_callbacks(), vterm_state_set_selection_callbacks(), vterm_state_set_unrecognised_fallbacks(), want_movecursor, want_moverect, want_screen_damage, want_screen_damage_cells, want_screen_scrollback, want_scrollrect, want_settermprop, want_state_erase, want_state_putglyph, want_state_scrollback, and VTermScreenCell::width.

◆ movecursor()

static int movecursor ( VTermPos  pos,
VTermPos  oldpos,
int  visible,
void *  user 
)
static

Definition at line 311 of file harness.c.

References VTermPos::col, VTermPos::row, state_pos, and want_movecursor.

◆ moverect()

static int moverect ( VTermRect  dest,
VTermRect  src,
void *  user 
)
static

Definition at line 335 of file harness.c.

References VTermRect::end_col, VTermRect::end_row, VTermRect::start_col, VTermRect::start_row, and want_moverect.

+ Here is the caller graph for this function:

◆ parser_apc()

static int parser_apc ( VTermStringFragment  frag,
void *  user 
)
static

Definition at line 234 of file harness.c.

References VTermStringFragment::final, VTermStringFragment::initial, VTermStringFragment::len, printhex(), and VTermStringFragment::str.

+ Here is the call graph for this function:

◆ parser_control()

static int parser_control ( unsigned char  control,
void *  user 
)
static

Definition at line 138 of file harness.c.

◆ parser_csi()

static int parser_csi ( const char *  leader,
const long  args[],
int  argcount,
const char *  intermed,
char  command,
void *  user 
)
static

Definition at line 163 of file harness.c.

References CSI_ARG, CSI_ARG_HAS_MORE, and CSI_ARG_MISSING.

◆ parser_dcs()

static int parser_dcs ( const char *  command,
size_t  commandlen,
VTermStringFragment  frag,
void *  user 
)
static

Definition at line 214 of file harness.c.

References VTermStringFragment::final, VTermStringFragment::initial, VTermStringFragment::len, printhex(), and VTermStringFragment::str.

+ Here is the call graph for this function:

◆ parser_escape()

static int parser_escape ( const char  bytes[],
size_t  len,
void *  user 
)
static

Definition at line 145 of file harness.c.

References printhex().

+ Here is the call graph for this function:

◆ parser_osc()

static int parser_osc ( int  command,
VTermStringFragment  frag,
void *  user 
)
static

Definition at line 193 of file harness.c.

References VTermStringFragment::final, VTermStringFragment::initial, VTermStringFragment::len, printhex(), and VTermStringFragment::str.

+ Here is the call graph for this function:

◆ parser_pm()

static int parser_pm ( VTermStringFragment  frag,
void *  user 
)
static

Definition at line 251 of file harness.c.

References VTermStringFragment::final, VTermStringFragment::initial, VTermStringFragment::len, printhex(), and VTermStringFragment::str.

+ Here is the call graph for this function:

◆ parser_sos()

static int parser_sos ( VTermStringFragment  frag,
void *  user 
)
static

Definition at line 268 of file harness.c.

References VTermStringFragment::final, VTermStringFragment::initial, VTermStringFragment::len, printhex(), and VTermStringFragment::str.

+ Here is the call graph for this function:

◆ parser_text()

static int parser_text ( const char  bytes[],
size_t  len,
void *  user 
)
static

Definition at line 123 of file harness.c.

◆ print_color()

static void print_color ( const VTermColor col)
static

Definition at line 64 of file harness.c.

References VTermColor::indexed, VTermColor::rgb, VTermColor::type, VTERM_COLOR_IS_DEFAULT_BG, VTERM_COLOR_IS_DEFAULT_FG, VTERM_COLOR_IS_INDEXED, and VTERM_COLOR_IS_RGB.

+ Here is the caller graph for this function:

◆ printhex()

static void printhex ( const char *  s,
size_t  len 
)
static

Definition at line 117 of file harness.c.

+ Here is the caller graph for this function:

◆ screen_damage()

static int screen_damage ( VTermRect  rect,
void *  user 
)
static

Definition at line 528 of file harness.c.

References VTermScreenCell::chars, VTermRect::end_col, VTermRect::end_row, screen, VTermRect::start_col, VTermRect::start_row, vterm_screen_get_cell(), want_screen_damage, and want_screen_damage_cells.

+ Here is the call graph for this function:

◆ screen_sb_clear()

static int screen_sb_clear ( void *  user)
static

Definition at line 608 of file harness.c.

References want_screen_scrollback.

◆ screen_sb_popline()

static int screen_sb_popline ( int  cols,
VTermScreenCell cells,
void *  user 
)
static

◆ screen_sb_pushline()

static int screen_sb_pushline ( int  cols,
const VTermScreenCell cells,
void *  user 
)
static

Definition at line 572 of file harness.c.

References cols, and want_screen_scrollback.

◆ scrollrect()

static int scrollrect ( VTermRect  rect,
int  downward,
int  rightward,
void *  user 
)
static

◆ selection_query()

static int selection_query ( VTermSelectionMask  mask,
void *  user 
)
static

Definition at line 514 of file harness.c.

◆ selection_set()

static int selection_set ( VTermSelectionMask  mask,
VTermStringFragment  frag,
void *  user 
)
static

Definition at line 501 of file harness.c.

References VTermStringFragment::final, VTermStringFragment::initial, VTermStringFragment::len, printhex(), and VTermStringFragment::str.

+ Here is the call graph for this function:

◆ settermprop()

static int settermprop ( VTermProp  prop,
VTermValue val,
void *  user 
)
static

◆ state_erase()

static int state_erase ( VTermRect  rect,
int  selective,
void *  user 
)
static

◆ state_putglyph()

static int state_putglyph ( VTermGlyphInfo info,
VTermPos  pos,
void *  user 
)
static

◆ state_sb_clear()

static int state_sb_clear ( void *  user)
static

Definition at line 481 of file harness.c.

References want_state_scrollback.

◆ state_setlineinfo()

static int state_setlineinfo ( int  row,
const VTermLineInfo newinfo,
const VTermLineInfo oldinfo,
void *  user 
)
static

Definition at line 475 of file harness.c.

◆ state_setpenattr()

◆ strp_key()

static VTermKey strp_key ( char *  str)
static

Definition at line 42 of file harness.c.

References name, streq, VTERM_KEY_ENTER, VTERM_KEY_FUNCTION, VTERM_KEY_KP_0, VTERM_KEY_NONE, VTERM_KEY_TAB, and VTERM_KEY_UP.

+ Here is the caller graph for this function:

◆ strpe_color()

static VTermColor strpe_color ( char **  strp)
static

Definition at line 84 of file harness.c.

References vterm_color_indexed(), and vterm_color_rgb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ strpe_modifiers()

static VTermModifier strpe_modifiers ( char **  strp)
static

Definition at line 26 of file harness.c.

References state, VTERM_MOD_ALT, VTERM_MOD_CTRL, and VTERM_MOD_SHIFT.

+ Here is the caller graph for this function:

◆ term_output()

static void term_output ( const char *  s,
size_t  len,
void *  user 
)
static

Definition at line 110 of file harness.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ encoding

VTermEncodingInstance encoding
static

Definition at line 108 of file harness.c.

◆ fallbacks

VTermStateFallbacks fallbacks
static
Initial value:
= {
.control = parser_control,
.csi = parser_csi,
.osc = parser_osc,
.dcs = parser_dcs,
.apc = parser_apc,
.pm = parser_pm,
.sos = parser_sos,
}
static int parser_control(unsigned char control, void *user)
Definition harness.c:138
static int parser_pm(VTermStringFragment frag, void *user)
Definition harness.c:251
static int parser_osc(int command, VTermStringFragment frag, void *user)
Definition harness.c:193
static int parser_csi(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user)
Definition harness.c:163
static int parser_sos(VTermStringFragment frag, void *user)
Definition harness.c:268
static int parser_apc(VTermStringFragment frag, void *user)
Definition harness.c:234
static int parser_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user)
Definition harness.c:214

Definition at line 297 of file harness.c.

◆ parser_cbs

VTermParserCallbacks parser_cbs
static
Initial value:
= {
.text = parser_text,
.control = parser_control,
.escape = parser_escape,
.csi = parser_csi,
.osc = parser_osc,
.dcs = parser_dcs,
.apc = parser_apc,
.pm = parser_pm,
.sos = parser_sos,
}
static int parser_text(const char bytes[], size_t len, void *user)
Definition harness.c:123
static int parser_escape(const char bytes[], size_t len, void *user)
Definition harness.c:145

Definition at line 285 of file harness.c.

◆ screen

VTermScreen* screen
static

Definition at line 106 of file harness.c.

◆ screen_cbs

Initial value:
= {
.damage = screen_damage,
.moverect = moverect,
.movecursor = movecursor,
.settermprop = settermprop,
.sb_pushline = screen_sb_pushline,
.sb_popline = screen_sb_popline,
.sb_clear = screen_sb_clear,
}
static int screen_sb_pushline(int cols, const VTermScreenCell *cells, void *user)
Definition harness.c:572
static int screen_sb_popline(int cols, VTermScreenCell *cells, void *user)
Definition harness.c:589
static int movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user)
Definition harness.c:311
static int screen_damage(VTermRect rect, void *user)
Definition harness.c:528
static int screen_sb_clear(void *user)
Definition harness.c:608
static int settermprop(VTermProp prop, VTermValue *val, void *user)
Definition harness.c:348
static int moverect(VTermRect dest, VTermRect src, void *user)
Definition harness.c:335

Definition at line 617 of file harness.c.

◆ selection_cbs

VTermSelectionCallbacks selection_cbs
Initial value:
= {
.set = selection_set,
.query = selection_query,
}
static int selection_set(VTermSelectionMask mask, VTermStringFragment frag, void *user)
Definition harness.c:501
static int selection_query(VTermSelectionMask mask, void *user)
Definition harness.c:514

Definition at line 521 of file harness.c.

◆ state

VTermState* state
static

Definition at line 105 of file harness.c.

◆ state_cbs

Initial value:
= {
.putglyph = state_putglyph,
.movecursor = movecursor,
.scrollrect = scrollrect,
.moverect = moverect,
.erase = state_erase,
.setpenattr = state_setpenattr,
.settermprop = settermprop,
.setlineinfo = state_setlineinfo,
.sb_clear = state_sb_clear,
}
static int state_erase(VTermRect rect, int selective, void *user)
Definition harness.c:402
static int scrollrect(VTermRect rect, int downward, int rightward, void *user)
Definition harness.c:322
static int state_sb_clear(void *user)
Definition harness.c:481
static int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
Definition harness.c:381
static int state_setpenattr(VTermAttr attr, VTermValue *val, void *user)
Definition harness.c:428
static int state_setlineinfo(int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user)
Definition harness.c:475

Definition at line 489 of file harness.c.

◆ [struct]

struct { ... } state_pen

◆ state_pos

VTermPos state_pos
static

Definition at line 310 of file harness.c.

◆ vt

VTerm* vt
static

Definition at line 104 of file harness.c.

◆ want_movecursor

int want_movecursor = 0
static

Definition at line 309 of file harness.c.

◆ want_moverect

int want_moverect = 0
static

Definition at line 334 of file harness.c.

◆ want_screen_damage

int want_screen_damage = 0
static

Definition at line 526 of file harness.c.

◆ want_screen_damage_cells

int want_screen_damage_cells = 0
static

Definition at line 527 of file harness.c.

◆ want_screen_scrollback

int want_screen_scrollback = 0
static

Definition at line 571 of file harness.c.

◆ want_scrollrect

int want_scrollrect = 0
static

Definition at line 321 of file harness.c.

◆ want_settermprop

int want_settermprop = 0
static

Definition at line 347 of file harness.c.

◆ want_state_erase

int want_state_erase = 0
static

Definition at line 401 of file harness.c.

◆ want_state_putglyph

int want_state_putglyph = 0
static

Definition at line 380 of file harness.c.

◆ want_state_scrollback

int want_state_scrollback = 0
static

Definition at line 480 of file harness.c.