The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
fb_text.c File Reference

text grid renderer over the framebuffer. More...

#include "fb_text.h"
#include "fb.h"
#include "font.h"

Functions

void fb_text_set_default_bg (uint32_t bg)
 set the default background used by clear/scroll (0x00RRGGBB).
void fb_text_init (uint32_t scale, uint32_t margin)
 initialize the text grid over the (already initialized) framebuffer.
uint8_t fb_text_rows (void)
 number of character rows / columns that fit on screen.
uint8_t fb_text_cols (void)
void fb_text_draw_glyph (uint8_t row, uint8_t col, char ch, uint32_t fg, uint32_t bg)
 draw a glyph at a cell with explicit 0x00RRGGBB colours.
void fb_text_clear (void)
 clear the whole grid to the current background colour.
void fb_text_scroll (void)
 scroll the grid up by one row; the new bottom row is cleared.
void fb_text_set_cursor (uint8_t row, uint8_t col)
 move / query the logical cursor (used by the tty backend to draw a caret).
void fb_text_get_cursor (uint8_t *row, uint8_t *col)
void fb_text_set_colors (uint8_t fg, uint8_t bg)
 set the active foreground/background as ANSI colour indices (0-15).
void fb_text_put (uint8_t row, uint8_t col, char ch)
 draw a glyph at a cell using the active ANSI colours (set via fb_text_set_colors).
void fb_text_draw_cursor (uint8_t row, uint8_t col, bool visible)
 draw or erase the software caret at a cell.

Detailed Description

text grid renderer over the framebuffer.

Function Documentation

◆ fb_text_set_default_bg()

void fb_text_set_default_bg ( uint32_t bg)

set the default background used by clear/scroll (0x00RRGGBB).

◆ fb_text_init()

void fb_text_init ( uint32_t scale,
uint32_t margin )

initialize the text grid over the (already initialized) framebuffer.

computes the cell size from the font plus scaling/margins, derives the rows/cols that fit, and clears the screen.

Parameters
scaleinteger glyph magnification (1 = native font size).
marginpixels of blank border on each edge of the text area.

◆ fb_text_rows()

uint8_t fb_text_rows ( void )

number of character rows / columns that fit on screen.

◆ fb_text_cols()

uint8_t fb_text_cols ( void )

◆ fb_text_draw_glyph()

void fb_text_draw_glyph ( uint8_t row,
uint8_t col,
char ch,
uint32_t fg,
uint32_t bg )

draw a glyph at a cell with explicit 0x00RRGGBB colours.

Parameters
row,coltarget cell (out-of-range is ignored).
chcharacter code (0-255).
fgforeground colour,
bgbackground colour.

◆ fb_text_clear()

void fb_text_clear ( void )

clear the whole grid to the current background colour.

◆ fb_text_scroll()

void fb_text_scroll ( void )

scroll the grid up by one row; the new bottom row is cleared.

◆ fb_text_set_cursor()

void fb_text_set_cursor ( uint8_t row,
uint8_t col )

move / query the logical cursor (used by the tty backend to draw a caret).

◆ fb_text_get_cursor()

void fb_text_get_cursor ( uint8_t * row,
uint8_t * col )

◆ fb_text_set_colors()

void fb_text_set_colors ( uint8_t fg,
uint8_t bg )

set the active foreground/background as ANSI colour indices (0-15).

glyphs drawn via fb_text_put use these until changed.

◆ fb_text_put()

void fb_text_put ( uint8_t row,
uint8_t col,
char ch )

draw a glyph at a cell using the active ANSI colours (set via fb_text_set_colors).

this is what the tty backend calls.

◆ fb_text_draw_cursor()

void fb_text_draw_cursor ( uint8_t row,
uint8_t col,
bool visible )

draw or erase the software caret at a cell.

when erasing, the cell is repainted with the active background so the underlying glyph is preserved by a subsequent redraw. drawn as an underline near the cell bottom.