From 2f2287318b33ddf855a692fcc191f6b25caf4644 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 16 Dec 2020 18:18:40 +0100 Subject: [gdb/cli] Add a progress meter Add a progress meter. It's not used anywhere yet. gdb/ChangeLog: 2020-12-16 Tom Tromey Tom Tromey Tom de Vries * utils.h (get_chars_per_line): Declare. * utils.c (get_chars_per_line): New function. (fputs_maybe_filtered): Handle '\r'. * ui-out.h (ui_out::progress_meter): New class. (ui_out::progress, ui_out::do_progress_start) (ui_out::do_progress_notify, ui_out::do_progress_end): New methods. * ui-out.c (do_progress_end) (make_cleanup_ui_out_progress_begin_end, ui_out_progress): New functions. * mi/mi-out.h (mi_ui_out::do_progress_start) (mi_ui_out::do_progress_notify, mi_ui_out::do_progress_end): New methods. * cli-out.h (struct cli_ui_out) : New methods. : New. : New member. * cli-out.c (cli_ui_out::do_progress_start) (cli_ui_out::do_progress_notify, cli_ui_out::do_progress_end): New methods. --- gdb/utils.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gdb/utils.c') diff --git a/gdb/utils.c b/gdb/utils.c index 3226656..abcf6e2 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1579,6 +1579,14 @@ gdb_flush (struct ui_file *stream) stream->flush (); } +/* See utils.h. */ + +int +get_chars_per_line () +{ + return chars_per_line; +} + /* Indicate that if the next sequence of characters overflows the line, a newline should be inserted here rather than when it hits the end. If INDENT is non-null, it is a string to be printed to indent the @@ -1769,6 +1777,12 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream, don't increment chars_printed here. */ lineptr += skip_bytes; } + else if (*lineptr == '\r') + { + wrap_buffer.push_back (*lineptr); + chars_printed = 0; + lineptr++; + } else { wrap_buffer.push_back (*lineptr); -- cgit v1.1