X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fcli-out.c;h=702e4e4dfe2eb187f019a5e7a26ff57092984eb8;hb=4b4477b52eee60ddadd59c36ffd778bbd9ab1c07;hp=fcb9ca1e2a7a7ff5d94dba4d45e4ce1f549ede67;hpb=61baf725eca99af2569262d10aca03dcde2698f6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/cli-out.c b/gdb/cli-out.c index fcb9ca1e2a..702e4e4dfe 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -1,6 +1,6 @@ /* Output generating routines for GDB CLI. - Copyright (C) 1999-2017 Free Software Foundation, Inc. + Copyright (C) 1999-2019 Free Software Foundation, Inc. Contributed by Cygnus Solutions. Written by Fernando Nasser for Cygnus. @@ -25,6 +25,7 @@ #include "cli-out.h" #include "completer.h" #include "readline/readline.h" +#include "cli/cli-style.h" /* These are the CLI output functions */ @@ -71,7 +72,8 @@ cli_ui_out::do_table_header (int width, ui_align alignment, if (m_suppress_output) return; - do_field_string (0, width, alignment, 0, col_hdr.c_str ()); + do_field_string (0, width, alignment, 0, col_hdr.c_str (), + ui_file_style ()); } /* Mark beginning of a list */ @@ -91,17 +93,27 @@ cli_ui_out::do_end (ui_out_type type) /* output an int field */ void -cli_ui_out::do_field_int (int fldno, int width, ui_align alignment, - const char *fldname, int value) +cli_ui_out::do_field_signed (int fldno, int width, ui_align alignment, + const char *fldname, LONGEST value) { - char buffer[20]; /* FIXME: how many chars long a %d can become? */ - if (m_suppress_output) return; - xsnprintf (buffer, sizeof (buffer), "%d", value); + do_field_string (fldno, width, alignment, fldname, plongest (value), + ui_file_style ()); +} + +/* output an unsigned field */ + +void +cli_ui_out::do_field_unsigned (int fldno, int width, ui_align alignment, + const char *fldname, ULONGEST value) +{ + if (m_suppress_output) + return; - do_field_string (fldno, width, alignment, fldname, buffer); + do_field_string (fldno, width, alignment, fldname, pulongest (value), + ui_file_style ()); } /* used to omit a field */ @@ -113,7 +125,8 @@ cli_ui_out::do_field_skip (int fldno, int width, ui_align alignment, if (m_suppress_output) return; - do_field_string (fldno, width, alignment, fldname, ""); + do_field_string (fldno, width, alignment, fldname, "", + ui_file_style ()); } /* other specific cli_field_* end up here so alignment and field @@ -121,7 +134,8 @@ cli_ui_out::do_field_skip (int fldno, int width, ui_align alignment, void cli_ui_out::do_field_string (int fldno, int width, ui_align align, - const char *fldname, const char *string) + const char *fldname, const char *string, + const ui_file_style &style) { int before = 0; int after = 0; @@ -156,7 +170,12 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align, spaces (before); if (string) - out_field_fmt (fldno, fldname, "%s", string); + { + if (test_flags (unfiltered_output)) + fputs_styled_unfiltered (string, style, m_streams.back ()); + else + fputs_styled (string, style, m_streams.back ()); + } if (after) spaces (after); @@ -165,20 +184,19 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align, field_separator (); } -/* This is the only field function that does not align. */ +/* Output field containing ARGS using printf formatting in FORMAT. */ void cli_ui_out::do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, - va_list args) + const char *fldname, const ui_file_style &style, + const char *format, va_list args) { if (m_suppress_output) return; - vfprintf_filtered (m_streams.back (), format, args); + std::string str = string_vprintf (format, args); - if (align != ui_noalign) - field_separator (); + do_field_string (fldno, width, align, fldname, str.c_str (), style); } void @@ -187,7 +205,10 @@ cli_ui_out::do_spaces (int numspaces) if (m_suppress_output) return; - print_spaces_filtered (numspaces, m_streams.back ()); + if (test_flags (unfiltered_output)) + print_spaces (numspaces, m_streams.back ()); + else + print_spaces_filtered (numspaces, m_streams.back ()); } void @@ -196,16 +217,24 @@ cli_ui_out::do_text (const char *string) if (m_suppress_output) return; - fputs_filtered (string, m_streams.back ()); + if (test_flags (unfiltered_output)) + fputs_unfiltered (string, m_streams.back ()); + else + fputs_filtered (string, m_streams.back ()); } void -cli_ui_out::do_message (const char *format, va_list args) +cli_ui_out::do_message (const ui_file_style &style, + const char *format, va_list args) { if (m_suppress_output) return; - vfprintf_unfiltered (m_streams.back (), format, args); + /* Use the "no_gdbfmt" variant here to avoid recursion. + vfprintf_styled calls into cli_ui_out::message to handle the + gdb-specific printf formats. */ + vfprintf_styled_no_gdbfmt (m_streams.back (), style, + !test_flags (unfiltered_output), format, args); } void @@ -227,39 +256,24 @@ cli_ui_out::do_flush () and make it therefore active. OUTSTREAM as NULL will pop the last pushed output stream; it is an internal error if it does not exist. */ -int +void cli_ui_out::do_redirect (ui_file *outstream) { if (outstream != NULL) m_streams.push_back (outstream); else m_streams.pop_back (); - - return 0; } /* local functions */ -/* Like cli_ui_out::do_field_fmt, but takes a variable number of args - and makes a va_list and does not insert a separator. */ - -/* VARARGS */ -void -cli_ui_out::out_field_fmt (int fldno, const char *fldname, - const char *format, ...) -{ - va_list args; - - va_start (args, format); - vfprintf_filtered (m_streams.back (), format, args); - - va_end (args); -} - void cli_ui_out::field_separator () { - fputc_filtered (' ', m_streams.back ()); + if (test_flags (unfiltered_output)) + fputc_unfiltered (' ', m_streams.back ()); + else + fputc_filtered (' ', m_streams.back ()); } /* Constructor for cli_ui_out. */ @@ -296,6 +310,12 @@ cli_ui_out::set_stream (struct ui_file *stream) return old; } +bool +cli_ui_out::can_emit_style_escape () const +{ + return m_streams.back ()->can_emit_style_escape (); +} + /* CLI interface to display tab-completion matches. */ /* CLI version of displayer.crlf. */