diff --git a/boredos.iso b/boredos.iso deleted file mode 100644 index dc47951..0000000 Binary files a/boredos.iso and /dev/null differ diff --git a/build/boot.o b/build/boot.o deleted file mode 100644 index 2d5e0e8..0000000 Binary files a/build/boot.o and /dev/null differ diff --git a/build/boredos.elf b/build/boredos.elf deleted file mode 100755 index 7a8a08c..0000000 Binary files a/build/boredos.elf and /dev/null differ diff --git a/build/cli_apps/beep.o b/build/cli_apps/beep.o deleted file mode 100644 index 0841089..0000000 Binary files a/build/cli_apps/beep.o and /dev/null differ diff --git a/build/cli_apps/blind.o b/build/cli_apps/blind.o deleted file mode 100644 index d8adde2..0000000 Binary files a/build/cli_apps/blind.o and /dev/null differ diff --git a/build/cli_apps/boredver.o b/build/cli_apps/boredver.o deleted file mode 100644 index f12cb06..0000000 Binary files a/build/cli_apps/boredver.o and /dev/null differ diff --git a/build/cli_apps/cc.o b/build/cli_apps/cc.o deleted file mode 100644 index dc79ed0..0000000 Binary files a/build/cli_apps/cc.o and /dev/null differ diff --git a/build/cli_apps/clear.o b/build/cli_apps/clear.o deleted file mode 100644 index 888ffe3..0000000 Binary files a/build/cli_apps/clear.o and /dev/null differ diff --git a/build/cli_apps/cli_utils.o b/build/cli_apps/cli_utils.o deleted file mode 100644 index e4ac893..0000000 Binary files a/build/cli_apps/cli_utils.o and /dev/null differ diff --git a/build/cli_apps/cowsay.o b/build/cli_apps/cowsay.o deleted file mode 100644 index 2caa5bc..0000000 Binary files a/build/cli_apps/cowsay.o and /dev/null differ diff --git a/build/cli_apps/date.o b/build/cli_apps/date.o deleted file mode 100644 index 009b603..0000000 Binary files a/build/cli_apps/date.o and /dev/null differ diff --git a/build/cli_apps/exit.o b/build/cli_apps/exit.o deleted file mode 100644 index a6d4712..0000000 Binary files a/build/cli_apps/exit.o and /dev/null differ diff --git a/build/cli_apps/fs_commands.o b/build/cli_apps/fs_commands.o deleted file mode 100644 index 6092bd7..0000000 Binary files a/build/cli_apps/fs_commands.o and /dev/null differ diff --git a/build/cli_apps/help.o b/build/cli_apps/help.o deleted file mode 100644 index 4db6733..0000000 Binary files a/build/cli_apps/help.o and /dev/null differ diff --git a/build/cli_apps/man.o b/build/cli_apps/man.o deleted file mode 100644 index 1d4356c..0000000 Binary files a/build/cli_apps/man.o and /dev/null differ diff --git a/build/cli_apps/math.o b/build/cli_apps/math.o deleted file mode 100644 index c10e5fb..0000000 Binary files a/build/cli_apps/math.o and /dev/null differ diff --git a/build/cli_apps/memcmd.o b/build/cli_apps/memcmd.o deleted file mode 100644 index bc720ce..0000000 Binary files a/build/cli_apps/memcmd.o and /dev/null differ diff --git a/build/cli_apps/meminfo.o b/build/cli_apps/meminfo.o deleted file mode 100644 index 8141507..0000000 Binary files a/build/cli_apps/meminfo.o and /dev/null differ diff --git a/build/cli_apps/net.o b/build/cli_apps/net.o deleted file mode 100644 index 67e834c..0000000 Binary files a/build/cli_apps/net.o and /dev/null differ diff --git a/build/cli_apps/pci_list.o b/build/cli_apps/pci_list.o deleted file mode 100644 index 698499e..0000000 Binary files a/build/cli_apps/pci_list.o and /dev/null differ diff --git a/build/cli_apps/readtheman.o b/build/cli_apps/readtheman.o deleted file mode 100644 index f9ba629..0000000 Binary files a/build/cli_apps/readtheman.o and /dev/null differ diff --git a/build/cli_apps/reboot.o b/build/cli_apps/reboot.o deleted file mode 100644 index 43b0147..0000000 Binary files a/build/cli_apps/reboot.o and /dev/null differ diff --git a/build/cli_apps/shutdown.o b/build/cli_apps/shutdown.o deleted file mode 100644 index eab7135..0000000 Binary files a/build/cli_apps/shutdown.o and /dev/null differ diff --git a/build/cli_apps/sweden.o b/build/cli_apps/sweden.o deleted file mode 100644 index e131fe0..0000000 Binary files a/build/cli_apps/sweden.o and /dev/null differ diff --git a/build/cli_apps/uptime.o b/build/cli_apps/uptime.o deleted file mode 100644 index 88b6f16..0000000 Binary files a/build/cli_apps/uptime.o and /dev/null differ diff --git a/build/interrupts.o b/build/interrupts.o deleted file mode 100644 index e5c299b..0000000 Binary files a/build/interrupts.o and /dev/null differ diff --git a/build/tcp.o b/build/tcp.o deleted file mode 100644 index 5edd796..0000000 Binary files a/build/tcp.o and /dev/null differ diff --git a/build/vm.o b/build/vm.o deleted file mode 100644 index bd554a4..0000000 Binary files a/build/vm.o and /dev/null differ diff --git a/build/wallpaper.o b/build/wallpaper.o deleted file mode 100644 index a732684..0000000 Binary files a/build/wallpaper.o and /dev/null differ diff --git a/build/wallpaper_data.o b/build/wallpaper_data.o deleted file mode 100644 index ffef5eb..0000000 Binary files a/build/wallpaper_data.o and /dev/null differ diff --git a/build/wm.o b/build/wm.o deleted file mode 100644 index 866a90f..0000000 Binary files a/build/wm.o and /dev/null differ diff --git a/disk.img b/disk.img index 019c32a..0236a21 100644 Binary files a/disk.img and b/disk.img differ diff --git a/iso_root/EFI/BOOT/BOOTIA32.EFI b/iso_root/EFI/BOOT/BOOTIA32.EFI deleted file mode 100644 index 93716eb..0000000 Binary files a/iso_root/EFI/BOOT/BOOTIA32.EFI and /dev/null differ diff --git a/iso_root/EFI/BOOT/BOOTX64.EFI b/iso_root/EFI/BOOT/BOOTX64.EFI deleted file mode 100644 index 7b1fc18..0000000 Binary files a/iso_root/EFI/BOOT/BOOTX64.EFI and /dev/null differ diff --git a/iso_root/bin/calculator.elf b/iso_root/bin/calculator.elf deleted file mode 100755 index 69b143c..0000000 Binary files a/iso_root/bin/calculator.elf and /dev/null differ diff --git a/iso_root/bin/crash.elf b/iso_root/bin/crash.elf deleted file mode 100755 index b4c2d1c..0000000 Binary files a/iso_root/bin/crash.elf and /dev/null differ diff --git a/iso_root/bin/hello.elf b/iso_root/bin/hello.elf deleted file mode 100755 index 3a28dda..0000000 Binary files a/iso_root/bin/hello.elf and /dev/null differ diff --git a/iso_root/bin/markdown.elf b/iso_root/bin/markdown.elf deleted file mode 100755 index 541c80b..0000000 Binary files a/iso_root/bin/markdown.elf and /dev/null differ diff --git a/iso_root/bin/minesweeper.elf b/iso_root/bin/minesweeper.elf deleted file mode 100755 index ca1d740..0000000 Binary files a/iso_root/bin/minesweeper.elf and /dev/null differ diff --git a/iso_root/bin/notepad.elf b/iso_root/bin/notepad.elf deleted file mode 100755 index 0452686..0000000 Binary files a/iso_root/bin/notepad.elf and /dev/null differ diff --git a/iso_root/bin/paint.elf b/iso_root/bin/paint.elf deleted file mode 100755 index df2ef8e..0000000 Binary files a/iso_root/bin/paint.elf and /dev/null differ diff --git a/iso_root/bin/settings.elf b/iso_root/bin/settings.elf deleted file mode 100755 index d970c4d..0000000 Binary files a/iso_root/bin/settings.elf and /dev/null differ diff --git a/iso_root/bin/txtedit.elf b/iso_root/bin/txtedit.elf deleted file mode 100755 index 101de91..0000000 Binary files a/iso_root/bin/txtedit.elf and /dev/null differ diff --git a/iso_root/bin/viewer.elf b/iso_root/bin/viewer.elf deleted file mode 100755 index 8589e4d..0000000 Binary files a/iso_root/bin/viewer.elf and /dev/null differ diff --git a/iso_root/boredos.elf b/iso_root/boredos.elf deleted file mode 100755 index 7a8a08c..0000000 Binary files a/iso_root/boredos.elf and /dev/null differ diff --git a/iso_root/limine-bios-cd.bin b/iso_root/limine-bios-cd.bin deleted file mode 100644 index 2d1601a..0000000 Binary files a/iso_root/limine-bios-cd.bin and /dev/null differ diff --git a/iso_root/limine-bios.sys b/iso_root/limine-bios.sys deleted file mode 100644 index 8a59e13..0000000 Binary files a/iso_root/limine-bios.sys and /dev/null differ diff --git a/iso_root/limine-uefi-cd.bin b/iso_root/limine-uefi-cd.bin deleted file mode 100644 index f4420a5..0000000 Binary files a/iso_root/limine-uefi-cd.bin and /dev/null differ diff --git a/iso_root/limine.conf b/iso_root/limine.conf deleted file mode 100644 index 533f42f..0000000 --- a/iso_root/limine.conf +++ /dev/null @@ -1,17 +0,0 @@ -timeout: 3 - -/BoredOS - protocol: limine - - kernel_path: boot():/boredos.elf - #resolution: 1280x720 - module_path: boot():/bin/calculator.elf - module_path: boot():/bin/crash.elf - module_path: boot():/bin/hello.elf - module_path: boot():/bin/markdown.elf - module_path: boot():/bin/minesweeper.elf - module_path: boot():/bin/notepad.elf - module_path: boot():/bin/paint.elf - module_path: boot():/bin/settings.elf - module_path: boot():/bin/txtedit.elf - module_path: boot():/bin/viewer.elf diff --git a/src/kernel/userland/minesweeper.c b/src/kernel/userland/minesweeper.c index cc85e90..bb876b7 100644 --- a/src/kernel/userland/minesweeper.c +++ b/src/kernel/userland/minesweeper.c @@ -141,19 +141,19 @@ static void flag_cell(int x, int y) { static void minesweeper_paint(ui_window_t win) { int win_w = 240, win_h = 340; - ui_draw_rect(win, 4, 0, win_w - 8, win_h - 34, COLOR_DARK_BG); + ui_draw_rect(win, 4, 0, win_w - 8, win_h, COLOR_DARK_BG); if (game_over) { - ui_draw_string(win, 10, 6, "Game Over!", COLOR_TRAFFIC_RED); + ui_draw_string(win, 10, 4, "Game Over!", COLOR_TRAFFIC_RED); } else if (game_won) { - ui_draw_string(win, 10, 6, "You Won!", 0xFF00FF00); // Bright green + ui_draw_string(win, 10, 4, "You Won!", 0xFF00FF00); // Bright green } else { - ui_draw_string(win, 10, 6, "", COLOR_DARK_TEXT); + ui_draw_string(win, 10, 4, "", COLOR_DARK_TEXT); } // Draw grid int grid_start_x = 10; - int grid_start_y = 26; + int grid_start_y = 22; for (int y = 0; y < GRID_HEIGHT; y++) { for (int x = 0; x < GRID_WIDTH; x++) { @@ -191,7 +191,7 @@ static void minesweeper_paint(ui_window_t win) { static void minesweeper_handle_click(ui_window_t win, int x, int y, int button) { int grid_start_x = 10; - int grid_start_y = 26; + int grid_start_y = 22; int btn_y = grid_start_y + GRID_HEIGHT * CELL_SIZE + 10; // Check "New Game" button @@ -211,10 +211,8 @@ static void minesweeper_handle_click(ui_window_t win, int x, int y, int button) int cell_y = (y - grid_start_y) / CELL_SIZE; if (button == GUI_EVENT_RIGHT_CLICK) { - debug_print("[MINESWEEPER] Flagging cell"); flag_cell(cell_x, cell_y); } else { - debug_print("[MINESWEEPER] Revealing cell"); reveal_cell(cell_x, cell_y); } } @@ -236,12 +234,10 @@ int main(int argc, char **argv) { minesweeper_paint(win); ui_mark_dirty(win, 0, 0, 240, 320); } else if (ev.type == GUI_EVENT_CLICK) { - debug_print("[MINESWEEPER] LEFT CLICK"); minesweeper_handle_click(win, ev.arg1, ev.arg2, ev.type); minesweeper_paint(win); ui_mark_dirty(win, 0, 0, 240, 320); } else if (ev.type == GUI_EVENT_RIGHT_CLICK) { - debug_print("[MINESWEEPER] RIGHT CLICK DETECTED"); minesweeper_handle_click(win, ev.arg1, ev.arg2, ev.type); minesweeper_paint(win); ui_mark_dirty(win, 0, 0, 240, 320); diff --git a/src/kernel/userland/minesweeper.elf b/src/kernel/userland/minesweeper.elf index ca1d740..def1804 100755 Binary files a/src/kernel/userland/minesweeper.elf and b/src/kernel/userland/minesweeper.elf differ diff --git a/src/kernel/userland/notepad.c b/src/kernel/userland/notepad.c index e63e294..25e98ac 100644 --- a/src/kernel/userland/notepad.c +++ b/src/kernel/userland/notepad.c @@ -13,7 +13,7 @@ static int cursor_pos = 0; static int notepad_scroll_line = 0; static void notepad_ensure_cursor_visible(int h) { - int visible_lines = (h - 40) / 10 + 3; + int visible_lines = (h - 10) / 10; if (visible_lines < 1) visible_lines = 1; int cursor_line = 0; @@ -53,23 +53,23 @@ static void notepad_save_state() { } static void notepad_paint(ui_window_t win, int w, int h) { - ui_draw_rect(win, 4, 30, w - 8, h - 34, COLOR_NOTEPAD_BG); + ui_draw_rect(win, 0, 0, w, h, COLOR_NOTEPAD_BG); int visual_line = 0; - int current_x = 8; - int current_y = 36; - int window_right = w - 16; + int current_x = 4; + int current_y = 4; + int window_right = w - 8; for (int i = 0; i < buf_len; i++) { if (visual_line < notepad_scroll_line) { if (buffer[i] == '\n') { visual_line++; - current_x = 8; - current_y = 36; + current_x = 4; + current_y = 4; } else { if (current_x >= window_right) { visual_line++; - current_x = 8; + current_x = 4; current_y += 10; } current_x += 8; @@ -77,21 +77,21 @@ static void notepad_paint(ui_window_t win, int w, int h) { continue; } - if (visual_line >= notepad_scroll_line + (h - 40) / 10) { + if (visual_line >= notepad_scroll_line + (h - 8) / 10) { break; } if (buffer[i] == '\n') { - current_x = 8; + current_x = 4; current_y += 10; visual_line++; } else { if (current_x >= window_right) { - current_x = 8; + current_x = 4; current_y += 10; visual_line++; - if (visual_line >= notepad_scroll_line + (h - 40) / 10) { + if (visual_line >= notepad_scroll_line + (h - 8) / 10) { break; } } @@ -103,18 +103,18 @@ static void notepad_paint(ui_window_t win, int w, int h) { } // Cursor - int cx = 8; - int cy = 36; + int cx = 4; + int cy = 4; int c_visual_line = 0; for (int i = 0; i < cursor_pos; i++) { if (buffer[i] == '\n') { - cx = 8; + cx = 4; cy += 10; c_visual_line++; } else { if (cx >= window_right) { - cx = 8; + cx = 4; cy += 10; c_visual_line++; } @@ -123,7 +123,7 @@ static void notepad_paint(ui_window_t win, int w, int h) { } if (c_visual_line >= notepad_scroll_line && - c_visual_line < notepad_scroll_line + (h - 40) / 10) { + c_visual_line < notepad_scroll_line + (h - 8) / 10) { ui_draw_rect(win, cx, cy, 2, 8, COLOR_BLACK); } diff --git a/src/kernel/userland/notepad.elf b/src/kernel/userland/notepad.elf index 0452686..7779ace 100755 Binary files a/src/kernel/userland/notepad.elf and b/src/kernel/userland/notepad.elf differ diff --git a/src/kernel/userland/settings.c b/src/kernel/userland/settings.c index bd3d566..278057d 100644 --- a/src/kernel/userland/settings.c +++ b/src/kernel/userland/settings.c @@ -137,10 +137,10 @@ static uint32_t parse_rgb_separate(const char *r, const char *g, const char *b) static void control_panel_paint_main(ui_window_t win) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; int win_w = 350; - int item_y = 15; + int item_y = 0; int item_h = 60; int item_spacing = 10; @@ -180,7 +180,7 @@ static void control_panel_paint_main(ui_window_t win) { static void control_panel_paint_wallpaper(ui_window_t win) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; ui_draw_rounded_rect_filled(win, offset_x, offset_y + 5, 80, 25, 6, COLOR_DARK_PANEL); ui_draw_string(win, offset_x + 10, offset_y + 13, "< Back", COLOR_DARK_TEXT); @@ -311,7 +311,7 @@ static void control_panel_paint_wallpaper(ui_window_t win) { static void control_panel_paint_network(ui_window_t win) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; ui_draw_rounded_rect_filled(win, offset_x, offset_y + 5, 80, 25, 6, COLOR_DARK_PANEL); ui_draw_string(win, offset_x + 10, offset_y + 13, "< Back", COLOR_DARK_TEXT); @@ -327,7 +327,7 @@ static void control_panel_paint_network(ui_window_t win) { static void control_panel_paint_desktop(ui_window_t win) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; ui_draw_rounded_rect_filled(win, offset_x, offset_y + 5, 80, 25, 6, COLOR_DARK_PANEL); ui_draw_string(win, offset_x + 10, offset_y + 13, "< Back", COLOR_DARK_TEXT); @@ -371,7 +371,7 @@ static void control_panel_paint_desktop(ui_window_t win) { static void control_panel_paint_mouse(ui_window_t win) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; ui_draw_rounded_rect_filled(win, offset_x, offset_y + 5, 80, 25, 6, COLOR_DARK_PANEL); ui_draw_string(win, offset_x + 10, offset_y + 13, "< Back", COLOR_DARK_TEXT); @@ -393,7 +393,7 @@ static void control_panel_paint_mouse(ui_window_t win) { static void control_panel_paint(ui_window_t win) { // Fill background - ui_draw_rect(win, 0, 20, 350, 480, COLOR_DARK_BG); + ui_draw_rect(win, 0, 0, 350, 500, COLOR_DARK_BG); if (current_view == VIEW_MAIN) { control_panel_paint_main(win); @@ -439,11 +439,11 @@ static void control_panel_handle_click(int x, int y) { if (current_view == VIEW_MAIN) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; int item_h = 60; int item_spacing = 10; - int item_y = offset_y + 15; + int item_y = offset_y + 0; if (x >= offset_x && x < win_w - 8 && y >= item_y && y < item_y + item_h) { current_view = VIEW_WALLPAPER; focused_field = -1; @@ -463,7 +463,7 @@ static void control_panel_handle_click(int x, int y) { } } else if (current_view == VIEW_WALLPAPER) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; int button_y = offset_y + 65; int button_x = offset_x; @@ -541,7 +541,7 @@ static void control_panel_handle_click(int x, int y) { } } else if (current_view == VIEW_NETWORK) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; if (x >= offset_x && x < offset_x + 80 && y >= offset_y + 5 && y < offset_y + 30) { current_view = VIEW_MAIN; @@ -560,7 +560,7 @@ static void control_panel_handle_click(int x, int y) { } } else if (current_view == VIEW_DESKTOP) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; if (x >= offset_x && x < offset_x + 80 && y >= offset_y + 5 && y < offset_y + 30) { current_view = VIEW_MAIN; @@ -608,7 +608,7 @@ static void control_panel_handle_click(int x, int y) { } } else if (current_view == VIEW_MOUSE) { int offset_x = 8; - int offset_y = 21; + int offset_y = 6; if (x >= offset_x && x < offset_x + 80 && y >= offset_y + 5 && y < offset_y + 30) { current_view = VIEW_MAIN; diff --git a/src/kernel/userland/settings.elf b/src/kernel/userland/settings.elf index d970c4d..3bcf1ee 100755 Binary files a/src/kernel/userland/settings.elf and b/src/kernel/userland/settings.elf differ diff --git a/src/kernel/userland/txtedit.c b/src/kernel/userland/txtedit.c index 270977b..25b42c3 100644 --- a/src/kernel/userland/txtedit.c +++ b/src/kernel/userland/txtedit.c @@ -52,7 +52,11 @@ static void editor_clear_all(void) { } static void editor_ensure_cursor_visible(void) { - int visible_lines = 22; + int header_h = 32; + int footer_h = 24; + int editor_h = win_h - header_h - footer_h; + int visible_lines = (editor_h - 10) / EDITOR_LINE_HEIGHT; + if (cursor_line < scroll_top) { scroll_top = cursor_line; } @@ -196,73 +200,76 @@ static void editor_insert_char(char ch) { } static void editor_paint(ui_window_t win) { - int offset_x = 4; - int offset_y = 0; - int content_width = win_w - 8; - int content_height = win_h - 28; + int header_h = 32; + int footer_h = 24; + int padding = 4; - // Top content bar - ui_draw_rounded_rect_filled(win, offset_x, offset_y, content_width, 25, 6, COLOR_DARK_PANEL); - ui_draw_string(win, offset_x + 10, offset_y + 6, "File", COLOR_DARK_TEXT); - ui_draw_string(win, offset_x + 55, offset_y + 6, open_filename, COLOR_DARK_TEXT); + int content_width = win_w - (padding * 2); + int editor_y = header_h; + int editor_h = win_h - header_h - footer_h; + + // Header bar + ui_draw_rounded_rect_filled(win, padding, 2, content_width, header_h - 4, 6, COLOR_DARK_PANEL); + ui_draw_string(win, padding + 10, 8, "File", COLOR_DARK_TEXT); + ui_draw_string(win, padding + 60, 8, open_filename, COLOR_DARK_TEXT); // Save button - int save_btn_x = offset_x + content_width - 80; - int save_btn_y = offset_y + 3; - ui_draw_rounded_rect_filled(win, save_btn_x, save_btn_y, 70, 20, 6, COLOR_DARK_BORDER); - ui_draw_string(win, save_btn_x + 20, save_btn_y + 6, "Save", COLOR_DARK_TEXT); + int save_btn_w = 70; + int save_btn_h = 22; + int save_btn_x = padding + content_width - save_btn_w - 5; + int save_btn_y = 3; + ui_draw_rounded_rect_filled(win, save_btn_x, save_btn_y, save_btn_w, save_btn_h, 6, COLOR_DARK_BORDER); + ui_draw_string(win, save_btn_x + 18, save_btn_y + 4, "Save", COLOR_DARK_TEXT); if (file_modified) { - ui_draw_string(win, offset_x + content_width - 200, offset_y + 5, "[Modified]", COLOR_RED); + ui_draw_string(win, padding + content_width - 180, 8, "[Modified]", COLOR_RED); } // Editor background - ui_draw_rect(win, 4, 54, win_w - 8, win_h - 58, COLOR_DARK_BG); + ui_draw_rect(win, padding, editor_y, content_width, editor_h, COLOR_DARK_BG); - int text_start_x = offset_x + 40; + int text_start_x = padding + 40; int available_width = content_width - 40; int max_chars_per_line = available_width / EDITOR_CHAR_WIDTH; if (max_chars_per_line < 1) max_chars_per_line = 1; - int display_line = 0; - int visible_lines = (content_height - 55) / EDITOR_LINE_HEIGHT; + int visible_lines = (editor_h - 10) / EDITOR_LINE_HEIGHT; int max_display_lines = visible_lines; + int display_line = 0; int line_idx = scroll_top; while (line_idx < line_count && display_line < max_display_lines) { - int display_y = offset_y + 35 + display_line * EDITOR_LINE_HEIGHT; + int display_y = editor_y + 5 + display_line * EDITOR_LINE_HEIGHT; - if (display_line == 0 || line_idx < line_count) { - char line_num_str[16]; - int temp = line_idx + 1; - int str_len = 0; - if (temp == 0) { - line_num_str[0] = '0'; - str_len = 1; - } else { - while (temp > 0) { - line_num_str[str_len++] = (temp % 10) + '0'; - temp /= 10; - } - for (int j = 0; j < str_len / 2; j++) { - char t = line_num_str[j]; - line_num_str[j] = line_num_str[str_len - 1 - j]; - line_num_str[str_len - 1 - j] = t; - } + // Line number + char line_num_str[16]; + int temp = line_idx + 1; + int str_len = 0; + if (temp == 0) { + line_num_str[0] = '0'; + str_len = 1; + } else { + while (temp > 0) { + line_num_str[str_len++] = (temp % 10) + '0'; + temp /= 10; + } + for (int j = 0; j < str_len / 2; j++) { + char t = line_num_str[j]; + line_num_str[j] = line_num_str[str_len - 1 - j]; + line_num_str[str_len - 1 - j] = t; } - line_num_str[str_len] = 0; - ui_draw_string(win, offset_x + 4, display_y, line_num_str, COLOR_DKGRAY); } + line_num_str[str_len] = 0; + ui_draw_string(win, padding + 4, display_y, line_num_str, COLOR_DKGRAY); const char *text = lines[line_idx].content; int text_len = lines[line_idx].length; int char_idx = 0; - int local_display_line = 0; _Bool first_pass = 1; while ((char_idx < text_len || (text_len == 0 && first_pass)) && display_line < max_display_lines) { first_pass = 0; - int current_display_y = offset_y + 35 + display_line * EDITOR_LINE_HEIGHT; + int current_display_y = editor_y + 5 + display_line * EDITOR_LINE_HEIGHT; char segment[256]; int segment_len = 0; @@ -273,6 +280,7 @@ static void editor_paint(ui_window_t win) { } segment[segment_len] = 0; + // Basic word wrap if (char_idx < text_len && segment_len > 0) { int last_space = -1; for (int i = segment_len - 1; i >= 0; i--) { @@ -285,9 +293,6 @@ static void editor_paint(ui_window_t win) { segment_len = last_space; segment[segment_len] = 0; char_idx = segment_start + last_space + 1; - while (char_idx < text_len && text[char_idx] == ' ') { - char_idx++; - } } } @@ -310,48 +315,38 @@ static void editor_paint(ui_window_t win) { } display_line++; - local_display_line++; if (char_idx >= text_len) break; } line_idx++; } - int status_y = offset_y + content_height - 20; - ui_draw_rounded_rect_filled(win, offset_x, status_y, content_width, 20, 6, COLOR_DARK_PANEL); - ui_draw_string(win, offset_x + 10, status_y + 5, "Line: ", COLOR_DARK_TEXT); + // Status bar + int status_y = win_h - footer_h; + ui_draw_rounded_rect_filled(win, padding, status_y + 2, content_width, footer_h - 4, 6, COLOR_DARK_PANEL); + + char status_text[128]; + // Simple manual sprintf-like functionality for BoredOS userspace + // We'll just draw parts for now as before but cleaned up + ui_draw_string(win, padding + 15, status_y + 5, "Line:", COLOR_DKGRAY); char line_str[32]; int temp = cursor_line + 1; int idx = 0; - while (temp > 0) { - line_str[idx++] = (temp % 10) + '0'; - temp /= 10; - } - for (int j = 0; j < idx / 2; j++) { - char t = line_str[j]; - line_str[j] = line_str[idx - 1 - j]; - line_str[idx - 1 - j] = t; - } + while (temp > 0) { line_str[idx++] = (temp % 10) + '0'; temp /= 10; } + if (idx == 0) line_str[idx++] = '0'; + for (int j = 0; j < idx / 2; j++) { char t = line_str[j]; line_str[j] = line_str[idx - 1 - j]; line_str[idx - 1 - j] = t; } line_str[idx] = 0; + ui_draw_string(win, padding + 65, status_y + 5, line_str, COLOR_DARK_TEXT); - ui_draw_string(win, offset_x + 60, status_y + 5, line_str, COLOR_DARK_TEXT); - ui_draw_string(win, offset_x + 100, status_y + 5, " Col: ", COLOR_DARK_TEXT); - + ui_draw_string(win, padding + 120, status_y + 5, "Col:", COLOR_DKGRAY); char col_str[32]; temp = cursor_col + 1; idx = 0; - while (temp > 0) { - col_str[idx++] = (temp % 10) + '0'; - temp /= 10; - } - for (int j = 0; j < idx / 2; j++) { - char t = col_str[j]; - col_str[j] = col_str[idx - 1 - j]; - col_str[idx - 1 - j] = t; - } + while (temp > 0) { col_str[idx++] = (temp % 10) + '0'; temp /= 10; } + if (idx == 0) col_str[idx++] = '0'; + for (int j = 0; j < idx / 2; j++) { char t = col_str[j]; col_str[j] = col_str[idx - 1 - j]; col_str[idx - 1 - j] = t; } col_str[idx] = 0; - - ui_draw_string(win, offset_x + 170, status_y + 5, col_str, COLOR_DARK_TEXT); + ui_draw_string(win, padding + 160, status_y + 5, col_str, COLOR_DARK_TEXT); } static void editor_handle_key(char c) { @@ -365,8 +360,7 @@ static void editor_handle_key(char c) { if (cursor_line < line_count - 1) { cursor_line++; if (cursor_col > lines[cursor_line].length) cursor_col = lines[cursor_line].length; - int visible_lines = 20; - if (cursor_line >= scroll_top + visible_lines) scroll_top = cursor_line - visible_lines + 1; + editor_ensure_cursor_visible(); } } else if (c == 19) { // LEFT if (cursor_col > 0) { @@ -388,11 +382,14 @@ static void editor_handle_key(char c) { } static void editor_handle_click(int x, int y) { - int content_width = win_w - 8; - int button_x = 4 + content_width - 80; - int button_y = 3; + int padding = 4; + int content_width = win_w - (padding * 2); + int save_btn_w = 70; + int save_btn_x = padding + content_width - save_btn_w - 5; + int save_btn_y = 3; + int save_btn_h = 22; - if (x >= button_x && x < button_x + 70 && y >= button_y && y < button_y + 20) { + if (x >= save_btn_x && x < save_btn_x + save_btn_w && y >= save_btn_y && y < save_btn_y + save_btn_h) { editor_save_file(); } } @@ -413,15 +410,15 @@ int main(int argc, char **argv) { if (ui_get_event(win, &ev)) { if (ev.type == GUI_EVENT_PAINT) { editor_paint(win); - ui_mark_dirty(win, 0, 0, win_w, win_h - 20); + ui_mark_dirty(win, 0, 0, win_w, win_h); } else if (ev.type == GUI_EVENT_CLICK) { editor_handle_click(ev.arg1, ev.arg2); editor_paint(win); - ui_mark_dirty(win, 0, 0, win_w, win_h - 20); + ui_mark_dirty(win, 0, 0, win_w, win_h); } else if (ev.type == GUI_EVENT_KEY) { editor_handle_key((char)ev.arg1); editor_paint(win); - ui_mark_dirty(win, 0, 0, win_w, win_h - 20); + ui_mark_dirty(win, 0, 0, win_w, win_h); } else if (ev.type == GUI_EVENT_CLOSE) { sys_exit(0); } diff --git a/src/kernel/userland/txtedit.elf b/src/kernel/userland/txtedit.elf index 101de91..cdc1834 100755 Binary files a/src/kernel/userland/txtedit.elf and b/src/kernel/userland/txtedit.elf differ