Merge fix
This commit is contained in:
parent
45f50a95ce
commit
45cf77ed2a
@ -27,7 +27,7 @@ func Parse(env *environment.Env) Input {
|
||||
return Parse_input(input)
|
||||
}
|
||||
func Parse_input(input string) Input {
|
||||
split := strings.Split(string(input), " ")
|
||||
split := strings.Split(strings.TrimSpace(string(input)), " ")
|
||||
instruction := strings.TrimSpace(split[0])
|
||||
|
||||
args_raw := ""
|
||||
@ -38,14 +38,11 @@ func Parse_input(input string) Input {
|
||||
var flags []string
|
||||
var args []string
|
||||
for _, arg := range split[1:] {
|
||||
if len(arg) == 0 {
|
||||
continue
|
||||
} else if len(arg) == 1 {
|
||||
if len(arg) == 1 {
|
||||
if arg[0] == '-' {
|
||||
continue
|
||||
} else {
|
||||
args = append(args, strings.TrimSpace(arg))
|
||||
}
|
||||
_ = append(args, string(arg[0]))
|
||||
} else if arg[0:2] == "--" {
|
||||
var result = strings.TrimSpace(arg)
|
||||
flags = append(flags, string(result[2:]))
|
||||
@ -88,11 +85,8 @@ func input_str(env *environment.Env) string {
|
||||
|
||||
for {
|
||||
r_rune, _, err := reader.ReadRune()
|
||||
|
||||
// fmt.Printf("Rune: %d\n", r_rune)
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(fmt.Sprintf("Error reading user input: ", err.Error()))
|
||||
fmt.Print(fmt.Sprintf("Error reading user input: %s", err.Error()))
|
||||
}
|
||||
switch r_rune {
|
||||
case 3: // ^C
|
||||
@ -101,32 +95,31 @@ func input_str(env *environment.Env) string {
|
||||
case 4: // ^D
|
||||
input = "exit"
|
||||
goto loop_exit
|
||||
|
||||
case 9: // Tab
|
||||
// fmt.Println("test tab")
|
||||
input = AutoComplete(input)
|
||||
// fmt.Println(input)
|
||||
|
||||
case 27: // arrow?
|
||||
case 27: // UPP
|
||||
if r, _, _ := reader.ReadRune(); r != 91 {
|
||||
break
|
||||
}
|
||||
if r, _, _ := reader.ReadRune(); r == 65 { // UPP
|
||||
if history_index > 0 {
|
||||
history_index--
|
||||
input = env.History[history_index]
|
||||
case 66: // DOWN
|
||||
if history_index < len(env.History)-2 {
|
||||
history_index++
|
||||
input = env.History[history_index]
|
||||
} else {
|
||||
history_index = len(env.History) - 1
|
||||
input = ""
|
||||
if r, _, _ := reader.ReadRune(); r == 65 { // UPP
|
||||
if history_index > 0 {
|
||||
history_index--
|
||||
input = env.History[history_index]
|
||||
}
|
||||
}
|
||||
break
|
||||
|
||||
}
|
||||
if r, _, _ := reader.ReadRune(); r != 66 { //DOWN
|
||||
if history_index < len(env.History)-1 {
|
||||
history_index++
|
||||
input = env.History[history_index]
|
||||
} else {
|
||||
input = ""
|
||||
if r, _, _ := reader.ReadRune(); r != 66 { //DOWN
|
||||
if history_index < len(env.History)-1 {
|
||||
history_index++
|
||||
input = env.History[history_index]
|
||||
} else {
|
||||
input = ""
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case 62:
|
||||
input = input + prevGhostString
|
||||
@ -144,10 +137,7 @@ func input_str(env *environment.Env) string {
|
||||
ghost_input := AutoCompleteHistory(input, *env)
|
||||
|
||||
env.History[len(env.History)-1] = input
|
||||
//fmt.Println(r_rune)
|
||||
fmt.Print("\r")
|
||||
// fmt.Print("\r\033[K")
|
||||
|
||||
fmt.Print(env.Path)
|
||||
fmt.Print(" > ")
|
||||
fmt.Print("\033[K")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user