cli-out.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Output generating routines for GDB CLI.
  2. Copyright (C) 1999-2022 Free Software Foundation, Inc.
  3. Contributed by Cygnus Solutions.
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef CLI_OUT_H
  16. #define CLI_OUT_H
  17. #include "ui-out.h"
  18. #include <vector>
  19. class cli_ui_out : public ui_out
  20. {
  21. public:
  22. explicit cli_ui_out (ui_file *stream, ui_out_flags flags);
  23. virtual ~cli_ui_out ();
  24. ui_file *set_stream (ui_file *stream);
  25. bool can_emit_style_escape () const override;
  26. protected:
  27. virtual void do_table_begin (int nbrofcols, int nr_rows,
  28. const char *tblid) override;
  29. virtual void do_table_body () override;
  30. virtual void do_table_end () override;
  31. virtual void do_table_header (int width, ui_align align,
  32. const std::string &col_name,
  33. const std::string &col_hdr) override;
  34. /* Note: level 0 is the top-level so LEVEL is always greater than
  35. zero. */
  36. virtual void do_begin (ui_out_type type, const char *id) override;
  37. virtual void do_end (ui_out_type type) override;
  38. virtual void do_field_signed (int fldno, int width, ui_align align,
  39. const char *fldname, LONGEST value) override;
  40. virtual void do_field_unsigned (int fldno, int width, ui_align align,
  41. const char *fldname, ULONGEST value)
  42. override;
  43. virtual void do_field_skip (int fldno, int width, ui_align align,
  44. const char *fldname) override;
  45. virtual void do_field_string (int fldno, int width, ui_align align,
  46. const char *fldname,
  47. const char *string,
  48. const ui_file_style &style) override;
  49. virtual void do_field_fmt (int fldno, int width, ui_align align,
  50. const char *fldname, const ui_file_style &style,
  51. const char *format, va_list args)
  52. override ATTRIBUTE_PRINTF (7, 0);
  53. virtual void do_spaces (int numspaces) override;
  54. virtual void do_text (const char *string) override;
  55. virtual void do_message (const ui_file_style &style,
  56. const char *format, va_list args) override
  57. ATTRIBUTE_PRINTF (3,0);
  58. virtual void do_wrap_hint (int indent) override;
  59. virtual void do_flush () override;
  60. virtual void do_redirect (struct ui_file *outstream) override;
  61. virtual void do_progress_start (const std::string &, bool) override;
  62. virtual void do_progress_notify (double) override;
  63. virtual void do_progress_end () override;
  64. bool suppress_output ()
  65. { return m_suppress_output; }
  66. private:
  67. void field_separator ();
  68. std::vector<ui_file *> m_streams;
  69. bool m_suppress_output;
  70. /* Represents the printing state of a progress meter. */
  71. enum meter_state
  72. {
  73. /* Printing will start with the next output. */
  74. START,
  75. /* Printing has already started. */
  76. WORKING,
  77. /* Progress printing has already started. */
  78. PROGRESS,
  79. /* Printing should not be done. */
  80. NO_PRINT
  81. };
  82. /* The state of a recent progress meter. */
  83. struct cli_progress_info
  84. {
  85. /* The current state. */
  86. enum meter_state printing;
  87. /* The name to print. */
  88. std::string name;
  89. /* The last notification value. */
  90. double last_value;
  91. };
  92. /* Stack of progress meters. */
  93. std::vector<cli_progress_info> m_meters;
  94. };
  95. extern cli_ui_out *cli_out_new (struct ui_file *stream);
  96. extern void cli_display_match_list (char **matches, int len, int max);
  97. #endif