diff --git a/odit.sublime-project b/odit.sublime-project index 9c95cc8..e50f18e 100644 --- a/odit.sublime-project +++ b/odit.sublime-project @@ -12,7 +12,7 @@ ], "build_systems": [ { - "cmd": ["odin", "build", "src", "-debug"], + "cmd": ["odin", "build", "src", "-debug", "-o:none"], "name": "odit", "selector": "source.odin", "working_dir": "${project_path}" diff --git a/src/main.odin b/src/main.odin index b12b8a2..edb0150 100644 --- a/src/main.odin +++ b/src/main.odin @@ -2,7 +2,7 @@ - DONE implement movement up and down by paragraph - DONE implement scrolling/viewport - DONE implement deletion by word -- TODO implement selection +- DONE implement selection - TODO implement duplicate selection/line - TODO implement move selection/line up/down - TODO implement copy/cut/paste @@ -16,6 +16,7 @@ package main import "core:fmt" import "core:mem" import "core:os" +import "core:slice" import "core:strings" import utf8 "core:unicode/utf8" import r "vendor:raylib" @@ -129,6 +130,21 @@ main :: proc() { fmt.println("Wrote file!") } + if r.IsKeyDown(.LEFT_SUPER) && r.IsKeyDown(.LEFT_SHIFT) && r.IsKeyPressed(.D) { + if selection.active { + earliest := selection_earliest() + latest := selection_latest() + #reverse for line, index in lines[earliest.line:latest.line + 1] { + new_line, _ := slice.clone_to_dynamic(line[:]) + inject_at(&lines, latest.line + 1, new_line) + } + // NOTE: should we move the selection as well? + } else { + new_line, _ := slice.clone_to_dynamic(current_line()[:]) + inject_at(&lines, cursor.line + 1, new_line) + cursor.line += 1 + } + } cursor_padding := 3 // move viewport up