[PATCH 00/16] Add styling to the gdb CLI and TUI

Tom Tromey tom@tromey.com
Fri Mar 1 18:42:00 GMT 2019


>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> I think either utils.c would have to be modified to change where it
>> sends output, or stdio_file::puts would have to be modified.  The idea
>> there would be to call a host-specific function; and then on Windows do
>> the filtering+styling if the output is going to the terminal.

Eli> I'm looking into this now.  The simplest change would be to modify
Eli> stdio_file::puts that performs the filtering only on Windows, but the
Eli> fact that you mentioned calling a host-specific function confuses me a
Eli> little.  Can you elaborate on what you had in mind, and specifically
Eli> what kind of a host-specific function should be involved here, and
Eli> how?

Right now styling works because, in the end, ANSI escape sequences are
emitted via stdio_file::puts, which just calls fputs.

However, my understanding is that the Windows console instead requires
styling to be done by making various API calls.

So, the idea is to replace stdio_file::puts with a function that, for
the Windows console only, parses out the ANSI escapes from the output
string and replaces those with the appropriate API calls.

This made sense to me as a host-dependent function of some kind.  But I
don't really know.

The TUI does essentially this in order to convert ANSI escapes into
curses calls.  See tui-io.c:tui_puts_internal and apply_ansi_escape.
The parsing work is done by the method ui_file_style::parse.

Tom



More information about the Gdb-patches mailing list