aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-winsource.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-09-27 20:30:30 -0600
committerTom Tromey <tom@tromey.com>2020-09-27 20:30:32 -0600
commit9e820dec13ec153f5843a30afe6d1c5037405278 (patch)
tree4dd4ccdadf25c5eb5781d4034cc5be52e109d32a /gdb/tui/tui-winsource.h
parentc15c15c8d998af6676562d15b9a1f1dcac1fa3ea (diff)
downloadbinutils-9e820dec13ec153f5843a30afe6d1c5037405278.zip
binutils-9e820dec13ec153f5843a30afe6d1c5037405278.tar.gz
binutils-9e820dec13ec153f5843a30afe6d1c5037405278.tar.bz2
Use a curses pad for source and disassembly windows
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.
Diffstat (limited to 'gdb/tui/tui-winsource.h')
-rw-r--r--gdb/tui/tui-winsource.h41
1 files changed, 30 insertions, 11 deletions
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ba9c0fd..5fc6a6d 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -107,6 +107,20 @@ protected:
virtual bool set_contents (struct gdbarch *gdbarch,
const struct symtab_and_line &sal) = 0;
+ /* Return the number of extra margin characters needed by this
+ instance. */
+ virtual int extra_margin () const
+ {
+ return 0;
+ }
+
+ /* Display the line number in the window margin. OFFSET indicates
+ which line to display; it is 0-based, with 0 meaning the line at
+ the top of the window. */
+ virtual void show_line_number (int offset) const
+ {
+ }
+
/* Redraw the complete line of a source or disassembly window. */
void show_source_line (int lineno);
@@ -119,6 +133,9 @@ protected:
std::vector<tui_source_element> m_content;
+ /* Length of longest line to be displayed. */
+ int m_max_length;
+
public:
/* Refill the source window's source cache and update it. If this
@@ -162,11 +179,17 @@ private:
void show_source_content ();
+ /* Re-display the pad in the window. */
+ void refresh_pad ();
+
/* Called when the user "set style enabled" setting is changed. */
void style_changed ();
/* A token used to register and unregister an observer. */
gdb::observers::token m_observable;
+
+ /* Pad used to display fixme mumble */
+ std::unique_ptr<WINDOW, curses_deleter> m_pad;
};
@@ -264,19 +287,15 @@ extern void tui_display_main (void);
extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
extern void tui_update_source_windows_with_line (struct symtab_and_line sal);
-/* Extract some source text from PTR. LINE_NO is the line number. If
- it is positive, it is printed at the start of the line. FIRST_COL
- is the first column to extract, and LINE_WIDTH is the number of
- characters to display. NDIGITS is used to format the line number
- (if it is positive). If NDIGITS is greater than 0, then that many
- digits are used; otherwise the line number is formatted with 6
- digits and the text is aligned to the next tab stop. Returns a
- string holding the desired text. PTR is updated to point to the
- start of the next line. */
+/* Extract some source text from PTR. Returns a string holding the
+ desired text. PTR is updated to point to the start of the next
+ line. If LENGTH is non-NULL, then the length of the line is stored
+ there. Escape sequences are not counted against the length.
+ Actually an approximation is used -- each byte of a multi-byte
+ sequence counts as a character here. */
extern std::string tui_copy_source_line (const char **ptr,
- int line_no, int first_col,
- int line_width, int ndigits);
+ int *length = nullptr);
/* Constant definitions. */
#define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */