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

Eli Zaretskii eliz@gnu.org
Fri Mar 1 19:40:00 GMT 2019


> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Fri, 01 Mar 2019 11:42:39 -0700
> 
> 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.

Right.  My question is about the details, or, more accurately, about
stylistic conventions and policies in such cases.

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

I'm not sure I understand how to call that host-dependent function.
You don't mean #ifdef, do you?  My idea was to do something like

  void
  stdio_file::puts (const char *linebuffer)
  {
  #ifdef _WIN32
    w32_fputs (linebuffer, m_file);
  #else
    /* Calling error crashes when we are called from the exception framework.  */
    if (fputs (linebuffer, m_file))
      {
	/* Nothing.  */
      }
  #endif
  }

where w32_fputs will DTRT for Windows.  If this is not what you had in
mind, can you maybe point me to a place where host-dependent functions
are called?

> 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.

Right, but TUI overrides the puts method, which is not what I need to
do here.

Thanks.



More information about the Gdb-patches mailing list