<p dir="ltr">A simple example of colored prompt would be good enough, so as not to make the docs too huge. People will be able to figure out they need \STX, or just make sure to tell them.</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, 5 Dec 2017 23:17 Brandon Allbery, <<a href="mailto:allbery.b@gmail.com">allbery.b@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It's indirectly already there: <a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#the-ghci-and-haskeline-files" target="_blank">https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#the-ghci-and-haskeline-files</a><div>Possibly an additional pointer needs to be in the FAQ/things to watch out for section.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 5, 2017 at 5:13 PM, David Feuer <span dir="ltr"><<a href="mailto:david@well-typed.com" target="_blank">david@well-typed.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>It sounds like this should be added to the GHCi documentation, even if it's not strictly about GHCi.</div><span class="m_-7376584034194809000HOEnZb"><font color="#888888"><div><br></div><div><br></div><div><br></div><div id="m_-7376584034194809000m_-425029116522610582composer_signature"><div style="font-size:85%;color:#575757">David Feuer</div><div style="font-size:85%;color:#575757">Well-Typed, LLP</div></div></font></span><span><div><br></div><div style="font-size:100%;color:#000000"><div>-------- Original message --------</div><div>From: Evan Laforge <<a href="mailto:qdunkan@gmail.com" target="_blank">qdunkan@gmail.com</a>> </div><div>Date: 12/5/17 4:49 PM (GMT-05:00) </div><div>To: Brandon Allbery <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>> </div><div>Cc: <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a> </div><div>Subject: Re: Long standing annoying issue in ghci </div><div><br></div></div>Here's what I use:<br><br>:set prompt "\ESC[46m\STX%s>\ESC[39;49m\STX "<br><br></span><span>I believe \STX is a signal to haskeline for control sequences.<br>Documentation is here:<br><a href="https://github.com/judah/haskeline/wiki/ControlSequencesInPrompt" target="_blank">https://github.com/judah/haskeline/wiki/ControlSequencesInPrompt</a><br><br></span><div><div class="m_-7376584034194809000h5">On Tue, Dec 5, 2017 at 12:57 PM, Brandon Allbery <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>> wrote:<br>> On Tue, Dec 5, 2017 at 12:36 PM, cheater00 cheater00 <<a href="mailto:cheater00@gmail.com" target="_blank">cheater00@gmail.com</a>><br>> wrote:<br>>><br>>> without color coding the prompt so I can't really turn it off. It<br>>> seems like a simple arithmetic issue somewhere in the readline<br>>> implementation.<br>><br>><br>> It's not arithmetic except in the sense that it's not doing *any* math.<br>> Color codes in a terminal are necessarily implemented as character sequences<br>> (this is pretty much the definition of a terminal interface), and haskeline<br>> makes no effort to recognize them, so it treats them the same as displayed<br>> character sequences and skips over them as if they were displayed<br>> characters.<br>><br>> GNU readline handles this by recognizing the character mode sequences as not<br>> taking up character positions (this is more complex than you think given<br>> that GNU readline doesn't assume all terminals obey the ANSI standard; as it<br>> turns out, neither does haskeline, so it actually gets a bit nasty), and<br>> recognizing the special behavior of carriage return, and providing \[ \]<br>> escapes to declare the sequence inside as "invisible" to to character<br>> positioning (and it's on the person crafting the prompt to insure that it<br>> actually is). Beyond that, it'd actually have to implement a 'terminal<br>> emulator' internally to get it right in all cases --- and i'd be on the user<br>> to ensure their declared terminal type matches the actual one well enough<br>> for the 'terminal emulator' to reflect the terminal's actual behavior, so<br>> it'd be a potential source of even weirder behavior.<br>><br>> So, (a) haskeline issue, not strictly ghc/ghci, and (b) not really fixable,<br>> but partially work-around-able for common cases.<br>><br></div></div><span>> --<br>> brandon s allbery kf8nh sine nomine associates<br>> <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a><br>> unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a><br>><br></span><span>> _______________________________________________<br>> ghc-devs mailing list<br>> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>><br>_______________________________________________<br>ghc-devs mailing list<br><a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br></span></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-7376584034194809000gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>