miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
VT/ANSI Terminal Core

ANSI/VT100 escape sequence parser and VGA-backed terminal renderer. More...

Functions

void vt_init (void)
 Clears the VGA framebuffer, resets cursor position to (0,0), sets default attribute (light gray on black), and initialises the ANSI escape parser state machine. Called once during kernel boot before any console output.
void vt_clear (void)
 Fills all 80x25 VGA cells with space characters using the current default attribute, resets the cursor position to row 0 column 0, and updates the hardware cursor via VGA CRT registers.
void vt_write_byte (char c)
 If inside an ANSI escape sequence, feeds to the CSI parser and applies the completed command (cursor movement, erase, SGR color). Otherwise:
void vt_write (const char *buf, size_t len)
 Calls vt_write_byte() for each byte in [buf, buf+len). Efficient for bulk output from tty_write() or printk().
void vt_set_cursor_visible (bool visible)
 Writes to VGA CRT registers VGA_CUR_START_REG (index 0x0A): sets VGA_CUR_DISABLE bit to hide, clears it and sets scanline range to show.
void vt_get_winsize (uint16_t *rows, uint16_t *cols)
 Used by tty_ioctl TIOCGWINSZ to fill struct minios_winsize.ws_row/ws_col.
uint8_t vt_current_attr (void)
 The attribute byte encodes foreground color (bits 3:0), background color (bits 6:4), and blink (bit 7) as set by the most recent SGR sequence.

Detailed Description

ANSI/VT100 escape sequence parser and VGA-backed terminal renderer.

The VT core parses ANSI escape sequences (CSI cursor movement, SGR color, erase commands) and renders output to the VGA 80x25 text-mode framebuffer. It implements a software cursor, 256-color SGR mapped to the nearest VGA 16-color palette entry, and hardware cursor sync via the VGA CRT registers.

Function Documentation

◆ vt_clear()

void vt_clear ( void )

Fills all 80x25 VGA cells with space characters using the current default attribute, resets the cursor position to row 0 column 0, and updates the hardware cursor via VGA CRT registers.

vt_clear() - Clear the terminal screen and reset cursor to (0,0).

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

◆ vt_current_attr()

uint8_t vt_current_attr ( void )

The attribute byte encodes foreground color (bits 3:0), background color (bits 6:4), and blink (bit 7) as set by the most recent SGR sequence.

vt_current_attr() - Return the current VGA text attribute byte.

Returns
Current VGA attribute byte (e.g. 0x07 = light gray on black).
Here is the call graph for this function:

◆ vt_get_winsize()

void vt_get_winsize ( uint16_t * rows,
uint16_t * cols )

Used by tty_ioctl TIOCGWINSZ to fill struct minios_winsize.ws_row/ws_col.

vt_get_winsize() - Query the terminal dimensions.

Parameters
rowsOutput; set to SCREEN_ROWS (25).
colsOutput; set to SCREEN_COLS (80).
Here is the caller graph for this function:

◆ vt_init()

void vt_init ( void )

Clears the VGA framebuffer, resets cursor position to (0,0), sets default attribute (light gray on black), and initialises the ANSI escape parser state machine. Called once during kernel boot before any console output.

vt_init() - Initialise the VT terminal state.

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

◆ vt_set_cursor_visible()

void vt_set_cursor_visible ( bool visible)

Writes to VGA CRT registers VGA_CUR_START_REG (index 0x0A): sets VGA_CUR_DISABLE bit to hide, clears it and sets scanline range to show.

vt_set_cursor_visible() - Show or hide the hardware VGA text cursor.

Parameters
visibletrue to enable the underline hardware cursor, false to hide it.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_write()

void vt_write ( const char * buf,
size_t len )

Calls vt_write_byte() for each byte in [buf, buf+len). Efficient for bulk output from tty_write() or printk().

vt_write() - Write a buffer of bytes through the VT state machine.

Parameters
bufPointer to the bytes to write.
lenNumber of bytes in @buf.
Here is the call graph for this function:

◆ vt_write_byte()

void vt_write_byte ( char c)

If inside an ANSI escape sequence, feeds to the CSI parser and applies the completed command (cursor movement, erase, SGR color). Otherwise:

vt_write_byte() - Process one output byte through the VT state machine.

Parameters
cByte to process.
  • ESC (0x1B): begins escape sequence.
  • '\n': advances row, scrolls if at bottom.
  • '\r': resets column to 0.
  • '\b': moves cursor left one cell (backspace).
  • Other printable bytes: writes to the VGA cell at the current cursor position with the current attribute, then advances the cursor.
Here is the call graph for this function:
Here is the caller graph for this function: