Compare commits

...

14 Commits

Author SHA1 Message Date
Tobias P.L Wennberg
0216b72d65 Accidentally disabled tab-complete 2025-01-13 17:12:54 +01:00
Tobias P.L Wennberg
35af0423a7 merge flodman 2025-01-13 17:04:15 +01:00
Tobias P.L Wennberg
3c166dda98 Merge branch 'Flodman' 2025-01-13 17:02:51 +01:00
In_the_Thick_of_It
e6e223b6a7 implemented some brainrot for y'all :):):):):):) 2025-01-13 16:59:09 +01:00
Tobias P.L Wennberg
d4757c154b Fix 2025-01-13 15:45:26 +01:00
Tobias P.L Wennberg
45cf77ed2a Merge fix 2025-01-13 15:39:04 +01:00
Laukka
0525f346b4 Merge remote-tracking branch 'origin/laukkasBranch' into laukkasBranch 2025-01-13 15:01:43 +01:00
Laukka
15da22bc16 added fritiofscommando och att man kan ha " " innan komandon 2025-01-13 15:01:38 +01:00
Laukka
642d1780b6 added fritiofscommando och att man kan ha " " innan komandon 2025-01-13 14:37:35 +01:00
Laukka
2932f9bf43 added fritiofscommando och att man kan ha " " innan komandon 2025-01-13 14:28:15 +01:00
Laukka
6c63fc7122 Merge branch 'refs/heads/master' into laukkasBranch
# Conflicts:
#	input_parser/input_parser.go
2025-01-13 14:25:54 +01:00
Tobias P.L Wennberg
a545c4cab3 Upp och ned pil är konstiga, väntar på hansons pil implementation innan jag fixar 2025-01-13 14:17:31 +01:00
t
2661860245 Merge pull request 'Fixed first version of auto complete. And fixade the input sak så that it didnt blinkade så much! :D' (#4) from lo_branch into master
Reviewed-on: #4
2025-01-13 13:43:03 +01:00
Laukka
aad4da3077 fixed len 1 and 0 args and flags 2025-01-13 10:55:44 +01:00
5 changed files with 73 additions and 37 deletions

View File

@ -5,6 +5,7 @@ import (
"bbash/command/cd"
"bbash/command/cp"
"bbash/command/echo"
"bbash/command/fritiofcommand"
"bbash/command/head"
"bbash/command/help"
"bbash/command/ls"
@ -14,6 +15,7 @@ import (
"bbash/command/rm"
"bbash/command/tail"
"bbash/command/touch"
"bbash/command/whereareyou"
"bbash/environment"
"bbash/input_parser"
"fmt"
@ -33,6 +35,8 @@ func Init(env *environment.Env) {
func Run_command(in input_parser.Input, env *environment.Env) {
switch in.Instruction {
case "fritiofcommand":
fritiofcommand.Fritiof(in, env)
case "pwd":
pwd.Pwd(in, env)
case "echo":
@ -59,6 +63,8 @@ func Run_command(in input_parser.Input, env *environment.Env) {
help.Help(in, env)
case "tail":
tail.Tail(in, env)
case "whereareyou":
whereareyou.Whereareyou(in, env)
default:
if !run_by_path(in, env) {
fmt.Println(fmt.Sprintf("No such command! (%s)", in.Instruction))

View File

@ -0,0 +1,12 @@
package fritiofcommand
import (
"bbash/environment"
"bbash/input_parser"
"fmt"
)
func Fritiof(in input_parser.Input, _ *environment.Env) {
fmt.Print("Sannolikheten för läkarlinjen är mycket hög!")
// fritiof
}

View File

@ -0,0 +1,11 @@
package whereareyou
import (
"bbash/environment"
"bbash/input_parser"
"fmt"
)
func Whereareyou(in input_parser.Input, env *environment.Env) {
fmt.Println("You're in the thick of it everybody knows!")
}

18
hello Normal file
View File

@ -0,0 +1,18 @@
a
b
c
1
2
3
4
5
6
7
8
9
9
9
9
9
9
9

View File

@ -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,36 +95,36 @@ func input_str(env *environment.Env) string {
case 4: // ^D
input = "exit"
goto loop_exit
case 9: // Tab
// fmt.Println("test tab")
case 9: // 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
case 127: //packspace
if len(input) > 0 {
input = input[:len(input)-1]
@ -140,17 +134,12 @@ func input_str(env *environment.Env) string {
default:
input = input + string(r_rune)
}
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")
fmt.Print(" > \033[K")
fmt.Print(input)
fmt.Print("\033[2m", ghost_input, "\033[0m")