Upp och ned pil är konstiga, väntar på hansons pil implementation innan jag fixar

This commit is contained in:
Tobias P.L Wennberg 2025-01-13 14:17:31 +01:00
parent 2661860245
commit a545c4cab3

View File

@ -96,15 +96,9 @@ func input_str(env *environment.Env) string {
case 4: // ^D
input = "exit"
goto loop_exit
case 9: // Tab
input = AutoComplete(input)
case 27: // arrow?
if r, _, _ := reader.ReadRune(); r != 91 {
break
}
case 91:
if r, _, _ := reader.ReadRune(); r == 65 { // UPP
if history_index > 0 {
history_index--
@ -114,7 +108,7 @@ func input_str(env *environment.Env) string {
}
if r, _, _ := reader.ReadRune(); r != 66 { //DOWN
if history_index < len(env.History)-1 {
if history_index < len(env.History)-2 {
history_index++
input = env.History[history_index]
} else {
@ -133,10 +127,8 @@ func input_str(env *environment.Env) string {
input = input + string(r_rune)
}
env.History[len(env.History)-1] = input
//fmt.Println(r_rune)
fmt.Print("\r")
// fmt.Print("\r\033[K")
fmt.Print("\r\033[K")
fmt.Print(env.Path)
fmt.Print(" > ")
fmt.Print("\033[K")