prompt fix
This commit is contained in:
@@ -12,6 +12,10 @@ _COL = False
|
||||
|
||||
def c(t, *cs): return t if not _COL or not cs else "\033[" + ";".join(map(str, cs)) + "m" + t + "\033[0m"
|
||||
|
||||
def cp(t, *cs): # colored prompt: hide ANSI escapes from readline's width calc (\001/\002 = RL_PROMPT_START/END_IGNORE)
|
||||
if readline is None or not _COL or not cs: return c(t, *cs)
|
||||
return "\001\033[" + ";".join(map(str, cs)) + "m\002" + t + "\001\033[0m\002"
|
||||
|
||||
def col(cfg):
|
||||
if os.environ.get("NO_COLOR") or os.environ.get("BANTAM_NO_COLOR"): return False
|
||||
m = str(cfg.get("color", "auto")).strip().lower()
|
||||
@@ -242,7 +246,7 @@ def main():
|
||||
sys.exit(0)
|
||||
print(c("Bantam Agent ready", 1, 32) + c(" (Ctrl+J = new line)", 2))
|
||||
while True:
|
||||
try: u = input(c("> ", 1, 36)).strip()
|
||||
try: u = input(cp("> ", 1, 36)).strip()
|
||||
except (EOFError, KeyboardInterrupt): print(); break
|
||||
if not u: continue
|
||||
if u == "/quit": break
|
||||
|
||||
Reference in New Issue
Block a user