can add new line

This commit is contained in:
2026-04-22 15:42:42 -04:00
parent f1c772258e
commit 0dd6516726

View File

@@ -71,6 +71,7 @@ main :: () {
case .ESCAPE; should_quit = true;
case .BACKSPACE; handle_backspace();
case .ENTER; handle_enter();
case .ARROW_UP; #through;
case .ARROW_DOWN; #through;
@@ -192,6 +193,20 @@ handle_window_resizes :: (window: Window_Type) {
}
}
handle_enter :: () {
cursor_line_index := cursor_y + first_line;
current_line := *lines[cursor_line_index];
new_line := [..]u8.{};
array_add(*new_line, array_view(current_line.*, cursor_x));
array_insert_at(*lines, new_line, cursor_y + 1);
current_line.count = cursor_x;
cursor_y += 1;
cursor_x = 0;
}
handle_backspace :: () {
if cursor_x == 0 && cursor_y == 0 {
return;