MOS Source Code
Loading...
Searching...
No Matches
sbi_console.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
7
8#include <ansi_colors.h>
9#include <mos/types.hpp>
10
12
13static size_t sbi_console_write(Console *con, const char *data, size_t size)
14{
15 MOS_UNUSED(con);
17 return sbi_putstring(data);
18}
19
21{
22 MOS_UNUSED(con);
23 sbi_console_fg = fg;
24 sbi_console_bg = bg;
25 char buf[64] = { 0 };
26 get_ansi_color(buf, fg, bg);
28 sbi_putstring(buf);
29 return true;
30}
31
33{
34 MOS_UNUSED(con);
35 *fg = sbi_console_fg;
36 *bg = sbi_console_bg;
37 return true;
38}
39
40static bool sbi_console_clear(Console *console)
41{
42 MOS_UNUSED(console);
43 sbi_putstring("\033[2J");
44 return true;
45}
46
47// static console_ops_t sbi_console_ops = {
48// .write = sbi_console_write,
49// .get_color = sbi_console_get_color,
50// .set_color = sbi_console_set_color,
51// .clear = sbi_console_clear,
52// };
53
54// Console sbi_console = {
55// .ops = &sbi_console_ops,
56// .name = "sbi-console",
57// .caps = CONSOLE_CAP_COLOR | CONSOLE_CAP_CLEAR,
58// .default_fg = White,
59// .default_bg = Black,
60// };
should_inline void get_ansi_color(char *buf, standard_color_t fg, standard_color_t bg)
Definition ansi_colors.h:80
#define ANSI_COLOR_RESET
Definition ansi_colors.h:49
standard_color_t
Definition ansi_colors.h:18
@ White
Definition ansi_colors.h:34
@ Black
Definition ansi_colors.h:19
#define MOS_UNUSED(x)
Definition mos_global.h:65
size_t sbi_putstring(const char *str)
Definition sbi-call.cpp:46
static standard_color_t sbi_console_fg
static size_t sbi_console_write(Console *con, const char *data, size_t size)
static bool sbi_console_set_color(Console *con, standard_color_t fg, standard_color_t bg)
static standard_color_t sbi_console_bg
static bool sbi_console_clear(Console *console)
static bool sbi_console_get_color(Console *con, standard_color_t *fg, standard_color_t *bg)
size_t size
Definition slab.cpp:34