Long standing annoying issue in ghci

Brandon Allbery allbery.b at gmail.com
Tue Dec 5 20:57:23 UTC 2017


On Tue, Dec 5, 2017 at 12:36 PM, cheater00 cheater00 <cheater00 at gmail.com>
wrote:

> without color coding the prompt so I can't really turn it off. It
> seems like a simple arithmetic issue somewhere in the readline
> implementation.
>

It's not arithmetic except in the sense that it's not doing *any* math.
Color codes in a terminal are necessarily implemented as character
sequences (this is pretty much the definition of a terminal interface), and
haskeline makes no effort to recognize them, so it treats them the same as
displayed character sequences and skips over them as if they were displayed
characters.

GNU readline handles this by recognizing the character mode sequences as
not taking up character positions (this is more complex than you think
given that GNU readline doesn't assume all terminals obey the ANSI
standard; as it turns out, neither does haskeline, so it actually gets a
bit nasty), and recognizing the special behavior of carriage return, and
providing \[ \] escapes to declare the sequence inside as "invisible" to to
character positioning (and it's on the person crafting the prompt to insure
that it actually is). Beyond that, it'd actually have to implement a
'terminal emulator' internally to get it right in all cases --- and i'd be
on the user to ensure their declared terminal type matches the actual one
well enough for the 'terminal emulator' to reflect the terminal's actual
behavior, so it'd be a potential source of even weirder behavior.

So, (a) haskeline issue, not strictly ghc/ghci, and (b) not really fixable,
but partially work-around-able for common cases.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20171205/b394e2b7/attachment.html>


More information about the ghc-devs mailing list