prompt fix

This commit is contained in:
Luxferre
2026-08-08 20:28:58 +03:00
parent bec49bad94
commit e64fa242fd
3 changed files with 49 additions and 6 deletions
+5 -1
View File
@@ -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