From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16310 invoked by alias); 27 Mar 2009 00:44:19 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 16299 invoked by uid 22791); 27 Mar 2009 00:44:18 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_36,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org To: archer@sourceware.org From: Andrew Sutherland Subject: Re: [python] how best to support colorized output? (with example colorized backtrace) Date: Fri, 27 Mar 2009 00:44:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1b4pre) Gecko/20090326 Shredder/3.0b3pre In-Reply-To: X-SW-Source: 2009-q1/txt/msg00418.txt.bz2 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