-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcorelib.h
143 lines (119 loc) · 3.62 KB
/
corelib.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef _CORELIB_H
#define _CORELIB_H
#include <knightos/display.h>
#include <errno.h>
#include <stdbool.h>
#define _CORELIB_ID 0x02
#define CHARSET_UPPER 0
#define CHARSET_LOWER 1
#define CHARSET_SYMBOL 2
#define CHARSET_EXTENDED 3
#define CHARSET_HEX 4
/** Flags for draw_window **/
#define WIN_DEFAULTS 0
#define WIN_SKIP_LAUNCHER 1
#define WIN_SKIP_THREADLIST 2
#define WIN_SHOW_MENU 4
/**
* Similar to the kernels getKey but listens for hotkeys
**/
#define _CORELIB_APPGETKEY 6
unsigned char app_get_key(unsigned char *lost_focus);
/**
* Similar to the kernels waitKey but listens for hotkeys
**/
#define _CORELIB_APPWAITKEY 9
unsigned char app_wait_key(unsigned char *lost_focus);
/**
* Draws the corelib window.
**/
#define _CORELIB_DRAWWINDOW 12
void draw_window(SCREEN *screen, const char *title, unsigned char flags);
/**
* Gets a key input from the user. The function returns the ANSI key, while &raw_key is loaded with the raw keycode
* Note: handles draw_charset_indicator() for you
**/
#define _CORELIB_GETCHARACTERINPUT 15
char get_character_input(unsigned char *raw_key);
/**
* Draws the charset indicator in the top right
**/
#define _CORELIB_DRAWCHARSETINDICATOR 18
void draw_charset_indicator();
/**
* Sets the charset
* Note: You can use CHARSET_UPPER, CHARSET_LOWER, CHARSET_SYMBOL, CHARSET_EXTENDED, and CHARSET_HEX
* all of which are defined at the top of this file.
**/
#define _CORELIB_SETCHARSET 21
void set_charset(unsigned char charset);
/**
* Returns the current charset
**/
#define _CORELIB_GETCHARSET 24
unsigned char get_charset();
/**
* Launches the launcher
**/
#define _CORELIB_LAUNCHCASTLE 27
void launch_castle();
/**
* Launches the threadlist
**/
#define _CORELIB_LAUNCHTHREADLIST 30
void launch_threadlist();
/**
* Shows a message prompt.
* message is the message shown
* message_list is a string as such: "\x02Option 1\x00Option 2\x00"
**/
#define _CORELIB_SHOWMESSAGE 33
unsigned char show_message(SCREEN *screen, const char *message, const char *message_list, unsigned char icon);
/**
* Displays an error. A list of kernel errors can be found in errno.h
**/
#define _CORELIB_SHOWERROR 36
void show_error(SCREEN *screen, int errno);
/**
* Displays an error and quits. A list of kernel errors can be found in errno.h
**/
#define _CORELIB_SHOWERRORANDQUIT 39
void show_error_and_quit(SCREEN *screen, int errno);
/**
* Launches a file
* More information: https://github.com/KnightOS/KnightOS/issues/143
**/
#define _CORELIB_OPEN 42
bool open_file(const char *path);
/**
* Draws a scrollbar.
**/
#define _CORELIB_DRAWSCROLLBAR 45
void draw_scrollbar(SCREEN *screen, unsigned char length, unsigned char scroll);
/**
* Opens a prompt. Returns 0 (false) if canceled and 1 (true) if accepted.
* &buffer is loaded with the result if accepted
* prompt_string is the title of the dialog
**/
#define _CORELIB_PROMPTSTRING 48
bool prompt_string(SCREEN *screen, unsigned short buffer_length, const char *prompt_string, char *buffer);
/**
* Initializes an F3 menu.
* menu is a string such as "\x03Info\x00Tasks\x00RAM\x00"
* Note: draw_windows flag should be '0x02' so it draws the menu graphic on the bottom bar
**/
#define _CORELIB_SHOWMENU 51
char show_menu(SCREEN *screen, const char *menu, unsigned char width);
/**
* Draws a string but wraps at words
**/
#define _CORELIB_WORDWRAP 54
void draw_string_word_wrap(SCREEN *screen, const char *text, unsigned char x, unsigned char y, unsigned char x_max, unsigned char y_max);
/**
* Draws a set of tabs.
* Tabs is a string such as "\x04Info\x00 Tasks\x00 RAM\x00 Flash\x00"
* Tab is the current tab
**/
#define _CORELIB_DRAWTABS 57
void draw_tabs(SCREEN *screen, const char *tabs, const char *tab);
#endif