diff options
author | Tom Tromey <tromey@adacore.com> | 2019-03-08 13:41:55 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-03-14 05:47:10 -0600 |
commit | 6f11e6824e15bd40fe1e7b245a22865c6ef8c7bd (patch) | |
tree | c4ba703384d8adcb73a5231d1d07563d44213957 /gdb/tui/tui-winsource.c | |
parent | a0148d8416f6c692b83acc77cf838b3e7929a249 (diff) | |
download | binutils-6f11e6824e15bd40fe1e7b245a22865c6ef8c7bd.zip binutils-6f11e6824e15bd40fe1e7b245a22865c6ef8c7bd.tar.gz binutils-6f11e6824e15bd40fe1e7b245a22865c6ef8c7bd.tar.bz2 |
Make TUI react to "set style enabled"
When the user toggles "set style enabled", the TUI should react by
redrawing the source window, if necessary. This patch implements this
behavior.
No test because the TUI is generally not tested.
This version of the patch incorporates Pedro's patch to provide a
clean way to force the TUI to update the source window's contents.
gdb/ChangeLog
2019-03-14 Pedro Alves <palves@redhat.com>
Tom Tromey <tromey@adacore.com>
* tui/tui-winsource.h (tui_refill_source_window): Declare.
* tui/tui-winsource.c (tui_refill_source_window): New function,
from...
(tui_horizontal_source_scroll): ... here. Move some logic.
* cli/cli-style.c (set_style_enabled): Notify new observable.
* tui/tui-hooks.c (tui_redisplay_source): New function.
(tui_attach_detach_observers): Attach or detach
tui_redisplay_source.
* observable.h (source_styling_changed): New observable.
* observable.c: Define source_styling_changed observable.
Diffstat (limited to 'gdb/tui/tui-winsource.c')
-rw-r--r-- | gdb/tui/tui-winsource.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 9336f7b..7fd460b 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -306,8 +306,32 @@ tui_show_source_content (struct tui_win_info *win_info) win_info->generic.content_in_use = TRUE; } +/* Refill the source window's source cache and update it. If WIN_INFO + is a disassembly window, then just update it. */ + +void +tui_refill_source_window (struct tui_win_info *win_info) +{ + symtab *s = nullptr; + + if (win_info->generic.type == SRC_WIN) + { + symtab_and_line cursal = get_current_source_symtab_and_line (); + s = (cursal.symtab == NULL + ? find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL))) + : cursal.symtab); + } + + tui_update_source_window_as_is (win_info, + win_info->detail.source_info.gdbarch, + s, + win_info->generic.content[0] + ->which_element.source.line_or_addr, + FALSE); +} /* Scroll the source forward or backward horizontally. */ + void tui_horizontal_source_scroll (struct tui_win_info *win_info, enum tui_scroll_direction direction, @@ -315,20 +339,7 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info, { if (win_info->generic.content != NULL) { - struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch; int offset; - struct symtab *s = NULL; - - if (win_info->generic.type == SRC_WIN) - { - struct symtab_and_line cursal - = get_current_source_symtab_and_line (); - - if (cursal.symtab == NULL) - s = find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL))); - else - s = cursal.symtab; - } if (direction == LEFT_SCROLL) offset = win_info->detail.source_info.horizontal_offset @@ -341,13 +352,8 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info, offset = 0; } win_info->detail.source_info.horizontal_offset = offset; - tui_update_source_window_as_is (win_info, gdbarch, s, - win_info->generic.content[0] - ->which_element.source.line_or_addr, - FALSE); + tui_refill_source_window (win_info); } - - return; } |