suewonjp / tclsh-wrapper

A tiny wrapper for Tcl/Tk's tclsh and wish
Apache License 2.0
22 stars 4 forks source link

bugged cursor position with colored prompts and long commands #10

Open JohnLunzer opened 4 years ago

JohnLunzer commented 4 years ago

I'm using this prompt:

set ::TclReadLine::PROMPT {\033\[36mtclsh-[info patchlevel]\033\[0m \[\033\[34m[file tail [pwd]\033\[0m]\]\033\[31m % \033\[0m}

It's very easy to test for long commands, I just type an 'f' character until the command wraps to the next line. The line wraps too early, it doesn't make it to the end of my terminal, and the cursor position is not where new characters are being displayed. Adding a newline seems to make things even more unpredictable.

Using the non-colored version:

set ::TclReadLine::PROMPT {tclsh[info patchlevel] \[[pwd]\]% }

The wrapping and cursor position behavior is fine. Newlines are handled fine with the uncolored prompt.

I feel like it's probably a pretty easy fix but I can't seem to figure it out.