From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthew Keeter Newsgroups: gmane.lisp.guile.user Subject: Re: Readline behavior with colored custom prompt Date: Thu, 25 Feb 2016 17:09:56 -0500 Message-ID: <2CEABA33-AC5F-44D4-9BC4-4B9FD163BDD7@gmail.com> References: <1474022160.2484505.1456423503453.JavaMail.yahoo@mail.yahoo.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_68BD77FA-1C53-4456-8C7F-CEC1F1F18820" X-Trace: ger.gmane.org 1456438224 9576 80.91.229.3 (25 Feb 2016 22:10:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Feb 2016 22:10:24 +0000 (UTC) Cc: "guile-user@gnu.org" To: Mike Gran Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Feb 25 23:10:18 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aZ46y-0004IK-55 for guile-user@m.gmane.org; Thu, 25 Feb 2016 23:10:16 +0100 Original-Received: from localhost ([::1]:46137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ46x-0006VV-Ht for guile-user@m.gmane.org; Thu, 25 Feb 2016 17:10:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ46l-0006U3-Gu for guile-user@gnu.org; Thu, 25 Feb 2016 17:10:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ46h-0006cm-SJ for guile-user@gnu.org; Thu, 25 Feb 2016 17:10:03 -0500 Original-Received: from mail-qg0-x233.google.com ([2607:f8b0:400d:c04::233]:33175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ46h-0006ci-JY for guile-user@gnu.org; Thu, 25 Feb 2016 17:09:59 -0500 Original-Received: by mail-qg0-x233.google.com with SMTP id b35so51711937qge.0 for ; Thu, 25 Feb 2016 14:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=7pr5C66dUKUsMx+vYl2rfcxjI6LEyj6v7tNLvRGx+XQ=; b=mKaZ34Qvs0dMt9INX0xRCC0TUZmGgUoTOOiqqunhVctrf+/BaWGvAuB9ufr3M223b8 6wVsneVloMnH3+RSSKEdWq0SybFQDDVKPd3GOYD/2zKxm9XNDzqt5gbwPoE4O54lFxhX 9ErJfNKgolk0Jz/ut7v2DDxWG4iewT6BoLA2sJG4DUnbUcLuqidRLiJk3lueABuFVBIO gFlJx4bAmj8ofE48ZAQ9+a+FqAFqAUWhEtnlMg0ZeYZ/BXsYamMNvq3cwK/rv6c4scam sxaxEu52AykXchWfUd570ClsVDyUos2V+uoxsMyU9gB0uRWXkbnmtjk2e/gvDH8jekfq /3IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=7pr5C66dUKUsMx+vYl2rfcxjI6LEyj6v7tNLvRGx+XQ=; b=mpuox3uJwOf1xaE7iOqEdjkufNalPQdX8i/C/DKM+1uDvN/TQW9OTamhX6XkCkaeQw bN1j7ZZPilizXiVduShjaifjkMwetvTHwvvB6OTMdbw06vuM3dEJhfX9D65xtOlMuza3 geEg5uZuzbbbfeACpbMLNqQkTjiFvimUHpeUNc6+B3vTLCy21ISXwxxTCEsIq9uqTgIr LLGPclsJNCn3Caz85vPfKkWWBXqSd42zp1+qFZjUCzqnRXC5552zq+JMLHfC/Y5UoehQ 9Eq5wvgOtU1c7RbVBGk/TLkSdsHEdkblRy6xTOpovCO2TscuihX3gtHHLBDiuv/i4nj4 tkVQ== X-Gm-Message-State: AG10YOQfNx9DaQzItmtrdsuxZ6+7LgBMYt8ZZCLiTvhc09wIdVvuTQfNkjrXxUjEZ49Y8w== X-Received: by 10.140.216.212 with SMTP id m203mr62646497qhb.37.1456438199178; Thu, 25 Feb 2016 14:09:59 -0800 (PST) Original-Received: from [10.0.0.218] ([209.6.175.242]) by smtp.gmail.com with ESMTPSA id a77sm4122958qge.7.2016.02.25.14.09.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Feb 2016 14:09:58 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.1878.6) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::233 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12449 Archived-At: --Apple-Mail=_68BD77FA-1C53-4456-8C7F-CEC1F1F18820 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Figured it out, after a bit more searching =96 it=92s purely due to = readline's behavior. readline obeys the magic characters \x01 and \x02, ignoring anything in = between then when calculating prompt length. Wrapping the escape sequences makes = everything behave correctly. (similar bug: https://bugs.python.org/issue17337) -Matt On Feb 25, 2016, at 1:53 PM, Matthew Keeter = wrote: > I think the fundamental issue is incorrect prompt length calculation, = since it=92s not just bounce-parens: > even with that turned off, scrolling through history ends up printing = weird mismatched lines. >=20 > Here=92s a similar issue discussed in nodejs: > https://github.com/nodejs/node-v0.x-archive/issues/3860 >=20 > Any suggestions where to look for prompt length calculations? > I flipped through guile-readline/readline.c but didn=92t see any = obvious places to apply a fix. >=20 > Thanks, > Matt >=20 > On Feb 25, 2016, at 1:05 PM, Mike Gran wrote: >=20 >>=20 >>=20 >>=20 >> On Thursday, February 25, 2016 9:21 AM, Matthew Keeter = wrote: >>=20 >>>=20 >>> Run this and you=92ll get a Guile shell. Into that shell, type >>>=20 >>> '(1 2 3 4 5 6 7 8 9 10) >>>=20 >>> The final parenthesis will highlight a character midway through the = string >>> (instead of the first parenthesis). >>>=20 >>> The same issues happen if you try to scroll through history: lines = end up >>> overlapping in strange ways. >>>=20 >>> Removing the ANSI codes from custom-prompt resolves the issue, but = I=92d really >>> like to have a colored prompt and correct readline behavior. >>>=20 >>> Does anyone have any ideas? >>=20 >> The conflict is likely between your codes and the bounce-parens = functionality >> of the readline prompt. >>=20 >> (readline-set! bounce-parens 0) should disable that functionality = and make the >> colored prompt work. >>=20 >> To get your escape sequences and bounce-parens working would probably = require >> more thinking... >>=20 >> -Mike >=20 --Apple-Mail=_68BD77FA-1C53-4456-8C7F-CEC1F1F18820 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
Figured it out, after a bit more searching =96 = it=92s purely due to readline's = behavior.

readline obeys the magic = characters \x01 and \x02, ignoring anything in between = then
when calculating prompt length.  Wrapping the escape = sequences makes everything
behave = correctly.


-Matt

On Feb = 25, 2016, at 1:53 PM, Matthew Keeter <matt.j.keeter@gmail.com> = wrote:

I = think the fundamental issue is incorrect prompt length calculation, = since it=92s not just bounce-parens:
even with that turned off, = scrolling through history ends up printing weird mismatched = lines.

Here=92s a similar issue discussed in = nodejs:

Any suggestions where to look for prompt length = calculations?
I flipped through guile-readline/readline.c but = didn=92t see any obvious places to apply a = fix.

Thanks,
Matt

On Feb 25, 2016, at 1:05 PM, Mike Gran <spk121@yahoo.com> = wrote:




On Thursday, February 25, 2016 9:21 AM, = Matthew Keeter <matt.j.keeter@gmail.com> = wrote:


Run this and you=92ll get a = Guile shell.  Into that shell, type

  '(1 2 3 4 5 = 6 7 8 9 10)

The final parenthesis will highlight a character = midway through the string
(instead of the first = parenthesis).

The same issues happen if you try to scroll through = history: lines end up
overlapping in strange ways.

Removing = the ANSI codes from custom-prompt resolves the issue, but I=92d = really
like to have a colored prompt and correct readline = behavior.

Does anyone have any ideas?

The = conflict is likely between your codes and the bounce-parens = functionality
of the readline prompt.

(readline-set! = bounce-parens 0)  should disable that functionality and make = the
colored prompt work.

To get your escape sequences and = bounce-parens working would probably require
more = thinking...

-Mike


= --Apple-Mail=_68BD77FA-1C53-4456-8C7F-CEC1F1F18820--