The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
fb_text.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file fb_text.h
5 * @brief text grid on top of the linear framebuffer.
6 *
7 * turns the pixel-only framebuffer driver into a character grid: it lays out
8 * cells using the generated bitmap font (font.h), draws glyphs with a
9 * foreground/background colour, tracks a cursor, and scrolls. it does not
10 * parse escape sequences, that is the tty layer's job. this is the piece the
11 * framebuffer tty backend calls.
12 */
13
14#include "common/stdint.h"
15
16/**
17 * initialize the text grid over the (already initialized) framebuffer.
18 * computes the cell size from the font plus scaling/margins, derives the
19 * rows/cols that fit, and clears the screen.
20 * @param scale integer glyph magnification (1 = native font size).
21 * @param margin pixels of blank border on each edge of the text area.
22 */
23void fb_text_init(uint32_t scale, uint32_t margin);
24
25/**
26 * number of character rows / columns that fit on screen.
27 */
30
31/**
32 * draw a glyph at a cell with explicit 0x00RRGGBB colours.
33 * @param row, col target cell (out-of-range is ignored).
34 * @param ch character code (0-255).
35 * @param fg foreground colour, @param bg background colour.
36 */
37void fb_text_draw_glyph(uint8_t row, uint8_t col, char ch, uint32_t fg, uint32_t bg);
38
39/**
40 * set the active foreground/background as ANSI colour indices (0-15). glyphs
41 * drawn via fb_text_put use these until changed.
42 */
44
45/**
46 * draw a glyph at a cell using the active ANSI colours (set via
47 * fb_text_set_colors). this is what the tty backend calls.
48 */
49void fb_text_put(uint8_t row, uint8_t col, char ch);
50
51/**
52 * draw or erase the software caret at a cell. when erasing, the cell is
53 * repainted with the active background so the underlying glyph is preserved
54 * by a subsequent redraw. drawn as an underline near the cell bottom.
55 */
56void fb_text_draw_cursor(uint8_t row, uint8_t col, bool visible);
57
58/**
59 * clear the whole grid to the current background colour.
60 */
61void fb_text_clear(void);
62
63/**
64 * scroll the grid up by one row; the new bottom row is cleared.
65 */
66void fb_text_scroll(void);
67
68/**
69 * move / query the logical cursor (used by the tty backend to draw a caret).
70 */
72void fb_text_get_cursor(uint8_t *row, uint8_t *col);
73
74/**
75 * set the default background used by clear/scroll (0x00RRGGBB).
76 */
void fb_text_set_colors(uint8_t fg, uint8_t bg)
set the active foreground/background as ANSI colour indices (0-15).
Definition fb_text.c:173
uint8_t fb_text_cols(void)
Definition fb_text.c:90
void fb_text_scroll(void)
scroll the grid up by one row; the new bottom row is cleared.
Definition fb_text.c:144
void fb_text_clear(void)
clear the whole grid to the current background colour.
Definition fb_text.c:137
void fb_text_init(uint32_t scale, uint32_t margin)
initialize the text grid over the (already initialized) framebuffer.
Definition fb_text.c:62
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).
Definition fb_text.c:161
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).
Definition fb_text.c:179
void fb_text_draw_cursor(uint8_t row, uint8_t col, bool visible)
draw or erase the software caret at a cell.
Definition fb_text.c:184
void fb_text_get_cursor(uint8_t *row, uint8_t *col)
Definition fb_text.c:167
void fb_text_set_default_bg(uint32_t bg)
set the default background used by clear/scroll (0x00RRGGBB).
Definition fb_text.c:57
uint8_t fb_text_rows(void)
number of character rows / columns that fit on screen.
Definition fb_text.c:85
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.
Definition fb_text.c:95
unsigned int uint32_t
Definition fb.h:17
unsigned char uint8_t
Definition fb.h:18