mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
9e820dec13
This changes the TUI source and disassembly windows to use a curses pad for their text. This is an important step toward properly handling non-ASCII characters, because it makes it easy to scroll horizontally without needing gdb to also understand multi-byte character boundaries -- this can be wholly delegated to curses. Horizontal scrolling is probably also faster now, because no re-rendering is required. gdb/ChangeLog 2020-09-27 Tom Tromey <tom@tromey.com> * unittests/tui-selftests.c: Update. * tui/tui-winsource.h (struct tui_source_window_base) <extra_margin, show_line_number, refresh_pad>: New methods. <m_max_length, m_pad>: New members. (tui_copy_source_line): Update. * tui/tui-winsource.c (tui_copy_source_line): Remove line_no, first_col, line_width, ndigits parameters. Add length. (tui_source_window_base::show_source_line): Write to pad. Line number now 0-based. (tui_source_window_base::refresh_pad): New method. (tui_source_window_base::show_source_content): Write to pad. Call refresh_pad. (tui_source_window_base::do_scroll_horizontal): Call refresh_pad, not refill. (tui_source_window_base::update_exec_info): Call show_line_number. * tui/tui-source.h (struct tui_source_window) <extra_margin>: New method. <m_digits>: New member. * tui/tui-source.c (tui_source_window::set_contents): Set m_digits and m_max_length. (tui_source_window::show_line_number): New method. * tui/tui-io.h (tui_puts): Fix comment. * tui/tui-disasm.c (tui_disasm_window::set_contents): Set m_max_length.
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
/* Self tests for the TUI
|
|
|
|
Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
|
|
|
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
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(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
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "gdbsupport/selftest.h"
|
|
|
|
#ifdef TUI
|
|
|
|
#include "tui/tui-winsource.h"
|
|
|
|
namespace selftests {
|
|
namespace tui {
|
|
|
|
static void
|
|
run_tests ()
|
|
{
|
|
const char *text = "hello";
|
|
std::string result = tui_copy_source_line (&text);
|
|
SELF_CHECK (result == "hello");
|
|
SELF_CHECK (*text == '\0');
|
|
|
|
text = "hello\n";
|
|
result = tui_copy_source_line (&text);
|
|
SELF_CHECK (result == "hello");
|
|
SELF_CHECK (*text == '\0');
|
|
}
|
|
|
|
} /* namespace tui*/
|
|
} /* namespace selftests */
|
|
|
|
#endif /* TUI */
|
|
|
|
void _initialize_tui_selftest ();
|
|
void
|
|
_initialize_tui_selftest ()
|
|
{
|
|
#ifdef TUI
|
|
selftests::register_test ("tui", selftests::tui::run_tests);
|
|
#endif
|
|
}
|