public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Sutherland <sombrero@alum.mit.edu>
To: archer@sourceware.org
Subject: Re: [python] how best to support colorized output? (with example colorized backtrace)
Date: Fri, 27 Mar 2009 00:44:00 -0000	[thread overview]
Message-ID: <gqh7g8$rq1$1@ger.gmane.org> (raw)
In-Reply-To: <m3hc1fvmvo.fsf@fleche.redhat.com>

On 03/26/2009 05:18 PM, Tom Tromey wrote:
> I think the only thing I would suggest would be to use the existing
> filtering backtrace, and just reimplement colorization as a filter.
> If that's not possible (I didn't dig into the details too much), let's
> modify the existing Python backtrace command to make it possible :-)

Both the FilteringBacktrace class and its helper FrameWrapper class 
directly write to an output stream as text devoid of any semantic 
information.  (They are using sys.stdout, though not always explicitly.)

It is hard to decorate this output without operating at the level of a 
glorified colorizing regex.

I think something more along the line of a semantic stream (along the 
lines of ui-out.h but perhaps more extensible) might work out, but could 
be argued to be overkill.

For example, if the FrameWrapper did:
   stream.write_string(FILENAME, sal.symtab.filename)
   stream.write_text(":")
   stream.write_int(LINENUMBER, sal.line)
that would be wildly easier to colorize.  The default stream would just 
ignore the semantic info and dump things as strings.  The colorizing 
stream would have colors bound to certain types of things.  I am 
obviously glossing over where FILENAME AND LINENUMBER would come from.

Crossing into definite exciting overkill territory would be pushing the 
invocations of the pretty printers into the smart stream itself.  That 
way the stream could perhaps do something even more clever than the 
default pretty printer.  And if the stream was part of a GUI it might be 
able to establish some actionable linkage so you can right-click and 
have relevant actions, etc.

Andrew

      reply	other threads:[~2009-03-27  0:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 22:35 Andrew Sutherland
2009-03-27  0:19 ` Tom Tromey
2009-03-27  0:44   ` Andrew Sutherland [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='gqh7g8$rq1$1@ger.gmane.org' \
    --to=sombrero@alum.mit.edu \
    --cc=archer@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).