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

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

#include "vterm_internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+ Include dependency graph for vterm.c:

Go to the source code of this file.

Macros

#define DEFAULT(v, def)   ((v) ? (v) : (def))
 

Functions

static void * default_malloc (size_t size, void *allocdata)
 
static void default_free (void *ptr, void *allocdata)
 
VTermvterm_new (int rows, int cols)
 
VTermvterm_new_with_allocator (int rows, int cols, VTermAllocatorFunctions *funcs, void *allocdata)
 
VTermvterm_build (const struct VTermBuilder *builder)
 
void vterm_free (VTerm *vt)
 
INTERNAL void * vterm_allocator_malloc (VTerm *vt, size_t size)
 
INTERNAL void vterm_allocator_free (VTerm *vt, void *ptr)
 
void vterm_get_size (const VTerm *vt, int *rowsp, int *colsp)
 
void vterm_set_size (VTerm *vt, int rows, int cols)
 
int vterm_get_utf8 (const VTerm *vt)
 
void vterm_set_utf8 (VTerm *vt, int is_utf8)
 
void vterm_output_set_callback (VTerm *vt, VTermOutputCallback *func, void *user)
 
INTERNAL void vterm_push_output_bytes (VTerm *vt, const char *bytes, size_t len)
 
INTERNAL void vterm_push_output_vsprintf (VTerm *vt, const char *format, va_list args)
 
INTERNAL void vterm_push_output_sprintf (VTerm *vt, const char *format,...)
 
INTERNAL void vterm_push_output_sprintf_ctrl (VTerm *vt, unsigned char ctrl, const char *fmt,...)
 
INTERNAL void vterm_push_output_sprintf_str (VTerm *vt, unsigned char ctrl, bool term, const char *fmt,...)
 
size_t vterm_output_get_buffer_size (const VTerm *vt)
 
size_t vterm_output_get_buffer_current (const VTerm *vt)
 
size_t vterm_output_get_buffer_remaining (const VTerm *vt)
 
size_t vterm_output_read (VTerm *vt, char *buffer, size_t len)
 
VTermValueType vterm_get_attr_type (VTermAttr attr)
 
VTermValueType vterm_get_prop_type (VTermProp prop)
 
void vterm_scroll_rect (VTermRect rect, int downward, int rightward, int(*moverect)(VTermRect src, VTermRect dest, void *user), int(*eraserect)(VTermRect rect, int selective, void *user), void *user)
 
void vterm_copy_cells (VTermRect dest, VTermRect src, void(*copycell)(VTermPos dest, VTermPos src, void *user), void *user)
 
void vterm_check_version (int major, int minor)
 

Variables

static VTermAllocatorFunctions default_allocator
 

Macro Definition Documentation

◆ DEFAULT

#define DEFAULT (   v,
  def 
)    ((v) ? (v) : (def))

Definition at line 49 of file vterm.c.

Function Documentation

◆ default_free()

static void default_free ( void *  ptr,
void *  allocdata 
)
static

Definition at line 20 of file vterm.c.

References free().

+ Here is the call graph for this function:

◆ default_malloc()

static void * default_malloc ( size_t  size,
void *  allocdata 
)
static

Definition at line 12 of file vterm.c.

References malloc(), memset(), and size.

+ Here is the call graph for this function:

◆ vterm_allocator_free()

INTERNAL void vterm_allocator_free ( VTerm vt,
void *  ptr 
)

Definition at line 103 of file vterm.c.

References VTerm::allocator, VTerm::allocdata, VTermAllocatorFunctions::free, and vt.

+ Here is the caller graph for this function:

◆ vterm_allocator_malloc()

INTERNAL void * vterm_allocator_malloc ( VTerm vt,
size_t  size 
)

Definition at line 98 of file vterm.c.

References VTerm::allocator, VTerm::allocdata, VTermAllocatorFunctions::malloc, size, and vt.

+ Here is the caller graph for this function:

◆ vterm_build()

VTerm * vterm_build ( const struct VTermBuilder builder)

Definition at line 51 of file vterm.c.

References VTermBuilder::allocator, VTerm::allocator, VTermBuilder::allocdata, VTerm::allocdata, VTermBuilder::cols, VTerm::cols, DEFAULT, default_allocator, VTerm::outbuffer, VTerm::outbuffer_cur, VTermBuilder::outbuffer_len, VTerm::outbuffer_len, VTerm::outdata, VTerm::outfunc, VTerm::parser, VTermBuilder::rows, VTerm::rows, VTerm::state, VTerm::tmpbuffer, VTermBuilder::tmpbuffer_len, VTerm::tmpbuffer_len, vt, and vterm_allocator_malloc().

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

◆ vterm_check_version()

void vterm_check_version ( int  major,
int  minor 
)

Definition at line 415 of file vterm.c.

References VTERM_VERSION_MAJOR, and VTERM_VERSION_MINOR.

◆ vterm_copy_cells()

void vterm_copy_cells ( VTermRect  dest,
VTermRect  src,
void(*)(VTermPos dest, VTermPos src, void *user)  copycell,
void *  user 
)

Definition at line 374 of file vterm.c.

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

◆ vterm_free()

void vterm_free ( VTerm vt)

Definition at line 84 of file vterm.c.

References VTerm::outbuffer, VTerm::screen, VTerm::state, VTerm::tmpbuffer, vt, vterm_allocator_free(), vterm_screen_free(), and vterm_state_free().

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

◆ vterm_get_attr_type()

VTermValueType vterm_get_attr_type ( VTermAttr  attr)

Definition at line 266 of file vterm.c.

References VTERM_ATTR_BACKGROUND, VTERM_ATTR_BASELINE, VTERM_ATTR_BLINK, VTERM_ATTR_BOLD, VTERM_ATTR_CONCEAL, VTERM_ATTR_FONT, VTERM_ATTR_FOREGROUND, VTERM_ATTR_ITALIC, VTERM_ATTR_REVERSE, VTERM_ATTR_SMALL, VTERM_ATTR_STRIKE, VTERM_ATTR_UNDERLINE, VTERM_N_ATTRS, VTERM_VALUETYPE_BOOL, VTERM_VALUETYPE_COLOR, and VTERM_VALUETYPE_INT.

+ Here is the caller graph for this function:

◆ vterm_get_prop_type()

VTermValueType vterm_get_prop_type ( VTermProp  prop)

Definition at line 287 of file vterm.c.

References VTERM_N_PROPS, VTERM_PROP_ALTSCREEN, VTERM_PROP_CURSORBLINK, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORVISIBLE, VTERM_PROP_FOCUSREPORT, VTERM_PROP_ICONNAME, VTERM_PROP_MOUSE, VTERM_PROP_REVERSE, VTERM_PROP_TITLE, VTERM_VALUETYPE_BOOL, VTERM_VALUETYPE_INT, and VTERM_VALUETYPE_STRING.

+ Here is the caller graph for this function:

◆ vterm_get_size()

void vterm_get_size ( const VTerm vt,
int *  rowsp,
int *  colsp 
)

Definition at line 108 of file vterm.c.

References VTerm::cols, VTerm::rows, and vt.

+ Here is the caller graph for this function:

◆ vterm_get_utf8()

int vterm_get_utf8 ( const VTerm vt)

Definition at line 128 of file vterm.c.

References VTerm::mode, and vt.

◆ vterm_new()

VTerm * vterm_new ( int  rows,
int  cols 
)

Definition at line 30 of file vterm.c.

References cols, rows, and vterm_build().

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

◆ vterm_new_with_allocator()

VTerm * vterm_new_with_allocator ( int  rows,
int  cols,
VTermAllocatorFunctions funcs,
void *  allocdata 
)

Definition at line 38 of file vterm.c.

References cols, rows, and vterm_build().

+ Here is the call graph for this function:

◆ vterm_output_get_buffer_current()

size_t vterm_output_get_buffer_current ( const VTerm vt)

Definition at line 241 of file vterm.c.

References VTerm::outbuffer_cur, and vt.

+ Here is the caller graph for this function:

◆ vterm_output_get_buffer_remaining()

size_t vterm_output_get_buffer_remaining ( const VTerm vt)

Definition at line 246 of file vterm.c.

References VTerm::outbuffer_cur, VTerm::outbuffer_len, and vt.

◆ vterm_output_get_buffer_size()

size_t vterm_output_get_buffer_size ( const VTerm vt)

Definition at line 236 of file vterm.c.

References VTerm::outbuffer_len, and vt.

◆ vterm_output_read()

size_t vterm_output_read ( VTerm vt,
char *  buffer,
size_t  len 
)

Definition at line 251 of file vterm.c.

References memcpy(), memmove(), VTerm::outbuffer, VTerm::outbuffer_cur, and vt.

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

◆ vterm_output_set_callback()

void vterm_output_set_callback ( VTerm vt,
VTermOutputCallback func,
void *  user 
)

Definition at line 138 of file vterm.c.

References VTerm::outdata, VTerm::outfunc, and vt.

+ Here is the caller graph for this function:

◆ vterm_push_output_bytes()

INTERNAL void vterm_push_output_bytes ( VTerm vt,
const char *  bytes,
size_t  len 
)

Definition at line 144 of file vterm.c.

References memcpy(), VTerm::outbuffer, VTerm::outbuffer_cur, VTerm::outbuffer_len, VTerm::outdata, VTerm::outfunc, and vt.

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

◆ vterm_push_output_sprintf()

INTERNAL void vterm_push_output_sprintf ( VTerm vt,
const char *  format,
  ... 
)

Definition at line 166 of file vterm.c.

References format, va_end, va_start, vt, and vterm_push_output_vsprintf().

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

◆ vterm_push_output_sprintf_ctrl()

INTERNAL void vterm_push_output_sprintf_ctrl ( VTerm vt,
unsigned char  ctrl,
const char *  fmt,
  ... 
)

Definition at line 174 of file vterm.c.

References ESC_S, VTerm::mode, VTerm::tmpbuffer, VTerm::tmpbuffer_len, va_end, va_start, vt, and vterm_push_output_bytes().

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

◆ vterm_push_output_sprintf_str()

INTERNAL void vterm_push_output_sprintf_str ( VTerm vt,
unsigned char  ctrl,
bool  term,
const char *  fmt,
  ... 
)

Definition at line 200 of file vterm.c.

References ESC_S, VTerm::mode, VTerm::tmpbuffer, VTerm::tmpbuffer_len, va_end, va_start, vt, and vterm_push_output_bytes().

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

◆ vterm_push_output_vsprintf()

INTERNAL void vterm_push_output_vsprintf ( VTerm vt,
const char *  format,
va_list  args 
)

Definition at line 158 of file vterm.c.

References format, VTerm::tmpbuffer, VTerm::tmpbuffer_len, vt, and vterm_push_output_bytes().

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

◆ vterm_scroll_rect()

void vterm_scroll_rect ( VTermRect  rect,
int  downward,
int  rightward,
int(*)(VTermRect src, VTermRect dest, void *user)  moverect,
int(*)(VTermRect rect, int selective, void *user)  eraserect,
void *  user 
)

Definition at line 305 of file vterm.c.

References VTermRect::end_col, VTermRect::end_row, moverect(), VTermRect::start_col, and VTermRect::start_row.

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

◆ vterm_set_size()

void vterm_set_size ( VTerm vt,
int  rows,
int  cols 
)

Definition at line 116 of file vterm.c.

References cols, VTerm::cols, VTerm::parser, rows, VTerm::rows, and vt.

+ Here is the caller graph for this function:

◆ vterm_set_utf8()

void vterm_set_utf8 ( VTerm vt,
int  is_utf8 
)

Definition at line 133 of file vterm.c.

References VTerm::mode, and vt.

+ Here is the caller graph for this function:

Variable Documentation

◆ default_allocator

VTermAllocatorFunctions default_allocator
static
Initial value:
= {
.malloc = &default_malloc,
.free = &default_free,
}
static void default_free(void *ptr, void *allocdata)
Definition vterm.c:20
static void * default_malloc(size_t size, void *allocdata)
Definition vterm.c:12

Definition at line 25 of file vterm.c.