aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-05-13 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-05-13 20:20:20 +0200
commit699355e352c2d0d374f404bc42809cdd5220e5fb (patch)
treec2ed8a316bbf00381b63d8c4e7bd932e8a026098
parentgo (diff)
downloadhardflip-699355e352c2d0d374f404bc42809cdd5220e5fb.tar.gz
hardflip-699355e352c2d0d374f404bc42809cdd5220e5fb.tar.bz2
hardflip-699355e352c2d0d374f404bc42809cdd5220e5fb.tar.xz
hardflip-699355e352c2d0d374f404bc42809cdd5220e5fb.tar.zst
hardflip-699355e352c2d0d374f404bc42809cdd5220e5fb.zip
go
-rw-r--r--src/e_events.go3
-rw-r--r--src/i_ui.go9
2 files changed, 7 insertions, 5 deletions
diff --git a/src/e_events.go b/src/e_events.go
index 99813ab..4c38763 100644
--- a/src/e_events.go
+++ b/src/e_events.go
@@ -286,6 +286,9 @@ func e_readline(event tcell.EventKey, buffer *Buffer) {
return
} else if buffer.cursor == buffer.len() {
buffer.data = (buffer.data)[:buffer.cursor - 1]
+ } else {
+ buffer.data = append(buffer.data[:buffer.cursor - 1],
+ buffer.data[buffer.cursor:]...)
}
buffer.cursor -= 1
} else if event.Key() == tcell.KeyCtrlU {
diff --git a/src/i_ui.go b/src/i_ui.go
index f4d4a60..0eae586 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -95,8 +95,7 @@ func (buffer *Buffer)empty() {
func (buffer *Buffer)insert(str string) {
buffer.data = []rune(str)
- // TODO: uncomment
- // buffer.cursor = len(buffer.data)
+ buffer.cursor = len(buffer.data)
}
func (buffer *Buffer)str() string {
@@ -393,7 +392,7 @@ func i_prompt_mkdir(ui HardUI, curr *ItemsNode) {
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
ui.style[DEF_STYLE].Bold(true), ui.buff.str())
ui.s.ShowCursor(len(prompt) + 1 + len(path) +
- len(ui.buff.str()), ui.dim[H] - 1)
+ ui.buff.cursor, ui.dim[H] - 1)
}
func i_prompt_list(ui HardUI, name, prompt string, list []string) {
@@ -439,7 +438,7 @@ func i_prompt_generic(ui HardUI, prompt string, secret bool, home_dir string) {
i_draw_text(ui.s, len(prompt) + 1,
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
style, ui.buff.str())
- ui.s.ShowCursor(len(prompt) + 1 + ui.buff.len(), ui.dim[H] - 1)
+ ui.s.ShowCursor(len(prompt) + 1 + ui.buff.cursor, ui.dim[H] - 1)
}
func i_prompt_dir(ui HardUI, prompt string, home_dir string) {
@@ -464,7 +463,7 @@ func i_prompt_dir(ui HardUI, prompt string, home_dir string) {
i_draw_text(ui.s, len(prompt) + 1,
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
style, ui.buff.str())
- ui.s.ShowCursor(len(prompt) + 1 + ui.buff.len(), ui.dim[H] - 1)
+ ui.s.ShowCursor(len(prompt) + 1 + ui.buff.cursor, ui.dim[H] - 1)
}
func i_prompt_insert(ui HardUI, curr *ItemsNode) {