2 #include "drv/vfs_new.h"
3 #include "drv/input/keyboard.h"
4 #include "gui/basics.h"
7 #include "sys/trigger.h"
8 #include "drv/input/keymap.h"
9 #include "lib/string.h"
13 char dino_cur_path[1024] =
"/";
14 struct dirent* dino_cur_dirent =
nullptr;
15 size_t dino_dirent_count = 0;
16 size_t dino_current_selection = 0;
18 void dino_draw_back() {
19 draw_filled_rectangle(0, 0, VESA_WIDTH, VESA_HEIGHT, 0x444444);
20 draw_filled_rectangle(40, 40, VESA_WIDTH - 80, VESA_HEIGHT - 80, 0x666666);
23 void dino_draw_panels() {
27 void dino_draw_main() {
30 50 + (dino_current_selection * 16),
31 strlen(dino_cur_dirent[dino_current_selection].
name) * 8,
37 for(
int i = 0; i < dino_dirent_count; i++) {
38 struct dirent elem = dino_cur_dirent[i];
40 draw_vga_str(elem.
name,
strlen(elem.
name), 50, 50 + (i * 16), 0x111111);
45 dino_cur_dirent = vfs_getListFolder(dino_cur_path);
46 dino_dirent_count = vfs_getCountElemDir(dino_cur_path);
49 void dino_path_check() {
52 size_t len =
strlen(dino_cur_path);
55 for(
int i = 0; i < len; i++) {
56 if(dino_cur_path[i] ==
'/') {
60 memmove(dino_cur_path + i, dino_cur_path + i + 1, len - i);
68 void dino_keyhandler(
int key,
int pressed,
int c,
int d,
int e) {
71 dino_current_selection = ((dino_current_selection + 1) % dino_dirent_count);
72 else if(key == KEY_UP)
73 dino_current_selection = dino_current_selection == 0 ? dino_dirent_count - 1 : dino_current_selection - 1;
74 else if(key == KEY_ENTER) {
75 qemu_log(
"You selected: %s", dino_cur_dirent[dino_current_selection].
name);
77 strcat(dino_cur_path, dino_cur_dirent[dino_current_selection].
name);
81 qemu_log(
"Path: %s", dino_cur_path);
83 dino_current_selection = 0;
90 uint32_t dino_filemanager(
int argc,
char* argv[]) {
93 keyboardctl(KEYBOARD_ECHO,
false);
95 RegTrigger(TRIGGER_KEY_PRESSED, (trigger_cmd_t)dino_keyhandler);
98 int key = getCharRaw();
111 keyboardctl(KEYBOARD_ECHO,
true);
Основные определения ядра
size_t strlen(const char *str)
Возращает длину строки
void * memmove(void *dest, void *src, size_t count)
Копирование массивов (в том числе пересекающихся)
char * strcat(char *destination, const char *source)
Объединение строк
Согласно POSIX, один из них возвращается вызовом readdir.
int RegTrigger(int type, trigger_cmd_t handler)
Регистрация триггера