MOS Source Code
Loading...
Searching...
No Matches
sbi_console.c
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.h>
10
12
13static size_t sbi_console_write(console_t *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_t *console)
41{
42 MOS_UNUSED(console);
43 sbi_putstring("\033[2J");
44 return true;
45}
46
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
55 .ops = &sbi_console_ops,
56 .name = "sbi-console",
58 .default_fg = White,
59 .default_bg = Black,
60};
@ CONSOLE_CAP_COLOR
Definition console.h:15
@ CONSOLE_CAP_CLEAR
Definition console.h:16
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:64
size_t sbi_putstring(const char *str)
Definition sbi-call.c:46
static size_t sbi_console_write(console_t *con, const char *data, size_t size)
Definition sbi_console.c:13
console_t sbi_console
Definition sbi_console.c:54
static bool sbi_console_get_color(console_t *con, standard_color_t *fg, standard_color_t *bg)
Definition sbi_console.c:32
static bool sbi_console_clear(console_t *console)
Definition sbi_console.c:40
static standard_color_t sbi_console_fg
Definition sbi_console.c:11
static bool sbi_console_set_color(console_t *con, standard_color_t fg, standard_color_t bg)
Definition sbi_console.c:20
static console_ops_t sbi_console_ops
Definition sbi_console.c:47
static standard_color_t sbi_console_bg
Definition sbi_console.c:11
size_t size
Definition slab.c:30