fix flashing text in terminal

This commit is contained in:
2024-10-08 09:43:26 +01:00
parent f98cf47988
commit 4910a2337b
2 changed files with 10 additions and 10 deletions

View File

@@ -14,12 +14,12 @@ func shell(global ArObject) {
go func() { go func() {
for sig := range c { for sig := range c {
if sig == os.Interrupt { if sig == os.Interrupt {
fmt.Println("\x1b[0m\n\x1b[32;5;240mBye :)\x1b[0m") fmt.Println("\x1b[0m\n\x1b[32;240mBye :)\x1b[0m")
os.Exit(0) os.Exit(0)
} }
} }
}() }()
fmt.Print("\x1b[32;5;240mWelcome to the Argon v3!\x1b[0m\n\n") fmt.Print("\x1b[32;240mWelcome to the Argon v3!\x1b[0m\n\n")
for { for {
indent := 0 indent := 0
previous := 0 previous := 0
@@ -27,7 +27,7 @@ func shell(global ArObject) {
textBefore := ">>>" textBefore := ">>>"
for i := 1; indent > 0 || (previous != indent && indent >= 0) || i == 1; i++ { for i := 1; indent > 0 || (previous != indent && indent >= 0) || i == 1; i++ {
indentStr := strings.Repeat(" ", indent) indentStr := strings.Repeat(" ", indent)
code := indentStr + input("\x1b[38;5;240m"+textBefore+indentStr+" \x1b[0m\x1b[1;5;240m") code := indentStr + input("\x1b[38;240m"+textBefore+indentStr+" \x1b[0m\x1b[1;240m")
fmt.Print("\x1b[0m") fmt.Print("\x1b[0m")
totranslate = append(totranslate, UNPARSEcode{code, code, i, "<shell>"}) totranslate = append(totranslate, UNPARSEcode{code, code, i, "<shell>"})
trimmed := strings.TrimSpace(code) trimmed := strings.TrimSpace(code)

View File

@@ -42,7 +42,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
} }
case number: case number:
if colored { if colored {
output = append(output, "\x1b[34;5;240m") output = append(output, "\x1b[34;240m")
} }
num, _ := x.Float64() num, _ := x.Float64()
if math.IsNaN(num) { if math.IsNaN(num) {
@@ -59,7 +59,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
} }
case bool: case bool:
if colored { if colored {
output = append(output, "\x1b[35;5;240m") output = append(output, "\x1b[35;240m")
} }
output = append(output, strconv.FormatBool(x)) output = append(output, strconv.FormatBool(x))
if colored { if colored {
@@ -67,7 +67,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
} }
case nil: case nil:
if colored { if colored {
output = append(output, "\x1b[31;5;240m") output = append(output, "\x1b[31;240m")
} }
output = append(output, "null") output = append(output, "null")
if colored { if colored {
@@ -128,7 +128,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
} else { } else {
outputkeyval := []string{} outputkeyval := []string{}
if colored { if colored {
outputkeyval = append(outputkeyval, "\x1b[36;5;240m") outputkeyval = append(outputkeyval, "\x1b[36;240m")
} }
outputkeyval = append(outputkeyval, key.(string)) outputkeyval = append(outputkeyval, key.(string))
if colored { if colored {
@@ -148,7 +148,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
output = append(output, anyToArgon(item, true, true, depth-1, indent+1, colored, plain)) output = append(output, anyToArgon(item, true, true, depth-1, indent+1, colored, plain))
} }
if colored { if colored {
output = append(output, "\x1b[38;5;240m(...)\x1b[0m") output = append(output, "\x1b[38;240m(...)\x1b[0m")
} else { } else {
output = append(output, "(...)") output = append(output, "(...)")
} }
@@ -173,7 +173,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
return "[" + maybenewline + (strings.Repeat(" ", (indent+1)*plain)) + strings.Join(output, ","+maybenewline+(strings.Repeat(" ", (indent+1)*plain))) + maybenewline + (strings.Repeat(" ", indent*plain)) + "]" return "[" + maybenewline + (strings.Repeat(" ", (indent+1)*plain)) + strings.Join(output, ","+maybenewline+(strings.Repeat(" ", (indent+1)*plain))) + maybenewline + (strings.Repeat(" ", indent*plain)) + "]"
case builtinFunc: case builtinFunc:
if colored { if colored {
output = append(output, "\x1b[38;5;240m") output = append(output, "\x1b[38;240m")
} }
output = append(output, "<builtin function "+x.name+">") output = append(output, "<builtin function "+x.name+">")
if colored { if colored {
@@ -181,7 +181,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
} }
case Callable: case Callable:
if colored { if colored {
output = append(output, "\x1b[38;5;240m") output = append(output, "\x1b[38;240m")
} }
output = append(output, "<function "+x.name+">") output = append(output, "<function "+x.name+">")
if colored { if colored {