fix backspace bug
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@ bin
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
src/src
|
src/src
|
||||||
scratch
|
scratch
|
||||||
|
src.bin*
|
||||||
|
*.sublime-workspace
|
||||||
26
odit.sublime-project
Normal file
26
odit.sublime-project
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"debugger_configurations":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch",
|
||||||
|
"program": "${project_path}/src.bin",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${project_path}"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"build_systems": [
|
||||||
|
{
|
||||||
|
"cmd": ["odin", "build", "src", "-debug"],
|
||||||
|
"name": "odit",
|
||||||
|
"selector": "source.odin",
|
||||||
|
"working_dir": "${project_path}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -174,9 +174,10 @@ main :: proc() {
|
|||||||
fmt.println("Wrote file!")
|
fmt.println("Wrote file!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if repeatable_key_pressed(r.KeyboardKey.BACKSPACE) {
|
skip_backspace: if repeatable_key_pressed(r.KeyboardKey.BACKSPACE) {
|
||||||
if cursor.line == 0 && cursor.char == 0 do continue
|
if cursor.line == 0 && cursor.char == 0 do break skip_backspace
|
||||||
if cursor.char == 0 {
|
if cursor.char == 0 {
|
||||||
|
// join lines
|
||||||
old_len := len(lines[cursor.line - 1])
|
old_len := len(lines[cursor.line - 1])
|
||||||
append(&lines[cursor.line - 1], string(current_line()[:]))
|
append(&lines[cursor.line - 1], string(current_line()[:]))
|
||||||
line_to_remove := current_line()^
|
line_to_remove := current_line()^
|
||||||
@@ -185,8 +186,21 @@ main :: proc() {
|
|||||||
cursor.line -= 1
|
cursor.line -= 1
|
||||||
cursor.char = old_len
|
cursor.char = old_len
|
||||||
} else {
|
} else {
|
||||||
ordered_remove(&lines[cursor.line], cursor.char - 1)
|
if r.IsKeyDown(r.KeyboardKey.LEFT_ALT) {
|
||||||
cursor.char -= 1
|
// delete by word
|
||||||
|
delete_to, found := find_previous_space(cursor.char, current_line()[:])
|
||||||
|
if found {
|
||||||
|
remove_range(current_line(), delete_to, cursor.char)
|
||||||
|
cursor.char = delete_to
|
||||||
|
} else {
|
||||||
|
remove_range(current_line(), 0, cursor.char)
|
||||||
|
cursor.char = 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// delete single char
|
||||||
|
ordered_remove(&lines[cursor.line], cursor.char - 1)
|
||||||
|
cursor.char -= 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user