summaryrefslogtreecommitdiff
path: root/src/user/include/terminal/terminal.h
blob: 17821730d5440f66d5475d6dac01425f064a8bb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef TERMINAL_TERMINAL_H
#define TERMINAL_TERMINAL_H

#include <libfont/fonts.h>

#include <pland/syscall.h>

#include <stdarg.h>
#include <stdint.h>

struct terminal {
  _window_handle_t window;
  uint8_t *pixbuf;
  uint32_t window_width;
  uint32_t window_height;

  struct font_info *font;

  uint32_t cols;
  uint32_t rows;
  char *charbuf;

  uint32_t cursor_y;
  uint32_t cursor_x;

  uint8_t fg;
  uint8_t bg;
};

struct terminal *make_term(struct font_info *font, uint32_t cols, uint32_t rows);
void del_term(struct terminal *term);

extern struct terminal *active_term;

void paint_term();

void set_color(uint8_t fg, uint8_t bg);
void clear_term();

void move_cursor(uint32_t new_y, uint32_t new_x);

void cursor_left();
void cursor_right();
void cursor_up();
void cursor_down();

void term_newline();
void term_add_char(char ch);
void term_add_sz_no_ww(const char *sz);
void term_add_sz(const char *sz);

void term_addf_no_ww_v(const char *fmt, va_list args);
void term_addf_no_ww(const char *fmt, ...);
void term_addf_v(const char *fmt, va_list args);
void term_addf(const char *fmt, ...);

#endif