-
Notifications
You must be signed in to change notification settings - Fork 3
/
SDL_console.h
69 lines (59 loc) · 1.59 KB
/
SDL_console.h
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
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef SDL_CONSOLE
#define SDL_CONSOLE
struct _SDL_console_tty;
typedef struct _SDL_console_tty Console_tty;
typedef int (*Console_InputFunction)(const char *, void*, char **);
typedef struct _console_color {
float r, g, b, a;
} Console_Color;
/*
* Create the console.
* The console will load the font at `font_path'. The font path *must* be a
* monospaced or fixed-width.
* The `trigger_key' is the keyboard key that toggles the console on and off.
* `input_func' is the function that uses the input to the console and
* `input_func_data' is userdata given to that function.
* Returns NULL on error.
*/
Console_tty*
Console_Create (SDL_Window *window,
const char *font_path,
const int font_size,
SDL_Keycode trigger_key,
Console_InputFunction input_func,
void *input_func_data);
/*
* In the `input_func`, this function handles memory for output and should
* be used instead of malloc, realloc, etc.
*/
void
Console_SetOutput (char **out, const char *s);
/*
* Set the background color of the console.
* Default is 0.0f, 0.0f, 0.0f, 0.90f.
*/
void
Console_SetBackgroundColor (Console_tty *tty, Console_Color);
/*
* Set the font color.
* Default is 1.0f, 1.0f, 1.0f, 1.0f.
*/
void
Console_SetFontColor (Console_tty *tty, Console_Color);
/*
* Handle drawing the console if it is toggled.
* Returns 1 on an error, 0 otherwise.
*/
int
Console_Draw (Console_tty *tty);
/*
* Clean up the console.
*/
void
Console_Destroy (Console_tty* tty);
/*
* Get the last error.
*/
const char*
Console_GetError (void);
#endif