13 #include <io/imaging.h>
14 #include <io/colors.h>
15 #include <lib/stdio.h>
17 #include <drv/input/keymap.h>
22 uint32_t bakMenu = -1;
25 drawLine(2,TUI_BASE_COLOR_HEAD);
26 char* OSNAME =
" SayoriOS v0.3.5 (Dev)";
29 tty_puts_color(OSNAME,getColorsTUI(
false), TUI_BASE_COLOR_HEAD);
32 char* TIME =
"10/10/2022 12:23";
33 setPosX((getMaxStrLineTUI()-16)*8);
35 drawRect((getMaxStrLineTUI()-16)*8,16,18*8, 16,TUI_BASE_COLOR_HEAD);
36 tty_puts_color(TIME,getColorsTUI(
false), TUI_BASE_COLOR_HEAD);
43 substr(infoCPU,
"CPU: sgetNameBrand()", 0, (getMaxListMenuTUI()/2)-2);
44 tty_puts_color(infoCPU,getColorsTUI(
false), getColorsTUI(
true));
50 tty_puts_color(infoRAM,getColorsTUI(
false), getColorsTUI(
true));
55 substr(infoVideo,
"Video: Basic video adapter (Unknown)", 0, (getMaxListMenuTUI()/2)-2);
56 tty_puts_color(infoVideo,getColorsTUI(
false), getColorsTUI(
true));
60 char infoDisplay[512];
61 substr(infoDisplay,
"Display", 0, (getMaxListMenuTUI()/2)-2);
62 tty_puts_color(infoDisplay,getColorsTUI(
false), getColorsTUI(
true));
65 void footBar(
char* text){
66 drawRect(0,getHeightScreen()-16,1024,getHeightScreen(),VESA_LIGHT_GREY);
69 tty_puts_color(text,VESA_BLACK, VESA_LIGHT_GREY);
79 setPosX((getMaxStrLineTUI()-20)*8);
82 drawRect((getMaxStrLineTUI()-16)*8,0,20*8, 15, TUI_BASE_COLOR_HEAD);
122 if (getCharRaw() != 0){
130 void menu0(
bool items){
132 setCurrentItemTUI(0);
134 addItem(
"Info PC",
true,
"",
"");
135 addItem(
"List PCI-Devices",
true,
"",
"");
136 addItem(
"Application List",
true,
"",
"");
137 addItem(
"Exit to Console",
false,
"",
"");
138 addItem(
"Reboot",
false,
"",
"");
139 addItem(
"Shutdown",
false,
"",
"");
143 createMenuBox(
"Base menu:");
147 void menu1(
bool items){
149 setCurrentItemTUI(0);
151 addItem(
"OS: SayoriOS v0.3.5 (Dev)",
true,
"",
"");
152 addItem(
"CPU: CX",
true,
"",
"");
153 addItem(
"RAM: ASD kb",
true,
"",
"");
154 addItem(
"Display: %s",
true,
"",
"");
155 addItem(
"Video: Basic video adapter (Unknown)",
true,
"",
"");
156 addItem(
"Back",
false,
"",
"");
160 createMenuBox(
"System Info");
165 addItem(
"Yes, close TShell",
false,
"",
"");
166 addItem(
"No, I don't want to log out of TShell",
false,
"",
"");
169 createMenuBox(
"Are you sure you want to quit TShell?");
172 void menuGen(
bool items){
173 uint32_t h = curMenu;
183 uint32_t menuHandler(){
184 uint32_t h = curMenu;
185 uint32_t i = getCurrentItemTUI();
186 qemu_printf(
"[menuHandler] Handler: %d | Item: %d\n",h,i);
187 if (h == 0 && i == 0){
190 }
else if (h == 0 && i == 1){
191 createErrorBox(
"Error in TShell. ",
"This functionality has not yet been implemented.");
193 cleanWorkSpace(TUI_BASE_COLOR_BODY);
197 }
else if (h == 0 && i == 2){
198 createErrorBox(
"Error in TShell. ",
"This functionality has not yet been implemented.");
200 cleanWorkSpace(TUI_BASE_COLOR_BODY);
204 }
else if ((h == 0 && i == 3) || (h == -2 && i == 0)){
206 }
else if (h == -2 && i == 1){
207 cleanWorkSpace(TUI_BASE_COLOR_BODY);
208 setModeTUI(TUI_DEFAULT);
210 }
else if (h == 0 && i == 4){
213 }
else if (h == 0 && i == 5){
216 }
else if (h == 1 && i == 5){
229 if (
getTicks() < getLastUpdateTUI()){
235 if (getModeTUI() == TUI_ERROR_BOX){
237 }
else if (getModeTUI() == TUI_MENU_BOX){
239 if (getCharRaw() == KEY_ENTER){
241 uint32_t handler = menuHandler();
248 }
else if (getCharRaw() == KEY_UP){
249 setCurrentItemTUI(getCurrentItemTUI()-1);
251 if (getCurrentItemTUI() < 0){
252 setCurrentItemTUI(getMaxListMenuTUI()-1);
255 }
else if (getCharRaw() == KEY_DOWN){
257 setCurrentItemTUI(getCurrentItemTUI()+1);
258 if (getCurrentItemTUI() >= getMaxListMenuTUI()){
259 setCurrentItemTUI(0);
262 }
else if (getCharRaw() == KEY_ESC){
267 cleanWorkSpace(TUI_BASE_COLOR_BODY);
268 setModeTUI(TUI_DEFAULT);
276 }
else if (getCharRaw() == KEY_ESC){
281 }
else if (getCharRaw() == KEY_START || getCharRaw()== KEY_F1){
287 }
else if (getCharRaw() == KEY_F12){
289 createErrorBox(
"Error in TUI module. ",
"You will be returned to the console in 1 seconds.");
301 drawRectLine(0,16*2,getWidthScreen(),getWorkSpaceHeightTUI()+32,VESA_WHITE,VESA_LIGHT_GREY,1);
304 cleanWorkSpace(TUI_BASE_COLOR_BODY);
307 footBar(
" Press 'Start' to open menu");
void substr(char *restrict dest, const char *restrict source, int from, int length)
Вырезает и возвращает подстроку из строки
void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color)
Рисуем залитый прямоугольник
void drawRectLine(int x, int y, int w, int h, int color, int color2, int c)
Рисует узор вокруг прямоугольника
void qemu_printf(const char *text,...)
Вывод QEMU через COM1 информации
void shutdown()
Выключение устройства
void reboot()
Перезагрузка устройства
size_t getTicks()
Получить количество тиков
void sleep_ms(uint32_t milliseconds)
Ожидание по миллисекундам
uint32_t getPosY()
Получение позиции по y.
uint32_t getPosX()
Получение позиции по x.
void setPosX(uint32_t x)
Изменяем позицию курсора по X.
void setPosY(uint32_t y)
Изменяем позицию курсора по Y.
void tty_setcolor(uint32_t color)
Изменение цвета текста