* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
/* TUI support I/O functions.
|
2002-03-01 07:19:28 +01:00
|
|
|
|
2019-01-01 07:01:51 +01:00
|
|
|
Copyright (C) 1998-2019 Free Software Foundation, Inc.
|
2002-03-01 07:19:28 +01:00
|
|
|
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
Contributed by Hewlett-Packard Company.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
#include "target.h"
|
|
|
|
#include "event-loop.h"
|
2002-08-31 14:02:14 +02:00
|
|
|
#include "event-top.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
#include "command.h"
|
|
|
|
#include "top.h"
|
2004-01-19 05:31:53 +01:00
|
|
|
#include "tui/tui.h"
|
|
|
|
#include "tui/tui-data.h"
|
|
|
|
#include "tui/tui-io.h"
|
|
|
|
#include "tui/tui-command.h"
|
|
|
|
#include "tui/tui-win.h"
|
|
|
|
#include "tui/tui-wingeneral.h"
|
|
|
|
#include "tui/tui-file.h"
|
Class-ify ui_out
This patch finalizes the C++ conversion of the ui-out subsystem, by
turning the ui_out and ui_out_impl structures into a single class
hierarchy. ui_out functions are turned into virtual methods of that new
class, so as a result there are a lot of call sites to update.
In the previous version of the patchset, there were separate ui_out and
ui_out_impl classes, but it wasn't really useful and added boilerplate.
In this version there is simply an ui_out base class that is
extended for CLI, TUI and MI.
It's a bit hard to maintain a ChangeLog for such a big patch, I did my
best but I'm sure there are some missing or outdated info in there...
gdb/ChangeLog:
* ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header,
ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int,
ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream,
ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text,
ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags,
ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect):
Remove, replace with a method in class ui_out.
(table_begin_ftype): Remove, replace with pure virtual method in
class ui_out.
(table_body_ftype): Likewise.
(table_end_ftype): Likewise.
(table_header_ftype): Likewise.
(ui_out_begin_ftype): Likewise.
(ui_out_end_ftype): Likewise.
(field_int_ftype): Likewise.
(field_skip_ftype): Likewise.
(field_string_ftype): Likewise.
(field_fmt_ftype): Likewise.
(spaces_ftype): Likewise.
(text_ftype): Likewise.
(message_ftype): Likewise.
(wrap_hint_ftype): Likewise.
(flush_ftype): Likewise.
(redirect_ftype): Likewise.
(data_destroy_ftype): Likewise.
(struct ui_out_impl): Remove, replace with class ui_out.
(ui_out_new): Remove.
(class ui_out): New class.
* ui-out.c (struct ui_out): Remove, replaced with class ui_out.
(current_level): Remove, replace with ui_out method.
(push_level): Likewise.
(pop_level): Likewise.
(uo_table_begin, uo_table_body, uo_table_end, uo_table_header,
uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt,
uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush,
uo_redirect, uo_field_string): Remove.
(ui_out_table_begin): Replace with ...
(ui_out::table_begin): ... this.
(ui_out_table_body): Replace with ...
(ui_out::table_body): ... this.
(ui_out_table_end): Replace with ...
(ui_out::table_end): ... this.
(ui_out_table_header): Replace with ...
(ui_out::table_header): ... this.
(ui_out_begin): Replace with ...
(ui_out::begin): ... this.
(ui_out_end): Replace with ...
(ui_out::end): ... this.
(ui_out_field_int): Replace with ...
(ui_out::field_int): ... this.
(ui_out_field_fmt_int): Replace with ...
(ui_out::field_fmt_int): ... this.
(ui_out_field_core_addr): Replace with ...
(ui_out::field_core_addr): ... this.
(ui_out_field_stream): Replace with ...
(ui_out::field_stream): ... this.
(ui_out_field_skip): Replace with ...
(ui_out::field_skip): ... this.
(ui_out_field_string): Replace with ...
(ui_out::field_string): ... this.
(ui_out_field_fmt): Replace with ...
(ui_out::field_fmt): ... this.
(ui_out_spaces): Replace with ...
(ui_out::spaces): ... this.
(ui_out_text): Replace with ...
(ui_out::text): ... this.
(ui_out_message): Replace with ...
(ui_out::message): ... this.
(ui_out_wrap_hint): Replace with ...
(ui_out::wrap_hint): ... this.
(ui_out_flush): Replace with ...
(ui_out::flush): ... this.
(ui_out_redirect): Replace with ...
(ui_out::redirect): ... this.
(ui_out_test_flags): Replace with ...
(ui_out::test_flags): ... this.
(ui_out_is_mi_like_p): Replace with ...
(ui_out::is_mi_like_p): ... this.
(verify_field): Replace with ...
(ui_out::verify_field): ... this.
(ui_out_query_field): Replace with ...
(ui_out::query_table_field): ... this.
(ui_out_data): Remove.
(ui_out_new): Remove, replace with ...
(ui_out::ui_out): ... this constructor.
(do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end,
do_cleanup_end, make_cleanup_ui_out_tuple_begin_end,
make_cleanup_ui_out_list_begin_end): Update fallouts of struct
ui_out -> class ui_out change.
* cli-out.c (cli_out_data): Remove.
(cli_uiout_dtor): Remove.
(cli_table_begin): Replace with ...
(cli_ui_out::do_table_begin): ... this new method.
(cli_table_body): Replace with ...
(cli_ui_out::do_table_body): ... this new method.
(cli_table_end): Replace with ...
(cli_ui_out::do_table_end): ... this new method.
(cli_table_header): Replace with ...
(cli_ui_out::do_table_header): ... this new method.
(cli_begin): Replace with ...
(cli_ui_out::do_begin): ... this new method.
(cli_end): Replace with ...
(cli_ui_out::do_end): ... this new method.
(cli_field_int): Replace with ...
(cli_ui_out::do_field_int): ... this new method.
(cli_field_skip): Replace with ...
(cli_ui_out::do_field_skip): ... this new method.
(cli_field_string): Replace with ...
(cli_ui_out::do_field_string): ... this new method.
(cli_field_fmt): Replace with ...
(cli_ui_out::do_field_fmt): ... this new method.
(cli_spaces): Replace with ...
(cli_ui_out::do_spaces): ... this new method.
(cli_text): Replace with ...
(cli_ui_out::do_text): ... this new method.
(cli_message): Replace with ...
(cli_ui_out::do_message): ... this new method.
(cli_wrap_hint): Replace with ...
(cli_ui_out::do_wrap_hint): ... this new method.
(cli_flush): Replace with ...
(cli_ui_out::do_flush): ... this new method.
(cli_redirect): Replace with ...
(cli_ui_out::do_redirect): ... this new method.
(out_field_fmt): Replace with ...
(cli_ui_out::out_field_fmt): ... this new method.
(field_separator): Replace with ...
(cli_ui_out::field_separator): ... this new method.
(cli_out_set_stream): Replace with ...
(cli_ui_out::set_stream): ... this new method.
(cli_ui_out_impl): Remove.
(cli_out_data_ctor): Remove.
(cli_ui_out_impl::cli_ui_out_impl): New constructor.
(cli_ui_out_impl::~cli_ui_out_impl): New destructor.
(cli_out_new): Change return type to cli_ui_out *, instantiate a
cli_ui_out.
* cli-out.h (cli_ui_out_data): Remove, replace with class
cli_ui_out.
(class cli_ui_out): New class.
(cli_ui_out_impl): Remove.
(cli_out_data_ctor): Remove.
(cli_out_new): Change return type to cli_ui_out*.
(cli_out_set_stream): Remove.
* cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type
to cli_ui_out*.
(cli_interpreter_resume): Adapt.
(cli_interpreter_exec): Adapt.
* mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove.
(mi_ui_out_impl): Remove.
(mi_table_begin): Replace with ...
(mi_ui_out::do_table_begin): ... this.
(mi_table_body): Replace with ...
(mi_ui_out::do_table_body): ... this.
(mi_table_end): Replace with ...
(mi_ui_out::do_table_end): ... this.
(mi_table_header): Replace with ...
(mi_ui_out::do_table_header): ... this.
(mi_begin): Replace with ...
(mi_ui_out::do_begin): ... this.
(mi_end): Replace with ...
(mi_ui_out::do_end): ... this.
(mi_field_int): Replace with ...
(mi_ui_out::do_field_int): ... this.
(mi_field_skip): Replace with ...
(mi_ui_out::do_field_skip): ... this.
(mi_field_string): Replace with ...
(mi_ui_out::do_field_string): ... this.
(mi_field_fmt): Replace with ...
(mi_ui_out::do_field_fmt): ... this.
(mi_spaces): Replace with ...
(mi_ui_out::do_spaces): ... this.
(mi_text): Replace with ...
(mi_ui_out::do_text): ... this.
(mi_message): Replace with ...
(mi_ui_out::do_message): ... this.
(mi_wrap_hint): Replace with ...
(mi_ui_out::do_wrap_hint): ... this.
(mi_flush): Replace with ...
(mi_ui_out::do_flush): ... this.
(mi_redirect): Replace with ...
(mi_ui_out::do_redirect):
(field_separator): Replace with ...
(mi_ui_out::field_separator):
(mi_open): Replace with ...
(mi_ui_out::open): ... this.
(mi_close): Replace with ...
(mi_ui_out::close): ... this.
(mi_out_rewind): Replace with ...
(mi_ui_out::rewind): ... this.
(mi_out_put): Replace with ...
(mi_ui_out::put): ... this.
(mi_version): Replace with ...
(mi_ui_out::version): ... this.
(mi_out_data_ctor): Replace with ...
(mi_ui_out::mi_ui_out): ... this.
(mi_out_data_dtor): Replace with ...
(mi_ui_out::~mi_ui_out): ... this.
(mi_out_new): Change return type to mi_ui_out*, instantiate
an mi_ui_out object.
(as_mi_ui_out): New function.
(mi_version): Update fallouts of struct ui_out to class ui_out
transition.
(mi_out_put): Likewise.
(mi_out_rewind): Likewise.
* mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*.
* tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl):
Remove.
(tui_field_int): Replace with ...
(tui_ui_out::do_field_int): ... this.
(tui_field_string): Replace with ...
(tui_ui_out::do_field_string): ... this.
(tui_field_fmt): Replace with ...
(tui_ui_out::do_field_fmt): ... this.
(tui_text): Replace with ...
(tui_ui_out::do_text): ... this.
(tui_out_new): Change return type to tui_ui_out*, instantiate
tui_ui_out object.
(tui_ui_out::tui_ui_out): New.
* tui/tui-out.h: New file.
* tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h.
* tui/tui-io.c: Include tui/tui-out.h.
(tui_old_uiout): Change type to cli_ui_out*.
(tui_setup_io): Use dynamic_cast.
* tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*.
* tui/tui-interp.c (tui_resume): Adapt.
* ada-lang.c (print_it_exception): Update fallouts of struct
ui_out to class ui_out transition.
(print_one_exception): Likewise.
(print_mention_exception): Likewise.
* ada-tasks.c (print_ada_task_info): Likewise.
(info_task): Likewise.
(task_command): Likewise.
* auto-load.c (print_script): Likewise.
(auto_load_info_scripts): Likewise.
(info_auto_load_cmd): Likewise.
* break-catch-sig.c (signal_catchpoint_print_one): Likewise.
* break-catch-syscall.c (print_it_catch_syscall): Likewise.
(print_one_catch_syscall): Likewise.
* break-catch-throw.c (print_it_exception_catchpoint): Likewise.
(print_one_exception_catchpoint): Likewise.
(print_one_detail_exception_catchpoint): Likewise.
(print_mention_exception_catchpoint): Likewise.
* breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise.
(print_solib_event): Likewise.
(watchpoint_check): Likewise.
(wrap_indent_at_field): Likewise.
(print_breakpoint_location): Likewise.
(output_thread_groups): Likewise.
(print_one_breakpoint_location): Likewise.
(breakpoint_1): Likewise.
(default_collect_info): Likewise.
(watchpoints_info): Likewise.
(print_it_catch_fork): Likewise.
(print_one_catch_fork): Likewise.
(print_it_catch_vfork): Likewise.
(print_one_catch_vfork): Likewise.
(print_it_catch_solib): Likewise.
(print_one_catch_solib): Likewise.
(print_it_catch_exec): Likewise.
(print_one_catch_exec): Likewise.
(mention): Likewise.
(print_it_ranged_breakpoint): Likewise.
(print_one_ranged_breakpoint): Likewise.
(print_one_detail_ranged_breakpoint): Likewise.
(print_mention_ranged_breakpoint): Likewise.
(print_it_watchpoint): Likewise.
(print_mention_watchpoint): Likewise.
(print_it_masked_watchpoint): Likewise.
(print_one_detail_masked_watchpoint): Likewise.
(print_mention_masked_watchpoint): Likewise.
(bkpt_print_it): Likewise.
(tracepoint_print_one_detail): Likewise.
(tracepoint_print_mention): Likewise.
(update_static_tracepoint): Likewise.
(tracepoints_info): Likewise.
(save_breakpoints): Likewise.
* cli/cli-cmds.c (complete_command): Likewise.
* cli/cli-logging.c (set_logging_redirect): Likewise.
(pop_output_files): Likewise.
(handle_redirections): Likewise.
* cli/cli-script.c (print_command_lines): Likewise.
* cli/cli-setshow.c (do_show_command): Likewise.
(cmd_show_list): Likewise.
* cp-abi.c (list_cp_abis): Likewise.
(show_cp_abi_cmd): Likewise.
* darwin-nat-info.c (darwin_debug_regions_recurse): Likewise.
* disasm.c (gdb_pretty_print_insn): Likewise.
(do_mixed_source_and_assembly_deprecated): Likewise.
(do_mixed_source_and_assembly): Likewise.
* gdb_bfd.c (print_one_bfd): Likewise.
(maintenance_info_bfds): Likewise.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise.
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise.
* i386-tdep.c (i386_mpx_print_bounds): Likewise.
* infcmd.c (run_command_1): Likewise.
(print_return_value_1): Likewise.
* inferior.c (print_selected_inferior): Likewise.
(print_inferior): Likewise.
* infrun.c (print_end_stepping_range_reason): Likewise.
(print_signal_exited_reason): Likewise.
(print_exited_reason): Likewise.
(print_signal_received_reason): Likewise.
(print_no_history_reason): Likewise.
* interps.c (interp_set): Likewise.
* linespec.c (decode_line_full): Likewise.
* linux-thread-db.c (info_auto_load_libthread_db): Likewise.
* mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
(mi_cmd_env_path): Likewise.
(mi_cmd_env_dir): Likewise.
(mi_cmd_inferior_tty_show): Likewise.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise.
(print_partial_file_name): Likewise.
(mi_cmd_file_list_exec_source_files): Likewise.
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise.
(mi_cmd_info_gdb_mi_command): Likewise.
* mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise.
(mi_cmd_stack_list_args): Likewise.
(list_arg_or_local): Likewise.
* mi/mi-cmd-var.c (print_varobj): Likewise.
(mi_cmd_var_create): Likewise.
(mi_cmd_var_delete): Likewise.
(mi_cmd_var_set_format): Likewise.
(mi_cmd_var_show_format): Likewise.
(mi_cmd_var_info_num_children): Likewise.
(mi_cmd_var_list_children): Likewise.
(mi_cmd_var_info_type): Likewise.
(mi_cmd_var_info_path_expression): Likewise.
(mi_cmd_var_info_expression): Likewise.
(mi_cmd_var_show_attributes): Likewise.
(mi_cmd_var_evaluate_expression): Likewise.
(mi_cmd_var_assign): Likewise.
(varobj_update_one): Likewise.
* mi/mi-interp.c (as_mi_interp): Likewise.
(mi_on_normal_stop_1): Likewise.
(mi_tsv_modified): Likewise.
(mi_breakpoint_created): Likewise.
(mi_breakpoint_modified): Likewise.
(mi_solib_loaded): Likewise.
(mi_solib_unloaded): Likewise.
(mi_command_param_changed): Likewise.
(mi_memory_changed): Likewise.
(mi_user_selected_context_changed): Likewise.
* mi/mi-main.c (print_one_inferior): Likewise.
(output_cores): Likewise.
(list_available_thread_groups): Likewise.
(mi_cmd_data_list_register_names): Likewise.
(mi_cmd_data_list_changed_registers): Likewise.
(output_register): Likewise.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Likewise.
(mi_cmd_data_read_memory_bytes): Likewise.
(mi_cmd_list_features): Likewise.
(mi_cmd_list_target_features): Likewise.
(mi_cmd_add_inferior): Likewise.
(mi_execute_command): Likewise.
(mi_load_progress): Likewise.
(print_variable_or_computed): Likewise.
(mi_cmd_trace_frame_collected): Likewise.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise.
* osdata.c (info_osdata_command): Likewise.
* probe.c (gen_ui_out_table_header_info): Likewise.
(print_ui_out_not_applicables): Likewise.
(print_ui_out_info): Likewise.
(info_probes_for_ops): Likewise.
(enable_probes_command): Likewise.
(disable_probes_command): Likewise.
* progspace.c (print_program_space): Likewise.
* python/py-breakpoint.c (bppy_get_commands): Likewise.
* python/py-framefilter.c (py_print_type): Likewise.
(py_print_value): Likewise.
(py_print_single_arg): Likewise.
(enumerate_args): Likewise.
(enumerate_locals): Likewise.
(py_print_args): Likewise.
(py_print_frame): Likewise.
* record-btrace.c (btrace_ui_out_decode_error): Likewise.
(btrace_call_history_insn_range): Likewise.
(btrace_call_history_src_line): Likewise.
(btrace_call_history): Likewise.
* remote.c (show_remote_cmd): Likewise.
* skip.c (skip_info): Likewise.
* solib.c (info_sharedlibrary_command): Likewise.
* source.c (print_source_lines_base): Likewise.
* spu-tdep.c (info_spu_event_command): Likewise.
(info_spu_signal_command): Likewise.
(info_spu_mailbox_list): Likewise.
(info_spu_dma_cmdlist): Likewise.
(info_spu_dma_command): Likewise.
(info_spu_proxydma_command): Likewise.
* stack.c (print_stack_frame): Likewise.
(print_frame_arg): Likewise.
(read_frame_arg): Likewise.
(print_frame_args): Likewise.
(print_frame_info): Likewise.
(print_frame): Likewise.
* symfile.c (load_progress): Likewise.
(generic_load): Likewise.
(print_transfer_performance): Likewise.
* thread.c (do_captured_list_thread_ids): Likewise.
(print_thread_info_1): Likewise.
(restore_selected_frame): Likewise.
(do_captured_thread_select): Likewise.
(print_selected_thread_frame): Likewise.
* top.c (execute_command_to_string): Likewise.
* tracepoint.c (tvariables_info_1): Likewise.
(trace_status_mi): Likewise.
(tfind_1): Likewise.
(print_one_static_tracepoint_marker): Likewise.
(info_static_tracepoint_markers_command): Likewise.
* utils.c (do_ui_out_redirect_pop): Likewise.
(fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
|
|
|
#include "tui/tui-out.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
#include "ui-out.h"
|
|
|
|
#include "cli-out.h"
|
|
|
|
#include <fcntl.h>
|
2001-07-22 00:35:40 +02:00
|
|
|
#include <signal.h>
|
2019-03-14 16:31:38 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2019-01-23 18:21:39 +01:00
|
|
|
#include "common/filestuff.h"
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
#include "completer.h"
|
2004-02-10 Andrew Cagney <cagney@redhat.com>
* defs.h: Do not include "tui.h".
* gdb_curses.h: New file.
* tui/tui-hooks.h: New file.
* tui/tui.h (tui_update_all_exec_infos): Delete declaration.
(tui_install_hooks, tui_remove_hooks): Delete declarations.
(tui_initialize_io): Delete declaration.
(tui_initialize_readline: Delete redundant declaration.
(struct tui_point): Delete definition.
* tui/tui-data.h (struct tui_point): Define.
* cli/cli-decode.c [TUI]: Include "tui/tui.h".
* utils.c: Include "tui/tui.h".
* tui/tui-data.h: Include "tui/tui.h" and "gdb_curses.h".
* printcmd.c [TUI]: Include "tui/tui.h".
* cli/cli-cmds.c [TUI]: Include "tui/tui.h".
* tui/tui-command.c: Include "gdb_curses.h".
* tui/tui.c, tui/tui-winsource.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-windata.c, tui/tui-win.c, tui/tui-stack.c: Ditto.
* tui/tui-source.c, tui/tui-regs.c, tui/tui-layout.c: Ditto.
* tui/tui-io.c, tui/tui-disasm.c, tui/tui-data.c: : Ditto.
* tui/tui-hooks.c: Include "tui-hooks.h" and "gdb_curses.h".
* Makefile.in: Update all dependencies.
(tui_hooks_h, gdb_curses_h): Define.
(SUBDIR_TUI_CFLAGS): Remove -I${srcdir}/tui.
2004-02-10 20:08:19 +01:00
|
|
|
#include "gdb_curses.h"
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
#include <map>
|
2001-07-21 21:56:54 +02:00
|
|
|
|
2004-04-09 15:54:34 +02:00
|
|
|
/* This redefines CTRL if it is not already defined, so it must come
|
|
|
|
after terminal state releated include files like <term.h> and
|
|
|
|
"gdb_curses.h". */
|
|
|
|
#include "readline/readline.h"
|
|
|
|
|
2019-03-14 16:31:38 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
static SHORT ncurses_norm_attr;
|
|
|
|
#endif
|
|
|
|
|
2018-09-02 02:44:33 +02:00
|
|
|
static int tui_getc (FILE *fp);
|
|
|
|
|
|
|
|
static int
|
2004-01-18 Andrew Cagney <cagney@redhat.com>
* tui/tui-io.c: Update copyright.
(key_is_end_sequence, key_is_backspace): New functions.
(key_is_command_char, key_is_start_sequence): New function.
(tui_getc): Update references.
* tui/tui-io.h: Update copyright.
(m_tuiStartNewLine): Delete macro.
(m_isBackspace, m_isDeleteChar): Delete macros.
(m_isDeleteLine, m_isDeleteToEol): Delete macros.
(m_isNextPage, m_isPrevPage): Delete macros.
(m_isLeftArrow, m_isRightArrow): Delete macros.
(m_isXdbStyleCommandChar): Delete macro.
(key_is_start_sequence): Declare, replace m_isStartSequence.
(key_is_end_sequence): Declare, replace m_isEndSequence.
(key_is_backspace): Declare ,replace m_isBackspace.
(key_is_command_char): Declare, replace m_isCommandChar.
* tui/tui-command.c: Update copyright.
(tuiDispatchCtrlChar): Update references.
2004-01-19 06:06:34 +01:00
|
|
|
key_is_start_sequence (int ch)
|
|
|
|
{
|
|
|
|
return (ch == 27);
|
|
|
|
}
|
|
|
|
|
2002-08-27 22:58:27 +02:00
|
|
|
/* Use definition from readline 4.3. */
|
|
|
|
#undef CTRL_CHAR
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-data.c, tui-data.h, tui-disasm.c, tui-disasm.h, tui-hooks.c,
tui-io.c, tui-layout.c, tui-layout.h, tui-out.c, tui-regs.c,
tui-source.c, tui-source.h, tui-stack.c, tui-win.c, tui-win.h,
tui-windata.c, tui-windata.h, tui-wingeneral.c, tui-winsource.c,
tui-winsource.h, tui.c, tui.h: Function declarations and
definitions, wrap long lines.
2007-08-15 01:50:39 +02:00
|
|
|
#define CTRL_CHAR(c) \
|
|
|
|
((c) < control_character_threshold && (((c) & 0x80) == 0))
|
2002-08-27 22:58:27 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* This file controls the IO interactions between gdb and curses.
|
|
|
|
When the TUI is enabled, gdb has two modes a curses and a standard
|
|
|
|
mode.
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
In curses mode, the gdb outputs are made in a curses command
|
|
|
|
window. For this, the gdb_stdout and gdb_stderr are redirected to
|
|
|
|
the specific ui_file implemented by TUI. The output is handled by
|
|
|
|
tui_puts(). The input is also controlled by curses with
|
|
|
|
tui_getc(). The readline library uses this function to get its
|
|
|
|
input. Several readline hooks are installed to redirect readline
|
|
|
|
output to the TUI (see also the note below).
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
In normal mode, the gdb outputs are restored to their origin, that
|
|
|
|
is as if TUI is not used. Readline also uses its original getc()
|
|
|
|
function with stdin.
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
Note SCz/2001-07-21: the current readline is not clean in its
|
|
|
|
management of the output. Even if we install a redisplay handler,
|
|
|
|
it sometimes writes on a stdout file. It is important to redirect
|
|
|
|
every output produced by readline, otherwise the curses window will
|
|
|
|
be garbled. This is implemented with a pipe that TUI reads and
|
|
|
|
readline writes to. A gdb input handler is created so that reading
|
|
|
|
the pipe is handled automatically. This will probably not work on
|
|
|
|
non-Unix platforms. The best fix is to make readline clean enougth
|
|
|
|
so that is never write on stdout.
|
|
|
|
|
|
|
|
Note SCz/2002-09-01: we now use more readline hooks and it seems
|
|
|
|
that with them we don't need the pipe anymore (verified by creating
|
|
|
|
the pipe and closing its end so that write causes a SIGPIPE). The
|
|
|
|
old pipe code is still there and can be conditionally removed by
|
2002-09-03 22:47:48 +02:00
|
|
|
#undef TUI_USE_PIPE_FOR_READLINE. */
|
|
|
|
|
|
|
|
/* For gdb 5.3, prefer to continue the pipe hack as a backup wheel. */
|
2009-07-20 17:24:55 +02:00
|
|
|
#ifdef HAVE_PIPE
|
2002-09-03 22:47:48 +02:00
|
|
|
#define TUI_USE_PIPE_FOR_READLINE
|
2009-07-20 17:24:55 +02:00
|
|
|
#endif
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* #undef TUI_USE_PIPE_FOR_READLINE */
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* TUI output files. */
|
|
|
|
static struct ui_file *tui_stdout;
|
|
|
|
static struct ui_file *tui_stderr;
|
2002-09-10 21:59:31 +02:00
|
|
|
struct ui_out *tui_out;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* GDB output files in non-curses mode. */
|
|
|
|
static struct ui_file *tui_old_stdout;
|
|
|
|
static struct ui_file *tui_old_stderr;
|
Class-ify ui_out
This patch finalizes the C++ conversion of the ui-out subsystem, by
turning the ui_out and ui_out_impl structures into a single class
hierarchy. ui_out functions are turned into virtual methods of that new
class, so as a result there are a lot of call sites to update.
In the previous version of the patchset, there were separate ui_out and
ui_out_impl classes, but it wasn't really useful and added boilerplate.
In this version there is simply an ui_out base class that is
extended for CLI, TUI and MI.
It's a bit hard to maintain a ChangeLog for such a big patch, I did my
best but I'm sure there are some missing or outdated info in there...
gdb/ChangeLog:
* ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header,
ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int,
ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream,
ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text,
ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags,
ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect):
Remove, replace with a method in class ui_out.
(table_begin_ftype): Remove, replace with pure virtual method in
class ui_out.
(table_body_ftype): Likewise.
(table_end_ftype): Likewise.
(table_header_ftype): Likewise.
(ui_out_begin_ftype): Likewise.
(ui_out_end_ftype): Likewise.
(field_int_ftype): Likewise.
(field_skip_ftype): Likewise.
(field_string_ftype): Likewise.
(field_fmt_ftype): Likewise.
(spaces_ftype): Likewise.
(text_ftype): Likewise.
(message_ftype): Likewise.
(wrap_hint_ftype): Likewise.
(flush_ftype): Likewise.
(redirect_ftype): Likewise.
(data_destroy_ftype): Likewise.
(struct ui_out_impl): Remove, replace with class ui_out.
(ui_out_new): Remove.
(class ui_out): New class.
* ui-out.c (struct ui_out): Remove, replaced with class ui_out.
(current_level): Remove, replace with ui_out method.
(push_level): Likewise.
(pop_level): Likewise.
(uo_table_begin, uo_table_body, uo_table_end, uo_table_header,
uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt,
uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush,
uo_redirect, uo_field_string): Remove.
(ui_out_table_begin): Replace with ...
(ui_out::table_begin): ... this.
(ui_out_table_body): Replace with ...
(ui_out::table_body): ... this.
(ui_out_table_end): Replace with ...
(ui_out::table_end): ... this.
(ui_out_table_header): Replace with ...
(ui_out::table_header): ... this.
(ui_out_begin): Replace with ...
(ui_out::begin): ... this.
(ui_out_end): Replace with ...
(ui_out::end): ... this.
(ui_out_field_int): Replace with ...
(ui_out::field_int): ... this.
(ui_out_field_fmt_int): Replace with ...
(ui_out::field_fmt_int): ... this.
(ui_out_field_core_addr): Replace with ...
(ui_out::field_core_addr): ... this.
(ui_out_field_stream): Replace with ...
(ui_out::field_stream): ... this.
(ui_out_field_skip): Replace with ...
(ui_out::field_skip): ... this.
(ui_out_field_string): Replace with ...
(ui_out::field_string): ... this.
(ui_out_field_fmt): Replace with ...
(ui_out::field_fmt): ... this.
(ui_out_spaces): Replace with ...
(ui_out::spaces): ... this.
(ui_out_text): Replace with ...
(ui_out::text): ... this.
(ui_out_message): Replace with ...
(ui_out::message): ... this.
(ui_out_wrap_hint): Replace with ...
(ui_out::wrap_hint): ... this.
(ui_out_flush): Replace with ...
(ui_out::flush): ... this.
(ui_out_redirect): Replace with ...
(ui_out::redirect): ... this.
(ui_out_test_flags): Replace with ...
(ui_out::test_flags): ... this.
(ui_out_is_mi_like_p): Replace with ...
(ui_out::is_mi_like_p): ... this.
(verify_field): Replace with ...
(ui_out::verify_field): ... this.
(ui_out_query_field): Replace with ...
(ui_out::query_table_field): ... this.
(ui_out_data): Remove.
(ui_out_new): Remove, replace with ...
(ui_out::ui_out): ... this constructor.
(do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end,
do_cleanup_end, make_cleanup_ui_out_tuple_begin_end,
make_cleanup_ui_out_list_begin_end): Update fallouts of struct
ui_out -> class ui_out change.
* cli-out.c (cli_out_data): Remove.
(cli_uiout_dtor): Remove.
(cli_table_begin): Replace with ...
(cli_ui_out::do_table_begin): ... this new method.
(cli_table_body): Replace with ...
(cli_ui_out::do_table_body): ... this new method.
(cli_table_end): Replace with ...
(cli_ui_out::do_table_end): ... this new method.
(cli_table_header): Replace with ...
(cli_ui_out::do_table_header): ... this new method.
(cli_begin): Replace with ...
(cli_ui_out::do_begin): ... this new method.
(cli_end): Replace with ...
(cli_ui_out::do_end): ... this new method.
(cli_field_int): Replace with ...
(cli_ui_out::do_field_int): ... this new method.
(cli_field_skip): Replace with ...
(cli_ui_out::do_field_skip): ... this new method.
(cli_field_string): Replace with ...
(cli_ui_out::do_field_string): ... this new method.
(cli_field_fmt): Replace with ...
(cli_ui_out::do_field_fmt): ... this new method.
(cli_spaces): Replace with ...
(cli_ui_out::do_spaces): ... this new method.
(cli_text): Replace with ...
(cli_ui_out::do_text): ... this new method.
(cli_message): Replace with ...
(cli_ui_out::do_message): ... this new method.
(cli_wrap_hint): Replace with ...
(cli_ui_out::do_wrap_hint): ... this new method.
(cli_flush): Replace with ...
(cli_ui_out::do_flush): ... this new method.
(cli_redirect): Replace with ...
(cli_ui_out::do_redirect): ... this new method.
(out_field_fmt): Replace with ...
(cli_ui_out::out_field_fmt): ... this new method.
(field_separator): Replace with ...
(cli_ui_out::field_separator): ... this new method.
(cli_out_set_stream): Replace with ...
(cli_ui_out::set_stream): ... this new method.
(cli_ui_out_impl): Remove.
(cli_out_data_ctor): Remove.
(cli_ui_out_impl::cli_ui_out_impl): New constructor.
(cli_ui_out_impl::~cli_ui_out_impl): New destructor.
(cli_out_new): Change return type to cli_ui_out *, instantiate a
cli_ui_out.
* cli-out.h (cli_ui_out_data): Remove, replace with class
cli_ui_out.
(class cli_ui_out): New class.
(cli_ui_out_impl): Remove.
(cli_out_data_ctor): Remove.
(cli_out_new): Change return type to cli_ui_out*.
(cli_out_set_stream): Remove.
* cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type
to cli_ui_out*.
(cli_interpreter_resume): Adapt.
(cli_interpreter_exec): Adapt.
* mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove.
(mi_ui_out_impl): Remove.
(mi_table_begin): Replace with ...
(mi_ui_out::do_table_begin): ... this.
(mi_table_body): Replace with ...
(mi_ui_out::do_table_body): ... this.
(mi_table_end): Replace with ...
(mi_ui_out::do_table_end): ... this.
(mi_table_header): Replace with ...
(mi_ui_out::do_table_header): ... this.
(mi_begin): Replace with ...
(mi_ui_out::do_begin): ... this.
(mi_end): Replace with ...
(mi_ui_out::do_end): ... this.
(mi_field_int): Replace with ...
(mi_ui_out::do_field_int): ... this.
(mi_field_skip): Replace with ...
(mi_ui_out::do_field_skip): ... this.
(mi_field_string): Replace with ...
(mi_ui_out::do_field_string): ... this.
(mi_field_fmt): Replace with ...
(mi_ui_out::do_field_fmt): ... this.
(mi_spaces): Replace with ...
(mi_ui_out::do_spaces): ... this.
(mi_text): Replace with ...
(mi_ui_out::do_text): ... this.
(mi_message): Replace with ...
(mi_ui_out::do_message): ... this.
(mi_wrap_hint): Replace with ...
(mi_ui_out::do_wrap_hint): ... this.
(mi_flush): Replace with ...
(mi_ui_out::do_flush): ... this.
(mi_redirect): Replace with ...
(mi_ui_out::do_redirect):
(field_separator): Replace with ...
(mi_ui_out::field_separator):
(mi_open): Replace with ...
(mi_ui_out::open): ... this.
(mi_close): Replace with ...
(mi_ui_out::close): ... this.
(mi_out_rewind): Replace with ...
(mi_ui_out::rewind): ... this.
(mi_out_put): Replace with ...
(mi_ui_out::put): ... this.
(mi_version): Replace with ...
(mi_ui_out::version): ... this.
(mi_out_data_ctor): Replace with ...
(mi_ui_out::mi_ui_out): ... this.
(mi_out_data_dtor): Replace with ...
(mi_ui_out::~mi_ui_out): ... this.
(mi_out_new): Change return type to mi_ui_out*, instantiate
an mi_ui_out object.
(as_mi_ui_out): New function.
(mi_version): Update fallouts of struct ui_out to class ui_out
transition.
(mi_out_put): Likewise.
(mi_out_rewind): Likewise.
* mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*.
* tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl):
Remove.
(tui_field_int): Replace with ...
(tui_ui_out::do_field_int): ... this.
(tui_field_string): Replace with ...
(tui_ui_out::do_field_string): ... this.
(tui_field_fmt): Replace with ...
(tui_ui_out::do_field_fmt): ... this.
(tui_text): Replace with ...
(tui_ui_out::do_text): ... this.
(tui_out_new): Change return type to tui_ui_out*, instantiate
tui_ui_out object.
(tui_ui_out::tui_ui_out): New.
* tui/tui-out.h: New file.
* tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h.
* tui/tui-io.c: Include tui/tui-out.h.
(tui_old_uiout): Change type to cli_ui_out*.
(tui_setup_io): Use dynamic_cast.
* tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*.
* tui/tui-interp.c (tui_resume): Adapt.
* ada-lang.c (print_it_exception): Update fallouts of struct
ui_out to class ui_out transition.
(print_one_exception): Likewise.
(print_mention_exception): Likewise.
* ada-tasks.c (print_ada_task_info): Likewise.
(info_task): Likewise.
(task_command): Likewise.
* auto-load.c (print_script): Likewise.
(auto_load_info_scripts): Likewise.
(info_auto_load_cmd): Likewise.
* break-catch-sig.c (signal_catchpoint_print_one): Likewise.
* break-catch-syscall.c (print_it_catch_syscall): Likewise.
(print_one_catch_syscall): Likewise.
* break-catch-throw.c (print_it_exception_catchpoint): Likewise.
(print_one_exception_catchpoint): Likewise.
(print_one_detail_exception_catchpoint): Likewise.
(print_mention_exception_catchpoint): Likewise.
* breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise.
(print_solib_event): Likewise.
(watchpoint_check): Likewise.
(wrap_indent_at_field): Likewise.
(print_breakpoint_location): Likewise.
(output_thread_groups): Likewise.
(print_one_breakpoint_location): Likewise.
(breakpoint_1): Likewise.
(default_collect_info): Likewise.
(watchpoints_info): Likewise.
(print_it_catch_fork): Likewise.
(print_one_catch_fork): Likewise.
(print_it_catch_vfork): Likewise.
(print_one_catch_vfork): Likewise.
(print_it_catch_solib): Likewise.
(print_one_catch_solib): Likewise.
(print_it_catch_exec): Likewise.
(print_one_catch_exec): Likewise.
(mention): Likewise.
(print_it_ranged_breakpoint): Likewise.
(print_one_ranged_breakpoint): Likewise.
(print_one_detail_ranged_breakpoint): Likewise.
(print_mention_ranged_breakpoint): Likewise.
(print_it_watchpoint): Likewise.
(print_mention_watchpoint): Likewise.
(print_it_masked_watchpoint): Likewise.
(print_one_detail_masked_watchpoint): Likewise.
(print_mention_masked_watchpoint): Likewise.
(bkpt_print_it): Likewise.
(tracepoint_print_one_detail): Likewise.
(tracepoint_print_mention): Likewise.
(update_static_tracepoint): Likewise.
(tracepoints_info): Likewise.
(save_breakpoints): Likewise.
* cli/cli-cmds.c (complete_command): Likewise.
* cli/cli-logging.c (set_logging_redirect): Likewise.
(pop_output_files): Likewise.
(handle_redirections): Likewise.
* cli/cli-script.c (print_command_lines): Likewise.
* cli/cli-setshow.c (do_show_command): Likewise.
(cmd_show_list): Likewise.
* cp-abi.c (list_cp_abis): Likewise.
(show_cp_abi_cmd): Likewise.
* darwin-nat-info.c (darwin_debug_regions_recurse): Likewise.
* disasm.c (gdb_pretty_print_insn): Likewise.
(do_mixed_source_and_assembly_deprecated): Likewise.
(do_mixed_source_and_assembly): Likewise.
* gdb_bfd.c (print_one_bfd): Likewise.
(maintenance_info_bfds): Likewise.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise.
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise.
* i386-tdep.c (i386_mpx_print_bounds): Likewise.
* infcmd.c (run_command_1): Likewise.
(print_return_value_1): Likewise.
* inferior.c (print_selected_inferior): Likewise.
(print_inferior): Likewise.
* infrun.c (print_end_stepping_range_reason): Likewise.
(print_signal_exited_reason): Likewise.
(print_exited_reason): Likewise.
(print_signal_received_reason): Likewise.
(print_no_history_reason): Likewise.
* interps.c (interp_set): Likewise.
* linespec.c (decode_line_full): Likewise.
* linux-thread-db.c (info_auto_load_libthread_db): Likewise.
* mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
(mi_cmd_env_path): Likewise.
(mi_cmd_env_dir): Likewise.
(mi_cmd_inferior_tty_show): Likewise.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise.
(print_partial_file_name): Likewise.
(mi_cmd_file_list_exec_source_files): Likewise.
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise.
(mi_cmd_info_gdb_mi_command): Likewise.
* mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise.
(mi_cmd_stack_list_args): Likewise.
(list_arg_or_local): Likewise.
* mi/mi-cmd-var.c (print_varobj): Likewise.
(mi_cmd_var_create): Likewise.
(mi_cmd_var_delete): Likewise.
(mi_cmd_var_set_format): Likewise.
(mi_cmd_var_show_format): Likewise.
(mi_cmd_var_info_num_children): Likewise.
(mi_cmd_var_list_children): Likewise.
(mi_cmd_var_info_type): Likewise.
(mi_cmd_var_info_path_expression): Likewise.
(mi_cmd_var_info_expression): Likewise.
(mi_cmd_var_show_attributes): Likewise.
(mi_cmd_var_evaluate_expression): Likewise.
(mi_cmd_var_assign): Likewise.
(varobj_update_one): Likewise.
* mi/mi-interp.c (as_mi_interp): Likewise.
(mi_on_normal_stop_1): Likewise.
(mi_tsv_modified): Likewise.
(mi_breakpoint_created): Likewise.
(mi_breakpoint_modified): Likewise.
(mi_solib_loaded): Likewise.
(mi_solib_unloaded): Likewise.
(mi_command_param_changed): Likewise.
(mi_memory_changed): Likewise.
(mi_user_selected_context_changed): Likewise.
* mi/mi-main.c (print_one_inferior): Likewise.
(output_cores): Likewise.
(list_available_thread_groups): Likewise.
(mi_cmd_data_list_register_names): Likewise.
(mi_cmd_data_list_changed_registers): Likewise.
(output_register): Likewise.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Likewise.
(mi_cmd_data_read_memory_bytes): Likewise.
(mi_cmd_list_features): Likewise.
(mi_cmd_list_target_features): Likewise.
(mi_cmd_add_inferior): Likewise.
(mi_execute_command): Likewise.
(mi_load_progress): Likewise.
(print_variable_or_computed): Likewise.
(mi_cmd_trace_frame_collected): Likewise.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise.
* osdata.c (info_osdata_command): Likewise.
* probe.c (gen_ui_out_table_header_info): Likewise.
(print_ui_out_not_applicables): Likewise.
(print_ui_out_info): Likewise.
(info_probes_for_ops): Likewise.
(enable_probes_command): Likewise.
(disable_probes_command): Likewise.
* progspace.c (print_program_space): Likewise.
* python/py-breakpoint.c (bppy_get_commands): Likewise.
* python/py-framefilter.c (py_print_type): Likewise.
(py_print_value): Likewise.
(py_print_single_arg): Likewise.
(enumerate_args): Likewise.
(enumerate_locals): Likewise.
(py_print_args): Likewise.
(py_print_frame): Likewise.
* record-btrace.c (btrace_ui_out_decode_error): Likewise.
(btrace_call_history_insn_range): Likewise.
(btrace_call_history_src_line): Likewise.
(btrace_call_history): Likewise.
* remote.c (show_remote_cmd): Likewise.
* skip.c (skip_info): Likewise.
* solib.c (info_sharedlibrary_command): Likewise.
* source.c (print_source_lines_base): Likewise.
* spu-tdep.c (info_spu_event_command): Likewise.
(info_spu_signal_command): Likewise.
(info_spu_mailbox_list): Likewise.
(info_spu_dma_cmdlist): Likewise.
(info_spu_dma_command): Likewise.
(info_spu_proxydma_command): Likewise.
* stack.c (print_stack_frame): Likewise.
(print_frame_arg): Likewise.
(read_frame_arg): Likewise.
(print_frame_args): Likewise.
(print_frame_info): Likewise.
(print_frame): Likewise.
* symfile.c (load_progress): Likewise.
(generic_load): Likewise.
(print_transfer_performance): Likewise.
* thread.c (do_captured_list_thread_ids): Likewise.
(print_thread_info_1): Likewise.
(restore_selected_frame): Likewise.
(do_captured_thread_select): Likewise.
(print_selected_thread_frame): Likewise.
* top.c (execute_command_to_string): Likewise.
* tracepoint.c (tvariables_info_1): Likewise.
(trace_status_mi): Likewise.
(tfind_1): Likewise.
(print_one_static_tracepoint_marker): Likewise.
(info_static_tracepoint_markers_command): Likewise.
* utils.c (do_ui_out_redirect_pop): Likewise.
(fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
|
|
|
cli_ui_out *tui_old_uiout;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Readline previous hooks. */
|
2014-06-20 17:43:56 +02:00
|
|
|
static rl_getc_func_t *tui_old_rl_getc_function;
|
|
|
|
static rl_voidfunc_t *tui_old_rl_redisplay_function;
|
|
|
|
static rl_vintfunc_t *tui_old_rl_prep_terminal;
|
|
|
|
static rl_voidfunc_t *tui_old_rl_deprep_terminal;
|
2015-02-01 00:07:22 +01:00
|
|
|
static rl_compdisp_func_t *tui_old_rl_display_matches_hook;
|
2011-05-12 01:38:44 +02:00
|
|
|
static int tui_old_rl_echoing_p;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Readline output stream.
|
|
|
|
Should be removed when readline is clean. */
|
|
|
|
static FILE *tui_rl_outstream;
|
|
|
|
static FILE *tui_old_rl_outstream;
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2001-07-21 21:56:54 +02:00
|
|
|
static int tui_readline_pipe[2];
|
2002-09-03 22:47:48 +02:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-10-26 12:38:57 +02:00
|
|
|
/* The last gdb prompt that was registered in readline.
|
|
|
|
This may be the main gdb prompt or a secondary prompt. */
|
|
|
|
static char *tui_rl_saved_prompt;
|
|
|
|
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
/* Print a character in the curses command window. The output is
|
|
|
|
buffered. It is up to the caller to refresh the screen if
|
|
|
|
necessary. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_tui_putc (WINDOW *w, char c)
|
|
|
|
{
|
|
|
|
static int tui_skip_line = -1;
|
|
|
|
|
|
|
|
/* Catch annotation and discard them. We need two \032 and discard
|
|
|
|
until a \n is seen. */
|
|
|
|
if (c == '\032')
|
|
|
|
{
|
|
|
|
tui_skip_line++;
|
|
|
|
}
|
|
|
|
else if (tui_skip_line != 1)
|
|
|
|
{
|
|
|
|
tui_skip_line = -1;
|
|
|
|
/* Expand TABs, since ncurses on MS-Windows doesn't. */
|
|
|
|
if (c == '\t')
|
|
|
|
{
|
|
|
|
int col;
|
|
|
|
|
|
|
|
col = getcurx (w);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
waddch (w, ' ');
|
|
|
|
col++;
|
|
|
|
}
|
|
|
|
while ((col % 8) != 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
waddch (w, c);
|
|
|
|
}
|
|
|
|
else if (c == '\n')
|
|
|
|
tui_skip_line = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the cached value of the command window's start line based on
|
|
|
|
the window's current Y coordinate. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_cmdwin_start_line ()
|
|
|
|
{
|
|
|
|
TUI_CMD_WIN->detail.command_info.start_line
|
|
|
|
= getcury (TUI_CMD_WIN->generic.handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print a character in the curses command window. The output is
|
|
|
|
buffered. It is up to the caller to refresh the screen if
|
|
|
|
necessary. */
|
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
static void
|
|
|
|
tui_putc (char c)
|
|
|
|
{
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
WINDOW *w = TUI_CMD_WIN->generic.handle;
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
do_tui_putc (w, c);
|
|
|
|
update_cmdwin_start_line ();
|
2002-09-03 22:47:48 +02:00
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
/* This maps colors to their corresponding color index. */
|
|
|
|
|
|
|
|
static std::map<ui_file_style::color, int> color_map;
|
|
|
|
|
|
|
|
/* This holds a pair of colors and is used to track the mapping
|
|
|
|
between a color pair index and the actual colors. */
|
|
|
|
|
|
|
|
struct color_pair
|
|
|
|
{
|
|
|
|
int fg;
|
|
|
|
int bg;
|
|
|
|
|
|
|
|
bool operator< (const color_pair &o) const
|
|
|
|
{
|
|
|
|
return fg < o.fg || (fg == o.fg && bg < o.bg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This maps pairs of colors to their corresponding color pair
|
|
|
|
index. */
|
|
|
|
|
|
|
|
static std::map<color_pair, int> color_pair_map;
|
|
|
|
|
|
|
|
/* This is indexed by ANSI color offset from the base color, and holds
|
|
|
|
the corresponding curses color constant. */
|
|
|
|
|
|
|
|
static const int curses_colors[] = {
|
|
|
|
COLOR_BLACK,
|
|
|
|
COLOR_RED,
|
|
|
|
COLOR_GREEN,
|
|
|
|
COLOR_YELLOW,
|
|
|
|
COLOR_BLUE,
|
|
|
|
COLOR_MAGENTA,
|
|
|
|
COLOR_CYAN,
|
|
|
|
COLOR_WHITE
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Given a color, find its index. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
get_color (const ui_file_style::color &color, int *result)
|
|
|
|
{
|
|
|
|
if (color.is_none ())
|
|
|
|
*result = -1;
|
|
|
|
else if (color.is_basic ())
|
|
|
|
*result = curses_colors[color.get_value ()];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto it = color_map.find (color);
|
|
|
|
if (it == color_map.end ())
|
|
|
|
{
|
|
|
|
/* The first 8 colors are standard. */
|
|
|
|
int next = color_map.size () + 8;
|
|
|
|
if (next >= COLORS)
|
|
|
|
return false;
|
|
|
|
uint8_t rgb[3];
|
|
|
|
color.get_rgb (rgb);
|
|
|
|
/* We store RGB as 0..255, but curses wants 0..1000. */
|
|
|
|
if (init_color (next, rgb[0] * 1000 / 255, rgb[1] * 1000 / 255,
|
|
|
|
rgb[2] * 1000 / 255) == ERR)
|
|
|
|
return false;
|
|
|
|
color_map[color] = next;
|
|
|
|
*result = next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*result = it->second;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The most recently emitted color pair. */
|
|
|
|
|
|
|
|
static int last_color_pair = -1;
|
|
|
|
|
|
|
|
/* The most recently applied style. */
|
|
|
|
|
|
|
|
static ui_file_style last_style;
|
|
|
|
|
Improve/fix the TUI's current source line highlight
With styling enabled, I think the way we display the TUI's
highlighted/current line is very ugly and distracting. The problem in
my view is that we reverse foreground/background in colored text as
well, leading to rainbow of background colors.
This patch changes that to something that I find much more sensible --
only reverse the default foreground/background colors, leave styled
text colors alone. If the foreground color is not the default
(because the text was styled), leave the foreground color as is. If
e.g., the terminal is fg=BLACK, and bg=WHITE, and the style wants to
print text in RED, reverse the background color (print in BLACK), but
still print the text in RED.
Note: The new ui_file_style::set_fg method isn't called set_foreground
instead, because set_foreground is a macro in /usr/lib/term.h (ncurses).
gdb/ChangeLog:
2019-03-18 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
New globals.
(apply_style): New, factored out from ...
(apply_ansi_escape): ... this. Handle reverse video mode.
(tui_set_reverse_mode): New function.
* tui/tui-io.h (tui_set_reverse_mode): New declaration.
* tui/tui-winsource.c (tui_show_source_line): Use
tui_set_reverse_mode instead of setting A_STANDOUT.
* ui-style.h (struct ui_file_style) <set_reverse, set_fg, set_bg>:
New setter methods.
2019-03-18 15:26:00 +01:00
|
|
|
/* If true, we're highlighting the current source line in reverse
|
|
|
|
video mode. */
|
|
|
|
static bool reverse_mode_p = false;
|
|
|
|
|
|
|
|
/* The background/foreground colors before we entered reverse
|
|
|
|
mode. */
|
|
|
|
static ui_file_style::color reverse_save_bg (ui_file_style::NONE);
|
|
|
|
static ui_file_style::color reverse_save_fg (ui_file_style::NONE);
|
|
|
|
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
/* Given two colors, return their color pair index; making a new one
|
|
|
|
if necessary. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_color_pair (int fg, int bg)
|
|
|
|
{
|
|
|
|
color_pair c = { fg, bg };
|
|
|
|
auto it = color_pair_map.find (c);
|
|
|
|
if (it == color_pair_map.end ())
|
|
|
|
{
|
|
|
|
/* Color pair 0 is our default color, so new colors start at
|
|
|
|
1. */
|
|
|
|
int next = color_pair_map.size () + 1;
|
|
|
|
/* Curses has a limited number of available color pairs. Fall
|
|
|
|
back to the default if we've used too many. */
|
|
|
|
if (next >= COLOR_PAIRS)
|
|
|
|
return 0;
|
|
|
|
init_pair (next, fg, bg);
|
|
|
|
color_pair_map[c] = next;
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
Improve/fix the TUI's current source line highlight
With styling enabled, I think the way we display the TUI's
highlighted/current line is very ugly and distracting. The problem in
my view is that we reverse foreground/background in colored text as
well, leading to rainbow of background colors.
This patch changes that to something that I find much more sensible --
only reverse the default foreground/background colors, leave styled
text colors alone. If the foreground color is not the default
(because the text was styled), leave the foreground color as is. If
e.g., the terminal is fg=BLACK, and bg=WHITE, and the style wants to
print text in RED, reverse the background color (print in BLACK), but
still print the text in RED.
Note: The new ui_file_style::set_fg method isn't called set_foreground
instead, because set_foreground is a macro in /usr/lib/term.h (ncurses).
gdb/ChangeLog:
2019-03-18 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
New globals.
(apply_style): New, factored out from ...
(apply_ansi_escape): ... this. Handle reverse video mode.
(tui_set_reverse_mode): New function.
* tui/tui-io.h (tui_set_reverse_mode): New declaration.
* tui/tui-winsource.c (tui_show_source_line): Use
tui_set_reverse_mode instead of setting A_STANDOUT.
* ui-style.h (struct ui_file_style) <set_reverse, set_fg, set_bg>:
New setter methods.
2019-03-18 15:26:00 +01:00
|
|
|
/* Apply STYLE to W. */
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
|
Improve/fix the TUI's current source line highlight
With styling enabled, I think the way we display the TUI's
highlighted/current line is very ugly and distracting. The problem in
my view is that we reverse foreground/background in colored text as
well, leading to rainbow of background colors.
This patch changes that to something that I find much more sensible --
only reverse the default foreground/background colors, leave styled
text colors alone. If the foreground color is not the default
(because the text was styled), leave the foreground color as is. If
e.g., the terminal is fg=BLACK, and bg=WHITE, and the style wants to
print text in RED, reverse the background color (print in BLACK), but
still print the text in RED.
Note: The new ui_file_style::set_fg method isn't called set_foreground
instead, because set_foreground is a macro in /usr/lib/term.h (ncurses).
gdb/ChangeLog:
2019-03-18 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
New globals.
(apply_style): New, factored out from ...
(apply_ansi_escape): ... this. Handle reverse video mode.
(tui_set_reverse_mode): New function.
* tui/tui-io.h (tui_set_reverse_mode): New declaration.
* tui/tui-winsource.c (tui_show_source_line): Use
tui_set_reverse_mode instead of setting A_STANDOUT.
* ui-style.h (struct ui_file_style) <set_reverse, set_fg, set_bg>:
New setter methods.
2019-03-18 15:26:00 +01:00
|
|
|
static void
|
|
|
|
apply_style (WINDOW *w, ui_file_style style)
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
{
|
|
|
|
/* Reset. */
|
|
|
|
wattron (w, A_NORMAL);
|
|
|
|
wattroff (w, A_BOLD);
|
|
|
|
wattroff (w, A_DIM);
|
|
|
|
wattroff (w, A_REVERSE);
|
|
|
|
if (last_color_pair != -1)
|
|
|
|
wattroff (w, COLOR_PAIR (last_color_pair));
|
|
|
|
wattron (w, COLOR_PAIR (0));
|
|
|
|
|
|
|
|
const ui_file_style::color &fg = style.get_foreground ();
|
|
|
|
const ui_file_style::color &bg = style.get_background ();
|
|
|
|
if (!fg.is_none () || !bg.is_none ())
|
|
|
|
{
|
|
|
|
int fgi, bgi;
|
|
|
|
if (get_color (fg, &fgi) && get_color (bg, &bgi))
|
|
|
|
{
|
2019-03-14 16:31:38 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
/* MS-Windows port of ncurses doesn't support implicit
|
|
|
|
default foreground and background colors, so we must
|
|
|
|
specify them explicitly when needed, using the colors we
|
|
|
|
saw at startup. */
|
|
|
|
if (fgi == -1)
|
|
|
|
fgi = ncurses_norm_attr & 15;
|
|
|
|
if (bgi == -1)
|
|
|
|
bgi = (ncurses_norm_attr >> 4) & 15;
|
|
|
|
#endif
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
int pair = get_color_pair (fgi, bgi);
|
|
|
|
if (last_color_pair != -1)
|
|
|
|
wattroff (w, COLOR_PAIR (last_color_pair));
|
|
|
|
wattron (w, COLOR_PAIR (pair));
|
|
|
|
last_color_pair = pair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (style.get_intensity ())
|
|
|
|
{
|
|
|
|
case ui_file_style::NORMAL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ui_file_style::BOLD:
|
|
|
|
wattron (w, A_BOLD);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ui_file_style::DIM:
|
|
|
|
wattron (w, A_DIM);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gdb_assert_not_reached ("invalid intensity");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style.is_reverse ())
|
|
|
|
wattron (w, A_REVERSE);
|
|
|
|
|
|
|
|
last_style = style;
|
Improve/fix the TUI's current source line highlight
With styling enabled, I think the way we display the TUI's
highlighted/current line is very ugly and distracting. The problem in
my view is that we reverse foreground/background in colored text as
well, leading to rainbow of background colors.
This patch changes that to something that I find much more sensible --
only reverse the default foreground/background colors, leave styled
text colors alone. If the foreground color is not the default
(because the text was styled), leave the foreground color as is. If
e.g., the terminal is fg=BLACK, and bg=WHITE, and the style wants to
print text in RED, reverse the background color (print in BLACK), but
still print the text in RED.
Note: The new ui_file_style::set_fg method isn't called set_foreground
instead, because set_foreground is a macro in /usr/lib/term.h (ncurses).
gdb/ChangeLog:
2019-03-18 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
New globals.
(apply_style): New, factored out from ...
(apply_ansi_escape): ... this. Handle reverse video mode.
(tui_set_reverse_mode): New function.
* tui/tui-io.h (tui_set_reverse_mode): New declaration.
* tui/tui-winsource.c (tui_show_source_line): Use
tui_set_reverse_mode instead of setting A_STANDOUT.
* ui-style.h (struct ui_file_style) <set_reverse, set_fg, set_bg>:
New setter methods.
2019-03-18 15:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply an ANSI escape sequence from BUF to W. BUF must start with
|
|
|
|
the ESC character. If BUF does not start with an ANSI escape,
|
|
|
|
return 0. Otherwise, apply the sequence if it is recognized, or
|
|
|
|
simply ignore it if not. In this case, the number of bytes read
|
|
|
|
from BUF is returned. */
|
|
|
|
|
|
|
|
static size_t
|
|
|
|
apply_ansi_escape (WINDOW *w, const char *buf)
|
|
|
|
{
|
|
|
|
ui_file_style style = last_style;
|
|
|
|
size_t n_read;
|
|
|
|
|
|
|
|
if (!style.parse (buf, &n_read))
|
|
|
|
return n_read;
|
|
|
|
|
|
|
|
if (reverse_mode_p)
|
|
|
|
{
|
|
|
|
/* We want to reverse _only_ the default foreground/background
|
|
|
|
colors. If the foreground color is not the default (because
|
|
|
|
the text was styled), we want to leave it as is. If e.g.,
|
|
|
|
the terminal is fg=BLACK, and bg=WHITE, and the style wants
|
|
|
|
to print text in RED, we want to reverse the background color
|
|
|
|
(print in BLACK), but still print the text in RED. To do
|
|
|
|
that, we enable the A_REVERSE attribute, and re-reverse the
|
|
|
|
parsed-style's fb/bg colors.
|
|
|
|
|
|
|
|
Notes on the approach:
|
|
|
|
|
|
|
|
- there's no portable way to know which colors the default
|
|
|
|
fb/bg colors map to.
|
|
|
|
|
|
|
|
- this approach does the right thing even if you change the
|
|
|
|
terminal colors while GDB is running -- the reversed
|
|
|
|
colors automatically adapt.
|
|
|
|
*/
|
|
|
|
if (!style.is_default ())
|
|
|
|
{
|
|
|
|
ui_file_style::color bg = style.get_background ();
|
|
|
|
ui_file_style::color fg = style.get_foreground ();
|
|
|
|
style.set_fg (bg);
|
|
|
|
style.set_bg (fg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable A_REVERSE. */
|
|
|
|
style.set_reverse (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_style (w, style);
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
return n_read;
|
|
|
|
}
|
|
|
|
|
Improve/fix the TUI's current source line highlight
With styling enabled, I think the way we display the TUI's
highlighted/current line is very ugly and distracting. The problem in
my view is that we reverse foreground/background in colored text as
well, leading to rainbow of background colors.
This patch changes that to something that I find much more sensible --
only reverse the default foreground/background colors, leave styled
text colors alone. If the foreground color is not the default
(because the text was styled), leave the foreground color as is. If
e.g., the terminal is fg=BLACK, and bg=WHITE, and the style wants to
print text in RED, reverse the background color (print in BLACK), but
still print the text in RED.
Note: The new ui_file_style::set_fg method isn't called set_foreground
instead, because set_foreground is a macro in /usr/lib/term.h (ncurses).
gdb/ChangeLog:
2019-03-18 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
New globals.
(apply_style): New, factored out from ...
(apply_ansi_escape): ... this. Handle reverse video mode.
(tui_set_reverse_mode): New function.
* tui/tui-io.h (tui_set_reverse_mode): New declaration.
* tui/tui-winsource.c (tui_show_source_line): Use
tui_set_reverse_mode instead of setting A_STANDOUT.
* ui-style.h (struct ui_file_style) <set_reverse, set_fg, set_bg>:
New setter methods.
2019-03-18 15:26:00 +01:00
|
|
|
/* See tui.io.h. */
|
|
|
|
|
|
|
|
void
|
|
|
|
tui_set_reverse_mode (WINDOW *w, bool reverse)
|
|
|
|
{
|
|
|
|
ui_file_style style = last_style;
|
|
|
|
|
|
|
|
reverse_mode_p = reverse;
|
|
|
|
style.set_reverse (reverse);
|
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
{
|
|
|
|
reverse_save_bg = style.get_background ();
|
|
|
|
reverse_save_fg = style.get_foreground ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
style.set_bg (reverse_save_bg);
|
|
|
|
style.set_fg (reverse_save_fg);
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_style (w, style);
|
|
|
|
}
|
|
|
|
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
/* Print LENGTH characters from the buffer pointed to by BUF to the
|
|
|
|
curses command window. The output is buffered. It is up to the
|
|
|
|
caller to refresh the screen if necessary. */
|
|
|
|
|
|
|
|
void
|
|
|
|
tui_write (const char *buf, size_t length)
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
{
|
|
|
|
/* We need this to be \0-terminated for the regexp matching. */
|
|
|
|
std::string copy (buf, length);
|
|
|
|
tui_puts (copy.c_str ());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-10-10 06:21:05 +02:00
|
|
|
tui_puts_internal (WINDOW *w, const char *string, int *height)
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
{
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
char c;
|
|
|
|
int prev_col = 0;
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
while ((c = *string++) != 0)
|
|
|
|
{
|
|
|
|
if (c == '\1' || c == '\2')
|
|
|
|
{
|
|
|
|
/* Ignore these, they are readline escape-marking
|
|
|
|
sequences. */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (c == '\033')
|
|
|
|
{
|
|
|
|
size_t bytes_read = apply_ansi_escape (w, string - 1);
|
|
|
|
if (bytes_read > 0)
|
|
|
|
{
|
|
|
|
string = string + bytes_read - 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
do_tui_putc (w, c);
|
|
|
|
|
|
|
|
if (height != nullptr)
|
|
|
|
{
|
|
|
|
int col = getcurx (w);
|
|
|
|
if (col <= prev_col)
|
|
|
|
++*height;
|
|
|
|
prev_col = col;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
2017-03-08 01:14:59 +01:00
|
|
|
update_cmdwin_start_line ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print a string in the curses command window. The output is
|
|
|
|
buffered. It is up to the caller to refresh the screen if
|
|
|
|
necessary. */
|
2015-02-04 12:27:28 +01:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2018-10-10 06:21:05 +02:00
|
|
|
tui_puts (const char *string, WINDOW *w)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2018-10-10 06:21:05 +02:00
|
|
|
if (w == nullptr)
|
|
|
|
w = TUI_CMD_WIN->generic.handle;
|
|
|
|
tui_puts_internal (w, string, nullptr);
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Readline callback.
|
|
|
|
Redisplay the command line with its prompt after readline has
|
|
|
|
changed the edited text. */
|
2002-08-31 14:02:14 +02:00
|
|
|
void
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_redisplay_readline (void)
|
|
|
|
{
|
|
|
|
int prev_col;
|
|
|
|
int height;
|
2016-06-28 22:25:49 +02:00
|
|
|
int col;
|
2001-07-21 21:56:54 +02:00
|
|
|
int c_pos;
|
|
|
|
int c_line;
|
|
|
|
int in;
|
|
|
|
WINDOW *w;
|
2015-10-13 20:40:50 +02:00
|
|
|
const char *prompt;
|
2001-07-21 21:56:54 +02:00
|
|
|
int start_line;
|
2002-09-13 22:06:56 +02:00
|
|
|
|
|
|
|
/* Detect when we temporarily left SingleKey and now the readline
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
edit buffer is empty, automatically restore the SingleKey
|
2012-11-10 14:12:18 +01:00
|
|
|
mode. The restore must only be done if the command has finished.
|
|
|
|
The command could call prompt_for_continue and we must not
|
|
|
|
restore SingleKey so that the prompt and normal keymap are used. */
|
|
|
|
if (tui_current_key_mode == TUI_ONE_COMMAND_MODE && rl_end == 0
|
2016-06-21 02:11:51 +02:00
|
|
|
&& !gdb_in_secondary_prompt_p (current_ui))
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
tui_set_key_mode (TUI_SINGLE_KEY_MODE);
|
2002-09-13 22:06:56 +02:00
|
|
|
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
if (tui_current_key_mode == TUI_SINGLE_KEY_MODE)
|
2002-08-31 14:02:14 +02:00
|
|
|
prompt = "";
|
|
|
|
else
|
2002-10-26 12:38:57 +02:00
|
|
|
prompt = tui_rl_saved_prompt;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
c_pos = -1;
|
|
|
|
c_line = -1;
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
w = TUI_CMD_WIN->generic.handle;
|
|
|
|
start_line = TUI_CMD_WIN->detail.command_info.start_line;
|
2001-07-21 21:56:54 +02:00
|
|
|
wmove (w, start_line, 0);
|
|
|
|
prev_col = 0;
|
|
|
|
height = 1;
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
if (prompt != nullptr)
|
2018-10-10 06:21:05 +02:00
|
|
|
tui_puts_internal (TUI_CMD_WIN->generic.handle, prompt, &height);
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
|
|
|
|
prev_col = getcurx (w);
|
2015-01-09 19:27:56 +01:00
|
|
|
for (in = 0; in <= rl_end; in++)
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
if (in == rl_point)
|
|
|
|
{
|
|
|
|
getyx (w, c_line, c_pos);
|
|
|
|
}
|
|
|
|
|
2015-01-09 19:27:56 +01:00
|
|
|
if (in == rl_end)
|
|
|
|
break;
|
|
|
|
|
|
|
|
c = (unsigned char) rl_line_buffer[in];
|
2001-07-21 21:56:54 +02:00
|
|
|
if (CTRL_CHAR (c) || c == RUBOUT)
|
|
|
|
{
|
|
|
|
waddch (w, '^');
|
|
|
|
waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?');
|
|
|
|
}
|
2015-01-31 09:47:14 +01:00
|
|
|
else if (c == '\t')
|
|
|
|
{
|
|
|
|
/* Expand TABs, since ncurses on MS-Windows doesn't. */
|
2016-06-28 22:25:49 +02:00
|
|
|
col = getcurx (w);
|
2015-01-31 09:47:14 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
waddch (w, ' ');
|
|
|
|
col++;
|
|
|
|
} while ((col % 8) != 0);
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
else
|
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
waddch (w, c);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
if (c == '\n')
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
|
2016-06-28 22:25:49 +02:00
|
|
|
col = getcurx (w);
|
2001-07-21 21:56:54 +02:00
|
|
|
if (col < prev_col)
|
|
|
|
height++;
|
|
|
|
prev_col = col;
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
wclrtobot (w);
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
|
2001-07-21 21:56:54 +02:00
|
|
|
if (c_line >= 0)
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
wmove (w, c_line, c_pos);
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
wrefresh (w);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Readline callback to prepare the terminal. It is called once each
|
|
|
|
time we enter readline. Terminal is already setup in curses
|
|
|
|
mode. */
|
2001-07-21 21:56:54 +02:00
|
|
|
static void
|
2003-02-12 16:14:36 +01:00
|
|
|
tui_prep_terminal (int notused1)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2002-10-26 12:38:57 +02:00
|
|
|
/* Save the prompt registered in readline to correctly display it.
|
|
|
|
(we can't use gdb_prompt() due to secondary prompts and can't use
|
|
|
|
rl_prompt because it points to an alloca buffer). */
|
|
|
|
xfree (tui_rl_saved_prompt);
|
Fix pagination crash when the TUI is active
The TUI currently crashes when the user types <return> in response to
a pagination prompt:
$ gdb --tui ...
*the TUI is now active*
(gdb) set height 2
(gdb) help
List of classes of commands:
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 movdqu (%rax), %xmm12
(top-gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x000000000086be5f in xstrdup (s=0x0) at ../src/libiberty/xstrdup.c:33
#2 0x00000000005163f9 in tui_prep_terminal (notused1=1) at ../src/gdb/tui/tui-io.c:296
#3 0x000000000077a7ee in _rl_callback_newline () at ../src/readline/callback.c:82
#4 0x000000000077a853 in rl_callback_handler_install (prompt=0x0, linefunc=0x618b60 <command_line_handler>) at ../src/readline/callback.c:102
#5 0x0000000000718a5c in gdb_readline_wrapper_cleanup (arg=0xfd14d0) at ../src/gdb/top.c:788
#6 0x0000000000596d08 in do_my_cleanups (pmy_chain=0xcf0b38 <cleanup_chain>, old_chain=0x1043d10) at ../src/gdb/cleanups.c:155
#7 0x0000000000596d75 in do_cleanups (old_chain=0x1043d10) at ../src/gdb/cleanups.c:177
#8 0x0000000000718bd9 in gdb_readline_wrapper (prompt=0x7fffffffcfa0 "---Type <return> to continue, or q <return> to quit---")
at ../src/gdb/top.c:835
#9 0x000000000071cf74 in prompt_for_continue () at ../src/gdb/utils.c:1894
#10 0x000000000071d434 in fputs_maybe_filtered (linebuffer=0x1043db0 "List of classes of commands:\n\n", stream=0xf72e20, filter=1)
at ../src/gdb/utils.c:2111
#11 0x000000000071da0f in vfprintf_maybe_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118, filter=1)
at ../src/gdb/utils.c:2339
#12 0x000000000071da4a in vfprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118)
at ../src/gdb/utils.c:2347
#13 0x000000000071dc72 in fprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n") at ../src/gdb/utils.c:2399
#14 0x00000000004f90ab in help_list (list=0xe6d100, cmdtype=0x89ad8c "", class=all_classes, stream=0xf72e20)
at ../src/gdb/cli/cli-decode.c:1038
#15 0x00000000004f8dba in help_cmd (arg=0x0, stream=0xf72e20) at ../src/gdb/cli/cli-decode.c:946
Git 0017922 added:
@@ -776,6 +777,12 @@ gdb_readline_wrapper_cleanup (void *arg)
gdb_assert (input_handler == gdb_readline_wrapper_line);
input_handler = cleanup->handler_orig;
+
+ /* Reinstall INPUT_HANDLER in readline, without displaying a
+ prompt. */
+ if (async_command_editing_p)
+ rl_callback_handler_install (NULL, input_handler);
and tui_prep_terminal simply misses handling the case of a NULL
rl_prompt.
I also checked that readline's sources do similar checks.
gdb/
2014-07-24 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (tui_prep_terminal): Handle NULL rl_prompt.
2014-07-24 16:51:21 +02:00
|
|
|
tui_rl_saved_prompt = rl_prompt != NULL ? xstrdup (rl_prompt) : NULL;
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Readline callback to restore the terminal. It is called once each
|
|
|
|
time we leave readline. There is nothing to do in curses mode. */
|
2001-07-21 21:56:54 +02:00
|
|
|
static void
|
|
|
|
tui_deprep_terminal (void)
|
|
|
|
{
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Read readline output pipe and feed the command window with it.
|
|
|
|
Should be removed when readline is clean. */
|
|
|
|
static void
|
2010-05-25 17:48:44 +02:00
|
|
|
tui_readline_output (int error, gdb_client_data data)
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
|
|
|
int size;
|
|
|
|
char buf[256];
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
size = read (tui_readline_pipe[0], buf, sizeof (buf) - 1);
|
|
|
|
if (size > 0 && tui_active)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
buf[size] = 0;
|
|
|
|
tui_puts (buf);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
2002-09-03 22:47:48 +02:00
|
|
|
#endif
|
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.crlf. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
static void
|
|
|
|
tui_mld_crlf (const struct match_list_displayer *displayer)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
tui_putc ('\n');
|
2002-09-03 22:47:48 +02:00
|
|
|
}
|
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.putch. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
static void
|
|
|
|
tui_mld_putch (const struct match_list_displayer *displayer, int ch)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
tui_putc (ch);
|
2002-09-03 22:47:48 +02:00
|
|
|
}
|
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.puts. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tui_mld_puts (const struct match_list_displayer *displayer, const char *s)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
tui_puts (s);
|
|
|
|
}
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.flush. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tui_mld_flush (const struct match_list_displayer *displayer)
|
|
|
|
{
|
|
|
|
wrefresh (TUI_CMD_WIN->generic.handle);
|
2002-09-03 22:47:48 +02:00
|
|
|
}
|
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.erase_entire_line. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
|
|
|
static void
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
tui_mld_erase_entire_line (const struct match_list_displayer *displayer)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
WINDOW *w = TUI_CMD_WIN->generic.handle;
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
int cur_y = getcury (w);
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
wmove (w, cur_y, 0);
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
wclrtoeol (w);
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
wmove (w, cur_y, 0);
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
}
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.beep. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
static void
|
|
|
|
tui_mld_beep (const struct match_list_displayer *displayer)
|
|
|
|
{
|
|
|
|
beep ();
|
|
|
|
}
|
|
|
|
|
2018-09-03 23:23:48 +02:00
|
|
|
/* A wrapper for wgetch that enters nonl mode. We We normally want
|
|
|
|
curses' "nl" mode, but when reading from the user, we'd like to
|
|
|
|
differentiate between C-j and C-m, because some users bind these
|
|
|
|
keys differently in their .inputrc. So, put curses into nonl mode
|
|
|
|
just when reading from the user. See PR tui/20819. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdb_wgetch (WINDOW *win)
|
|
|
|
{
|
|
|
|
nonl ();
|
|
|
|
int r = wgetch (win);
|
|
|
|
nl ();
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* Helper function for tui_mld_read_key.
|
|
|
|
This temporarily replaces tui_getc for use during tab-completion
|
|
|
|
match list display. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tui_mld_getc (FILE *fp)
|
|
|
|
{
|
|
|
|
WINDOW *w = TUI_CMD_WIN->generic.handle;
|
2018-09-03 23:23:48 +02:00
|
|
|
int c = gdb_wgetch (w);
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
return c;
|
|
|
|
}
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of displayer.read_key. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
static int
|
|
|
|
tui_mld_read_key (const struct match_list_displayer *displayer)
|
|
|
|
{
|
|
|
|
rl_getc_func_t *prev = rl_getc_function;
|
|
|
|
int c;
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* We can't use tui_getc as we need NEWLINE to not get emitted. */
|
|
|
|
rl_getc_function = tui_mld_getc;
|
|
|
|
c = rl_read_key ();
|
|
|
|
rl_getc_function = prev;
|
|
|
|
return c;
|
|
|
|
}
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
/* TUI version of rl_completion_display_matches_hook.
|
|
|
|
See gdb_display_match_list for a description of the arguments. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
Unify CLI/TUI interface to readline tab completion.
This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.
gdb/ChangeLog:
* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion. All callers
updated.
2015-01-31 23:11:54 +01:00
|
|
|
static void
|
|
|
|
tui_rl_display_match_list (char **matches, int len, int max)
|
|
|
|
{
|
|
|
|
struct match_list_displayer displayer;
|
|
|
|
|
|
|
|
rl_get_screen_size (&displayer.height, &displayer.width);
|
|
|
|
displayer.crlf = tui_mld_crlf;
|
|
|
|
displayer.putch = tui_mld_putch;
|
|
|
|
displayer.puts = tui_mld_puts;
|
|
|
|
displayer.flush = tui_mld_flush;
|
|
|
|
displayer.erase_entire_line = tui_mld_erase_entire_line;
|
|
|
|
displayer.beep = tui_mld_beep;
|
|
|
|
displayer.read_key = tui_mld_read_key;
|
|
|
|
|
|
|
|
gdb_display_match_list (matches, len, max, &displayer);
|
2002-09-03 22:47:48 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Setup the IO for curses or non-curses mode.
|
|
|
|
- In non-curses mode, readline and gdb use the standard input and
|
|
|
|
standard output/error directly.
|
|
|
|
- In curses mode, the standard output/error is controlled by TUI
|
|
|
|
with the tui_stdout and tui_stderr. The output is redirected in
|
|
|
|
the curses command window. Several readline callbacks are installed
|
|
|
|
so that readline asks for its input to the curses command window
|
|
|
|
with wgetch(). */
|
|
|
|
void
|
|
|
|
tui_setup_io (int mode)
|
|
|
|
{
|
2011-05-12 01:38:44 +02:00
|
|
|
extern int _rl_echoing_p;
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
if (mode)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Redirect readline to TUI. */
|
|
|
|
tui_old_rl_redisplay_function = rl_redisplay_function;
|
|
|
|
tui_old_rl_deprep_terminal = rl_deprep_term_function;
|
|
|
|
tui_old_rl_prep_terminal = rl_prep_term_function;
|
|
|
|
tui_old_rl_getc_function = rl_getc_function;
|
2015-02-01 00:07:22 +01:00
|
|
|
tui_old_rl_display_matches_hook = rl_completion_display_matches_hook;
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_old_rl_outstream = rl_outstream;
|
2011-05-12 01:38:44 +02:00
|
|
|
tui_old_rl_echoing_p = _rl_echoing_p;
|
2001-07-21 21:56:54 +02:00
|
|
|
rl_redisplay_function = tui_redisplay_readline;
|
|
|
|
rl_deprep_term_function = tui_deprep_terminal;
|
|
|
|
rl_prep_term_function = tui_prep_terminal;
|
|
|
|
rl_getc_function = tui_getc;
|
2011-05-12 01:38:44 +02:00
|
|
|
_rl_echoing_p = 0;
|
2001-07-21 21:56:54 +02:00
|
|
|
rl_outstream = tui_rl_outstream;
|
|
|
|
rl_prompt = 0;
|
2002-09-03 22:47:48 +02:00
|
|
|
rl_completion_display_matches_hook = tui_rl_display_match_list;
|
|
|
|
rl_already_prompted = 0;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Keep track of previous gdb output. */
|
|
|
|
tui_old_stdout = gdb_stdout;
|
|
|
|
tui_old_stderr = gdb_stderr;
|
Class-ify ui_out
This patch finalizes the C++ conversion of the ui-out subsystem, by
turning the ui_out and ui_out_impl structures into a single class
hierarchy. ui_out functions are turned into virtual methods of that new
class, so as a result there are a lot of call sites to update.
In the previous version of the patchset, there were separate ui_out and
ui_out_impl classes, but it wasn't really useful and added boilerplate.
In this version there is simply an ui_out base class that is
extended for CLI, TUI and MI.
It's a bit hard to maintain a ChangeLog for such a big patch, I did my
best but I'm sure there are some missing or outdated info in there...
gdb/ChangeLog:
* ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header,
ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int,
ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream,
ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text,
ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags,
ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect):
Remove, replace with a method in class ui_out.
(table_begin_ftype): Remove, replace with pure virtual method in
class ui_out.
(table_body_ftype): Likewise.
(table_end_ftype): Likewise.
(table_header_ftype): Likewise.
(ui_out_begin_ftype): Likewise.
(ui_out_end_ftype): Likewise.
(field_int_ftype): Likewise.
(field_skip_ftype): Likewise.
(field_string_ftype): Likewise.
(field_fmt_ftype): Likewise.
(spaces_ftype): Likewise.
(text_ftype): Likewise.
(message_ftype): Likewise.
(wrap_hint_ftype): Likewise.
(flush_ftype): Likewise.
(redirect_ftype): Likewise.
(data_destroy_ftype): Likewise.
(struct ui_out_impl): Remove, replace with class ui_out.
(ui_out_new): Remove.
(class ui_out): New class.
* ui-out.c (struct ui_out): Remove, replaced with class ui_out.
(current_level): Remove, replace with ui_out method.
(push_level): Likewise.
(pop_level): Likewise.
(uo_table_begin, uo_table_body, uo_table_end, uo_table_header,
uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt,
uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush,
uo_redirect, uo_field_string): Remove.
(ui_out_table_begin): Replace with ...
(ui_out::table_begin): ... this.
(ui_out_table_body): Replace with ...
(ui_out::table_body): ... this.
(ui_out_table_end): Replace with ...
(ui_out::table_end): ... this.
(ui_out_table_header): Replace with ...
(ui_out::table_header): ... this.
(ui_out_begin): Replace with ...
(ui_out::begin): ... this.
(ui_out_end): Replace with ...
(ui_out::end): ... this.
(ui_out_field_int): Replace with ...
(ui_out::field_int): ... this.
(ui_out_field_fmt_int): Replace with ...
(ui_out::field_fmt_int): ... this.
(ui_out_field_core_addr): Replace with ...
(ui_out::field_core_addr): ... this.
(ui_out_field_stream): Replace with ...
(ui_out::field_stream): ... this.
(ui_out_field_skip): Replace with ...
(ui_out::field_skip): ... this.
(ui_out_field_string): Replace with ...
(ui_out::field_string): ... this.
(ui_out_field_fmt): Replace with ...
(ui_out::field_fmt): ... this.
(ui_out_spaces): Replace with ...
(ui_out::spaces): ... this.
(ui_out_text): Replace with ...
(ui_out::text): ... this.
(ui_out_message): Replace with ...
(ui_out::message): ... this.
(ui_out_wrap_hint): Replace with ...
(ui_out::wrap_hint): ... this.
(ui_out_flush): Replace with ...
(ui_out::flush): ... this.
(ui_out_redirect): Replace with ...
(ui_out::redirect): ... this.
(ui_out_test_flags): Replace with ...
(ui_out::test_flags): ... this.
(ui_out_is_mi_like_p): Replace with ...
(ui_out::is_mi_like_p): ... this.
(verify_field): Replace with ...
(ui_out::verify_field): ... this.
(ui_out_query_field): Replace with ...
(ui_out::query_table_field): ... this.
(ui_out_data): Remove.
(ui_out_new): Remove, replace with ...
(ui_out::ui_out): ... this constructor.
(do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end,
do_cleanup_end, make_cleanup_ui_out_tuple_begin_end,
make_cleanup_ui_out_list_begin_end): Update fallouts of struct
ui_out -> class ui_out change.
* cli-out.c (cli_out_data): Remove.
(cli_uiout_dtor): Remove.
(cli_table_begin): Replace with ...
(cli_ui_out::do_table_begin): ... this new method.
(cli_table_body): Replace with ...
(cli_ui_out::do_table_body): ... this new method.
(cli_table_end): Replace with ...
(cli_ui_out::do_table_end): ... this new method.
(cli_table_header): Replace with ...
(cli_ui_out::do_table_header): ... this new method.
(cli_begin): Replace with ...
(cli_ui_out::do_begin): ... this new method.
(cli_end): Replace with ...
(cli_ui_out::do_end): ... this new method.
(cli_field_int): Replace with ...
(cli_ui_out::do_field_int): ... this new method.
(cli_field_skip): Replace with ...
(cli_ui_out::do_field_skip): ... this new method.
(cli_field_string): Replace with ...
(cli_ui_out::do_field_string): ... this new method.
(cli_field_fmt): Replace with ...
(cli_ui_out::do_field_fmt): ... this new method.
(cli_spaces): Replace with ...
(cli_ui_out::do_spaces): ... this new method.
(cli_text): Replace with ...
(cli_ui_out::do_text): ... this new method.
(cli_message): Replace with ...
(cli_ui_out::do_message): ... this new method.
(cli_wrap_hint): Replace with ...
(cli_ui_out::do_wrap_hint): ... this new method.
(cli_flush): Replace with ...
(cli_ui_out::do_flush): ... this new method.
(cli_redirect): Replace with ...
(cli_ui_out::do_redirect): ... this new method.
(out_field_fmt): Replace with ...
(cli_ui_out::out_field_fmt): ... this new method.
(field_separator): Replace with ...
(cli_ui_out::field_separator): ... this new method.
(cli_out_set_stream): Replace with ...
(cli_ui_out::set_stream): ... this new method.
(cli_ui_out_impl): Remove.
(cli_out_data_ctor): Remove.
(cli_ui_out_impl::cli_ui_out_impl): New constructor.
(cli_ui_out_impl::~cli_ui_out_impl): New destructor.
(cli_out_new): Change return type to cli_ui_out *, instantiate a
cli_ui_out.
* cli-out.h (cli_ui_out_data): Remove, replace with class
cli_ui_out.
(class cli_ui_out): New class.
(cli_ui_out_impl): Remove.
(cli_out_data_ctor): Remove.
(cli_out_new): Change return type to cli_ui_out*.
(cli_out_set_stream): Remove.
* cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type
to cli_ui_out*.
(cli_interpreter_resume): Adapt.
(cli_interpreter_exec): Adapt.
* mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove.
(mi_ui_out_impl): Remove.
(mi_table_begin): Replace with ...
(mi_ui_out::do_table_begin): ... this.
(mi_table_body): Replace with ...
(mi_ui_out::do_table_body): ... this.
(mi_table_end): Replace with ...
(mi_ui_out::do_table_end): ... this.
(mi_table_header): Replace with ...
(mi_ui_out::do_table_header): ... this.
(mi_begin): Replace with ...
(mi_ui_out::do_begin): ... this.
(mi_end): Replace with ...
(mi_ui_out::do_end): ... this.
(mi_field_int): Replace with ...
(mi_ui_out::do_field_int): ... this.
(mi_field_skip): Replace with ...
(mi_ui_out::do_field_skip): ... this.
(mi_field_string): Replace with ...
(mi_ui_out::do_field_string): ... this.
(mi_field_fmt): Replace with ...
(mi_ui_out::do_field_fmt): ... this.
(mi_spaces): Replace with ...
(mi_ui_out::do_spaces): ... this.
(mi_text): Replace with ...
(mi_ui_out::do_text): ... this.
(mi_message): Replace with ...
(mi_ui_out::do_message): ... this.
(mi_wrap_hint): Replace with ...
(mi_ui_out::do_wrap_hint): ... this.
(mi_flush): Replace with ...
(mi_ui_out::do_flush): ... this.
(mi_redirect): Replace with ...
(mi_ui_out::do_redirect):
(field_separator): Replace with ...
(mi_ui_out::field_separator):
(mi_open): Replace with ...
(mi_ui_out::open): ... this.
(mi_close): Replace with ...
(mi_ui_out::close): ... this.
(mi_out_rewind): Replace with ...
(mi_ui_out::rewind): ... this.
(mi_out_put): Replace with ...
(mi_ui_out::put): ... this.
(mi_version): Replace with ...
(mi_ui_out::version): ... this.
(mi_out_data_ctor): Replace with ...
(mi_ui_out::mi_ui_out): ... this.
(mi_out_data_dtor): Replace with ...
(mi_ui_out::~mi_ui_out): ... this.
(mi_out_new): Change return type to mi_ui_out*, instantiate
an mi_ui_out object.
(as_mi_ui_out): New function.
(mi_version): Update fallouts of struct ui_out to class ui_out
transition.
(mi_out_put): Likewise.
(mi_out_rewind): Likewise.
* mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*.
* tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl):
Remove.
(tui_field_int): Replace with ...
(tui_ui_out::do_field_int): ... this.
(tui_field_string): Replace with ...
(tui_ui_out::do_field_string): ... this.
(tui_field_fmt): Replace with ...
(tui_ui_out::do_field_fmt): ... this.
(tui_text): Replace with ...
(tui_ui_out::do_text): ... this.
(tui_out_new): Change return type to tui_ui_out*, instantiate
tui_ui_out object.
(tui_ui_out::tui_ui_out): New.
* tui/tui-out.h: New file.
* tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h.
* tui/tui-io.c: Include tui/tui-out.h.
(tui_old_uiout): Change type to cli_ui_out*.
(tui_setup_io): Use dynamic_cast.
* tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*.
* tui/tui-interp.c (tui_resume): Adapt.
* ada-lang.c (print_it_exception): Update fallouts of struct
ui_out to class ui_out transition.
(print_one_exception): Likewise.
(print_mention_exception): Likewise.
* ada-tasks.c (print_ada_task_info): Likewise.
(info_task): Likewise.
(task_command): Likewise.
* auto-load.c (print_script): Likewise.
(auto_load_info_scripts): Likewise.
(info_auto_load_cmd): Likewise.
* break-catch-sig.c (signal_catchpoint_print_one): Likewise.
* break-catch-syscall.c (print_it_catch_syscall): Likewise.
(print_one_catch_syscall): Likewise.
* break-catch-throw.c (print_it_exception_catchpoint): Likewise.
(print_one_exception_catchpoint): Likewise.
(print_one_detail_exception_catchpoint): Likewise.
(print_mention_exception_catchpoint): Likewise.
* breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise.
(print_solib_event): Likewise.
(watchpoint_check): Likewise.
(wrap_indent_at_field): Likewise.
(print_breakpoint_location): Likewise.
(output_thread_groups): Likewise.
(print_one_breakpoint_location): Likewise.
(breakpoint_1): Likewise.
(default_collect_info): Likewise.
(watchpoints_info): Likewise.
(print_it_catch_fork): Likewise.
(print_one_catch_fork): Likewise.
(print_it_catch_vfork): Likewise.
(print_one_catch_vfork): Likewise.
(print_it_catch_solib): Likewise.
(print_one_catch_solib): Likewise.
(print_it_catch_exec): Likewise.
(print_one_catch_exec): Likewise.
(mention): Likewise.
(print_it_ranged_breakpoint): Likewise.
(print_one_ranged_breakpoint): Likewise.
(print_one_detail_ranged_breakpoint): Likewise.
(print_mention_ranged_breakpoint): Likewise.
(print_it_watchpoint): Likewise.
(print_mention_watchpoint): Likewise.
(print_it_masked_watchpoint): Likewise.
(print_one_detail_masked_watchpoint): Likewise.
(print_mention_masked_watchpoint): Likewise.
(bkpt_print_it): Likewise.
(tracepoint_print_one_detail): Likewise.
(tracepoint_print_mention): Likewise.
(update_static_tracepoint): Likewise.
(tracepoints_info): Likewise.
(save_breakpoints): Likewise.
* cli/cli-cmds.c (complete_command): Likewise.
* cli/cli-logging.c (set_logging_redirect): Likewise.
(pop_output_files): Likewise.
(handle_redirections): Likewise.
* cli/cli-script.c (print_command_lines): Likewise.
* cli/cli-setshow.c (do_show_command): Likewise.
(cmd_show_list): Likewise.
* cp-abi.c (list_cp_abis): Likewise.
(show_cp_abi_cmd): Likewise.
* darwin-nat-info.c (darwin_debug_regions_recurse): Likewise.
* disasm.c (gdb_pretty_print_insn): Likewise.
(do_mixed_source_and_assembly_deprecated): Likewise.
(do_mixed_source_and_assembly): Likewise.
* gdb_bfd.c (print_one_bfd): Likewise.
(maintenance_info_bfds): Likewise.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise.
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise.
* i386-tdep.c (i386_mpx_print_bounds): Likewise.
* infcmd.c (run_command_1): Likewise.
(print_return_value_1): Likewise.
* inferior.c (print_selected_inferior): Likewise.
(print_inferior): Likewise.
* infrun.c (print_end_stepping_range_reason): Likewise.
(print_signal_exited_reason): Likewise.
(print_exited_reason): Likewise.
(print_signal_received_reason): Likewise.
(print_no_history_reason): Likewise.
* interps.c (interp_set): Likewise.
* linespec.c (decode_line_full): Likewise.
* linux-thread-db.c (info_auto_load_libthread_db): Likewise.
* mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
(mi_cmd_env_path): Likewise.
(mi_cmd_env_dir): Likewise.
(mi_cmd_inferior_tty_show): Likewise.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise.
(print_partial_file_name): Likewise.
(mi_cmd_file_list_exec_source_files): Likewise.
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise.
(mi_cmd_info_gdb_mi_command): Likewise.
* mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise.
(mi_cmd_stack_list_args): Likewise.
(list_arg_or_local): Likewise.
* mi/mi-cmd-var.c (print_varobj): Likewise.
(mi_cmd_var_create): Likewise.
(mi_cmd_var_delete): Likewise.
(mi_cmd_var_set_format): Likewise.
(mi_cmd_var_show_format): Likewise.
(mi_cmd_var_info_num_children): Likewise.
(mi_cmd_var_list_children): Likewise.
(mi_cmd_var_info_type): Likewise.
(mi_cmd_var_info_path_expression): Likewise.
(mi_cmd_var_info_expression): Likewise.
(mi_cmd_var_show_attributes): Likewise.
(mi_cmd_var_evaluate_expression): Likewise.
(mi_cmd_var_assign): Likewise.
(varobj_update_one): Likewise.
* mi/mi-interp.c (as_mi_interp): Likewise.
(mi_on_normal_stop_1): Likewise.
(mi_tsv_modified): Likewise.
(mi_breakpoint_created): Likewise.
(mi_breakpoint_modified): Likewise.
(mi_solib_loaded): Likewise.
(mi_solib_unloaded): Likewise.
(mi_command_param_changed): Likewise.
(mi_memory_changed): Likewise.
(mi_user_selected_context_changed): Likewise.
* mi/mi-main.c (print_one_inferior): Likewise.
(output_cores): Likewise.
(list_available_thread_groups): Likewise.
(mi_cmd_data_list_register_names): Likewise.
(mi_cmd_data_list_changed_registers): Likewise.
(output_register): Likewise.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Likewise.
(mi_cmd_data_read_memory_bytes): Likewise.
(mi_cmd_list_features): Likewise.
(mi_cmd_list_target_features): Likewise.
(mi_cmd_add_inferior): Likewise.
(mi_execute_command): Likewise.
(mi_load_progress): Likewise.
(print_variable_or_computed): Likewise.
(mi_cmd_trace_frame_collected): Likewise.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise.
* osdata.c (info_osdata_command): Likewise.
* probe.c (gen_ui_out_table_header_info): Likewise.
(print_ui_out_not_applicables): Likewise.
(print_ui_out_info): Likewise.
(info_probes_for_ops): Likewise.
(enable_probes_command): Likewise.
(disable_probes_command): Likewise.
* progspace.c (print_program_space): Likewise.
* python/py-breakpoint.c (bppy_get_commands): Likewise.
* python/py-framefilter.c (py_print_type): Likewise.
(py_print_value): Likewise.
(py_print_single_arg): Likewise.
(enumerate_args): Likewise.
(enumerate_locals): Likewise.
(py_print_args): Likewise.
(py_print_frame): Likewise.
* record-btrace.c (btrace_ui_out_decode_error): Likewise.
(btrace_call_history_insn_range): Likewise.
(btrace_call_history_src_line): Likewise.
(btrace_call_history): Likewise.
* remote.c (show_remote_cmd): Likewise.
* skip.c (skip_info): Likewise.
* solib.c (info_sharedlibrary_command): Likewise.
* source.c (print_source_lines_base): Likewise.
* spu-tdep.c (info_spu_event_command): Likewise.
(info_spu_signal_command): Likewise.
(info_spu_mailbox_list): Likewise.
(info_spu_dma_cmdlist): Likewise.
(info_spu_dma_command): Likewise.
(info_spu_proxydma_command): Likewise.
* stack.c (print_stack_frame): Likewise.
(print_frame_arg): Likewise.
(read_frame_arg): Likewise.
(print_frame_args): Likewise.
(print_frame_info): Likewise.
(print_frame): Likewise.
* symfile.c (load_progress): Likewise.
(generic_load): Likewise.
(print_transfer_performance): Likewise.
* thread.c (do_captured_list_thread_ids): Likewise.
(print_thread_info_1): Likewise.
(restore_selected_frame): Likewise.
(do_captured_thread_select): Likewise.
(print_selected_thread_frame): Likewise.
* top.c (execute_command_to_string): Likewise.
* tracepoint.c (tvariables_info_1): Likewise.
(trace_status_mi): Likewise.
(tfind_1): Likewise.
(print_one_static_tracepoint_marker): Likewise.
(info_static_tracepoint_markers_command): Likewise.
* utils.c (do_ui_out_redirect_pop): Likewise.
(fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
|
|
|
tui_old_uiout = dynamic_cast<cli_ui_out *> (current_uiout);
|
|
|
|
gdb_assert (tui_old_uiout != nullptr);
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Reconfigure gdb output. */
|
|
|
|
gdb_stdout = tui_stdout;
|
|
|
|
gdb_stderr = tui_stderr;
|
|
|
|
gdb_stdlog = gdb_stdout; /* for moment */
|
|
|
|
gdb_stdtarg = gdb_stderr; /* for moment */
|
2010-09-11 18:00:27 +02:00
|
|
|
gdb_stdtargerr = gdb_stderr; /* for moment */
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
|
|
|
current_uiout = tui_out;
|
2001-07-22 00:35:40 +02:00
|
|
|
|
|
|
|
/* Save tty for SIGCONT. */
|
|
|
|
savetty ();
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
else
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Restore gdb output. */
|
|
|
|
gdb_stdout = tui_old_stdout;
|
|
|
|
gdb_stderr = tui_old_stderr;
|
|
|
|
gdb_stdlog = gdb_stdout; /* for moment */
|
|
|
|
gdb_stdtarg = gdb_stderr; /* for moment */
|
2010-09-11 18:00:27 +02:00
|
|
|
gdb_stdtargerr = gdb_stderr; /* for moment */
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
|
|
|
current_uiout = tui_old_uiout;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Restore readline. */
|
|
|
|
rl_redisplay_function = tui_old_rl_redisplay_function;
|
|
|
|
rl_deprep_term_function = tui_old_rl_deprep_terminal;
|
|
|
|
rl_prep_term_function = tui_old_rl_prep_terminal;
|
|
|
|
rl_getc_function = tui_old_rl_getc_function;
|
2015-02-01 00:07:22 +01:00
|
|
|
rl_completion_display_matches_hook = tui_old_rl_display_matches_hook;
|
2001-07-21 21:56:54 +02:00
|
|
|
rl_outstream = tui_old_rl_outstream;
|
2011-05-12 01:38:44 +02:00
|
|
|
_rl_echoing_p = tui_old_rl_echoing_p;
|
2002-09-13 21:47:21 +02:00
|
|
|
rl_already_prompted = 0;
|
2001-07-22 00:35:40 +02:00
|
|
|
|
|
|
|
/* Save tty for SIGCONT. */
|
|
|
|
savetty ();
|
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI. A simple way to see this is to try the
extended-prompt example from the gdb manual.
Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.
This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb. These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.
The curses approach to color handling is unusual and so there are some
oddities in the implementation.
Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color. ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.
Second, in curses, colors always come in pairs: you cannot set just
the foreground. This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.
Third, there are a limited number of such pairs available. In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.
Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors. This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.
I am very sour on the curses design now.
I do not know how to write a test for this, so I did not.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
PR tui/14126:
* tui/tui.c (tui_enable): Call start_color and
use_default_colors.
* tui/tui-io.c (struct color_pair): New.
(color_pair_map, last_color_pair, last_style): New globals.
(tui_setup_io): Clean up color map when shutting down.
(curses_colors): New constant.
(get_color_pair, apply_ansi_escape): New functions.
(tui_write): Rewrite.
(tui_puts_internal): New function, from tui_puts. Add "height"
parameter.
(tui_puts): Use tui_puts_internal.
(tui_redisplay_readline): Use tui_puts_internal.
(_initialize_tui_io): New function.
(color_map): New globals.
(get_color): New function.
* configure.ac: Check for use_default_colors.
* config.in, configure: Rebuild.
2018-09-03 20:42:59 +02:00
|
|
|
|
|
|
|
/* Clean up color information. */
|
|
|
|
last_color_pair = -1;
|
|
|
|
last_style = ui_file_style ();
|
|
|
|
color_map.clear ();
|
|
|
|
color_pair_map.clear ();
|
2001-07-22 00:35:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SIGCONT
|
|
|
|
/* Catch SIGCONT to restore the terminal and refresh the screen. */
|
|
|
|
static void
|
|
|
|
tui_cont_sig (int sig)
|
|
|
|
{
|
|
|
|
if (tui_active)
|
|
|
|
{
|
|
|
|
/* Restore the terminal setting because another process (shell)
|
|
|
|
might have changed it. */
|
|
|
|
resetty ();
|
|
|
|
|
|
|
|
/* Force a refresh of the screen. */
|
2004-02-07 02:02:54 +01:00
|
|
|
tui_refresh_all_win ();
|
2001-07-23 23:16:20 +02:00
|
|
|
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
wrefresh (TUI_CMD_WIN->generic.handle);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-22 00:35:40 +02:00
|
|
|
signal (sig, tui_cont_sig);
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
2001-07-22 00:35:40 +02:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Initialize the IO for gdb in curses mode. */
|
|
|
|
void
|
2004-02-08 02:32:26 +01:00
|
|
|
tui_initialize_io (void)
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
2001-07-22 00:35:40 +02:00
|
|
|
#ifdef SIGCONT
|
|
|
|
signal (SIGCONT, tui_cont_sig);
|
|
|
|
#endif
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Create tui output streams. */
|
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
|
|
|
tui_stdout = new tui_file (stdout);
|
|
|
|
tui_stderr = new tui_file (stderr);
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_out = tui_out_new (tui_stdout);
|
|
|
|
|
2013-09-06 12:12:20 +02:00
|
|
|
/* Create the default UI. */
|
2011-09-12 23:25:22 +02:00
|
|
|
tui_old_uiout = cli_out_new (gdb_stdout);
|
2001-07-21 21:56:54 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Temporary solution for readline writing to stdout: redirect
|
|
|
|
readline output in a pipe, read that pipe and output the content
|
|
|
|
in the curses command window. */
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
|
|
|
if (gdb_pipe_cloexec (tui_readline_pipe) != 0)
|
2014-08-04 15:03:21 +02:00
|
|
|
error (_("Cannot create pipe for readline"));
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_rl_outstream = fdopen (tui_readline_pipe[1], "w");
|
|
|
|
if (tui_rl_outstream == 0)
|
2014-08-04 15:03:21 +02:00
|
|
|
error (_("Cannot redirect readline output"));
|
|
|
|
|
2002-10-25 21:24:01 +02:00
|
|
|
setvbuf (tui_rl_outstream, (char*) NULL, _IOLBF, 0);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
#ifdef O_NONBLOCK
|
|
|
|
(void) fcntl (tui_readline_pipe[0], F_SETFL, O_NONBLOCK);
|
1999-04-16 03:35:26 +02:00
|
|
|
#else
|
2001-07-21 21:56:54 +02:00
|
|
|
#ifdef O_NDELAY
|
|
|
|
(void) fcntl (tui_readline_pipe[0], F_SETFL, O_NDELAY);
|
1999-04-16 03:35:26 +02:00
|
|
|
#endif
|
2001-07-21 21:56:54 +02:00
|
|
|
#endif
|
|
|
|
add_file_handler (tui_readline_pipe[0], tui_readline_output, 0);
|
2002-09-03 22:47:48 +02:00
|
|
|
#else
|
|
|
|
tui_rl_outstream = stdout;
|
|
|
|
#endif
|
2019-03-14 16:31:38 +01:00
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
/* MS-Windows port of ncurses doesn't support default foreground and
|
|
|
|
background colors, so we must record the default colors at startup. */
|
|
|
|
HANDLE hstdout = (HANDLE)_get_osfhandle (fileno (stdout));
|
|
|
|
DWORD cmode;
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
|
|
|
|
|
|
|
if (hstdout != INVALID_HANDLE_VALUE
|
|
|
|
&& GetConsoleMode (hstdout, &cmode) != 0
|
|
|
|
&& GetConsoleScreenBufferInfo (hstdout, &csbi))
|
|
|
|
ncurses_norm_attr = csbi.wAttributes;
|
|
|
|
#endif
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Get a character from the command window. This is called from the
|
|
|
|
readline package. */
|
2018-09-02 02:44:33 +02:00
|
|
|
static int
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_getc (FILE *fp)
|
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
WINDOW *w;
|
|
|
|
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
w = TUI_CMD_WIN->generic.handle;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Flush readline output. */
|
2010-05-25 17:48:44 +02:00
|
|
|
tui_readline_output (0, 0);
|
2002-09-03 22:47:48 +02:00
|
|
|
#endif
|
|
|
|
|
2018-09-03 23:23:48 +02:00
|
|
|
ch = gdb_wgetch (w);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* The \n must be echoed because it will not be printed by
|
|
|
|
readline. */
|
2019-03-18 19:04:40 +01:00
|
|
|
if (ch == '\n' || ch == '\r')
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
|
|
|
/* When hitting return with an empty input, gdb executes the last
|
|
|
|
command. If we emit a newline, this fills up the command window
|
|
|
|
with empty lines with gdb prompt at beginning. Instead of that,
|
|
|
|
stay on the same line but provide a visual effect to show the
|
|
|
|
user we recognized the command. */
|
2016-06-21 02:11:51 +02:00
|
|
|
if (rl_end == 0 && !gdb_in_secondary_prompt_p (current_ui))
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
wmove (w, getcury (w), 0);
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Clear the line. This will blink the gdb prompt since
|
|
|
|
it will be redrawn at the same line. */
|
|
|
|
wclrtoeol (w);
|
|
|
|
wrefresh (w);
|
|
|
|
napms (20);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-11 00:44:56 +01:00
|
|
|
/* Move cursor to the end of the command line before emitting the
|
|
|
|
newline. We need to do so because when ncurses outputs a newline
|
|
|
|
it truncates any text that appears past the end of the cursor. */
|
Remove fields curch and cur_line from TUI_CMD_WIN
These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.
So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).
In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.
Tested on x86_64 Fedora 22, no obvious regressions.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).
2015-08-19 03:08:57 +02:00
|
|
|
int px, py;
|
|
|
|
getyx (w, py, px);
|
2015-02-11 00:44:56 +01:00
|
|
|
px += rl_end - rl_point;
|
|
|
|
py += px / TUI_CMD_WIN->generic.width;
|
|
|
|
px %= TUI_CMD_WIN->generic.width;
|
|
|
|
wmove (w, py, px);
|
2015-08-21 18:04:25 +02:00
|
|
|
tui_putc ('\n');
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-17 14:06:10 +01:00
|
|
|
/* Handle prev/next/up/down here. */
|
|
|
|
ch = tui_dispatch_ctrl_char (ch);
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
if (ch == KEY_BACKSPACE)
|
|
|
|
return '\b';
|
2014-11-23 11:03:39 +01:00
|
|
|
|
Make command line editing (use of readline) be per UI
Due to the way that readline's API works (based on globals), we can
only have one instance of readline in a process. So the goal of this
patch is to only allow editing in the main UI, and make sure that only
one UI calls into readline. Some MI paths touch readline variables
currently, which is bad as that is changing variables that matter for
the main console UI. This patch fixes those.
This actually fixes a nasty bug -- starting gdb in MI mode ("gdb
-i=mi"), and then doing "set editing on" crashes GDB, because MI is
not prepared to use readline:
set editing on
&"set editing on\n"
=cmd-param-changed,param="editing",value="on"
^done
(gdb)
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
The fix for that was to add an interp_proc method to query the
interpreter whether it actually supports editing. New test included.
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
PR mi/20034
* cli/cli-interp.c: Include cli-interp.h and event-top.h.
(cli_interpreter_resume): Pass 1 to gdb_setup_readline. Set the
UI's input_handler here.
(cli_interpreter_supports_command_editing): New function.
(cli_interp_procs): Install it.
* cli/cli-interp.h: New file.
* event-top.c (async_command_editing_p): Rename to ...
(set_editing_cmd_var): ... this.
(change_line_handler): Add parameter 'editing', and use it. Bail
early if the interpreter doesn't support editing. Don't touch
readline state if editing is off.
(gdb_rl_callback_handler_remove, gdb_rl_callback_handler_install)
(gdb_rl_callback_handler_reinstall): Assert the current UI is the
main UI.
(display_gdb_prompt): Don't call gdb_rl_callback_handler_remove if
not using readline. Check whether the current UI is using command
editing instead of checking the async_command_editing_p global.
(set_async_editing_command): Delete.
(gdb_setup_readline): Add 'editing' parameter. Only allow editing
on the main UI. Don't touch readline state if editing is off.
(gdb_disable_readline): Don't touch readline state if editing is
off.
* event-top.h (gdb_setup_readline): Add 'int' parameter.
(set_async_editing_command): Delete declaration.
(change_line_handler, command_line_handler): Declare.
(async_command_editing_p): Rename to ...
(set_editing_cmd_var): ... this.
* infrun.c (reinstall_readline_callback_handler_cleanup): Check
whether the current UI has editing enabled rather than checking
the async_command_editing_p global.
* interps.c (interp_supports_command_editing): New function.
* interps.h (interp_supports_command_editing_ftype): New typedef.
(struct interp_procs) <supports_command_editing_proc>: New field.
(interp_supports_command_editing): Declare.
* mi/mi-interp.c (mi_interpreter_resume): Pass 0 to
gdb_setup_readline. Don't clear the async_command_editing_p
global. Update comments.
* top.c (gdb_readline_wrapper_line, gdb_readline_wrapper): Check
whether the current UI has editing enabled rather than checking
the async_command_editing_p global. Don't touch readline state if
editing is off.
(undo_terminal_modifications_before_exit): Switch to the main UI.
Unconditionally call gdb_disable_readline.
(set_editing): New function.
(show_async_command_editing_p): Rename to ...
(show_editing): ... this. Show the state of the current UI.
(_initialize_top): Adjust.
* top.h (struct ui) <command_editing>: New field.
* tui/tui-interp.c: Include cli/cli-interp.h.
(tui_resume): Pass 1 to gdb_setup_readline. Set the UI's
input_handler.
(tui_interp_procs): Install
cli_interpreter_supports_command_editing.
* tui/tui-io.c (tui_getc): Check whether the current UI has
editing enabled rather than checking the async_command_editing_p
global.
gdb/testsuite/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
PR mi/20034
* gdb.mi/mi-editing.exp: New file.
2016-06-21 02:11:48 +02:00
|
|
|
if (current_ui->command_editing && key_is_start_sequence (ch))
|
2014-11-23 11:03:39 +01:00
|
|
|
{
|
|
|
|
int ch_pending;
|
|
|
|
|
|
|
|
nodelay (w, TRUE);
|
2018-09-03 23:23:48 +02:00
|
|
|
ch_pending = gdb_wgetch (w);
|
2014-11-23 11:03:39 +01:00
|
|
|
nodelay (w, FALSE);
|
|
|
|
|
|
|
|
/* If we have pending input following a start sequence, call the stdin
|
|
|
|
event handler again because ncurses may have already read and stored
|
|
|
|
the input into its internal buffer, meaning that we won't get an stdin
|
|
|
|
event for it. If we don't compensate for this missed stdin event, key
|
|
|
|
sequences as Alt_F (^[f) will not behave promptly.
|
|
|
|
|
|
|
|
(We only compensates for the missed 2nd byte of a key sequence because
|
|
|
|
2-byte sequences are by far the most commonly used. ncurses may have
|
|
|
|
buffered a larger, 3+-byte key sequence though it remains to be seen
|
|
|
|
whether it is useful to compensate for all the bytes of such
|
|
|
|
sequences.) */
|
|
|
|
if (ch_pending != ERR)
|
|
|
|
{
|
|
|
|
ungetch (ch_pending);
|
|
|
|
call_stdin_event_handler_again_p = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
return ch;
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2015-01-31 09:47:14 +01:00
|
|
|
/* Utility function to expand TABs in a STRING into spaces. STRING
|
|
|
|
will be displayed starting at column COL, and is assumed to include
|
|
|
|
no newlines. The returned expanded string is malloc'ed. */
|
|
|
|
|
|
|
|
char *
|
|
|
|
tui_expand_tabs (const char *string, int col)
|
|
|
|
{
|
2015-03-21 09:48:34 +01:00
|
|
|
int n_adjust, ncol;
|
2015-01-31 09:47:14 +01:00
|
|
|
const char *s;
|
|
|
|
char *ret, *q;
|
|
|
|
|
|
|
|
/* 1. How many additional characters do we need? */
|
2015-03-21 09:48:34 +01:00
|
|
|
for (ncol = col, n_adjust = 0, s = string; s; )
|
2015-01-31 09:47:14 +01:00
|
|
|
{
|
|
|
|
s = strpbrk (s, "\t");
|
|
|
|
if (s)
|
|
|
|
{
|
2015-03-21 09:48:34 +01:00
|
|
|
ncol += (s - string) + n_adjust;
|
2015-01-31 09:47:14 +01:00
|
|
|
/* Adjustment for the next tab stop, minus one for the TAB
|
|
|
|
we replace with spaces. */
|
2015-03-21 09:48:34 +01:00
|
|
|
n_adjust += 8 - (ncol % 8) - 1;
|
2015-01-31 09:47:14 +01:00
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the copy. */
|
2015-09-25 20:08:06 +02:00
|
|
|
ret = q = (char *) xmalloc (strlen (string) + n_adjust + 1);
|
2015-01-31 09:47:14 +01:00
|
|
|
|
|
|
|
/* 2. Copy the original string while replacing TABs with spaces. */
|
2015-03-21 09:48:34 +01:00
|
|
|
for (ncol = col, s = string; s; )
|
2015-01-31 09:47:14 +01:00
|
|
|
{
|
2015-03-09 12:58:20 +01:00
|
|
|
const char *s1 = strpbrk (s, "\t");
|
2015-01-31 09:47:14 +01:00
|
|
|
if (s1)
|
|
|
|
{
|
|
|
|
if (s1 > s)
|
|
|
|
{
|
|
|
|
strncpy (q, s, s1 - s);
|
|
|
|
q += s1 - s;
|
2015-03-21 09:48:34 +01:00
|
|
|
ncol += s1 - s;
|
2015-01-31 09:47:14 +01:00
|
|
|
}
|
|
|
|
do {
|
|
|
|
*q++ = ' ';
|
2015-03-21 09:48:34 +01:00
|
|
|
ncol++;
|
|
|
|
} while ((ncol % 8) != 0);
|
2015-01-31 09:47:14 +01:00
|
|
|
s1++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy (q, s);
|
|
|
|
s = s1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|