diff --git a/src/main.odin b/src/main.odin index 8a1c9f6..1e4925d 100644 --- a/src/main.odin +++ b/src/main.odin @@ -286,9 +286,7 @@ main :: proc() { log.error("SDL failed to initialize:", sdl2.GetError()); return; } - defer { - sdl2.Quit(); - } + defer sdl2.Quit() if ttf.Init() < 0 { log.error("SDL_TTF failed to initialize:", ttf.GetError()); diff --git a/src/panels/file_buffer.odin b/src/panels/file_buffer.odin index 3d03e17..cd33a7a 100644 --- a/src/panels/file_buffer.odin +++ b/src/panels/file_buffer.odin @@ -188,6 +188,25 @@ file_buffer_go_actions :: proc(input_map: ^core.InputActions) { }, "move to end of line"); } +file_buffer_delete_actions :: proc(input_map: ^core.InputActions) { + core.register_key_action(input_map, .D, proc(state: ^core.State, user_data: rawptr) { + buffer := &(&(transmute(^core.Panel)user_data).type.(core.FileBufferPanel)).buffer + + core.push_new_snapshot(&buffer.history) + + buffer.selection = core.new_selection(buffer.history.cursor); + sel_cur := &(buffer.selection.?); + + core.move_cursor_start_of_line(buffer, cursor = &sel_cur.start); + core.move_cursor_end_of_line(buffer, cursor = &sel_cur.end, stop_at_end = false); + + core.delete_content_from_selection(buffer, sel_cur) + + buffer.selection = nil; + core.reset_input_map(state) + }, "delete whole line"); +} + file_buffer_input_actions :: proc(input_map: ^core.InputActions) { // Cursor Movement { @@ -273,6 +292,10 @@ file_buffer_input_actions :: proc(input_map: ^core.InputActions) { file_buffer_go_actions(&go_actions); core.register_key_action(input_map, .G, go_actions, "Go commands"); + delete_actions := core.new_input_actions(show_help = true) + file_buffer_delete_actions(&delete_actions); + core.register_key_action(input_map, .D, delete_actions, "Delete commands"); + core.register_key_action(input_map, .V, proc(state: ^core.State, user_data: rawptr) { buffer := &(&(transmute(^core.Panel)user_data).type.(core.FileBufferPanel)).buffer