set text [Term::get_line 1]
# Just check for any register window content at all.
Term::check_contents "any register contents" "\\|.*\[^ \].*\\|"
+
+
+# Check that we can successfully cause the register window to appear
+# using the 'tui reg next' and 'tui reg prev' commands.
+foreach_with_prefix cmd { next prev } {
+ Term::clean_restart 24 80 $testfile
+
+ if {![runto_main]} {
+ perror "test suppressed"
+ return
+ }
+
+ if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+ }
+
+ Term::command "tui reg ${cmd}"
+ Term::check_box "register box" 0 0 80 8
+ Term::check_box "source box in regs layout" 0 7 80 8
+ Term::check_region_contents "check register group title" \
+ 0 0 80 1 "Register group: "
+ set contents [Term::get_region 0 15 80 8 "\r\n"]
+ gdb_assert {![regexp -- "unknown register group '${cmd}'" $contents]} \
+ "check register group is known"
+}
}
/* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap
- around behaviour. Returns the next register group, or NULL if the
- register window is not currently being displayed. */
+ around behaviour. Will never return nullptr. If CURRENT_GROUP is
+ nullptr (e.g. if the tui register window has only just been displayed
+ and has no current group selected), then the first register group will
+ be returned. */
static const reggroup *
tui_reg_next (const reggroup *current_group, struct gdbarch *gdbarch)
{
- const reggroup *group = NULL;
-
- if (current_group != NULL)
- {
- group = reggroup_next (gdbarch, current_group);
- if (group == NULL)
- group = reggroup_next (gdbarch, NULL);
- }
+ const reggroup *group = reggroup_next (gdbarch, current_group);
+ if (group == NULL)
+ group = reggroup_next (gdbarch, NULL);
return group;
}
/* Helper for "tui reg prev", wraps a call to REGGROUP_PREV, but adds wrap
- around behaviour. Returns the previous register group, or NULL if the
- register window is not currently being displayed. */
+ around behaviour. Will never return nullptr. If CURRENT_GROUP is
+ nullptr (e.g. if the tui register window has only just been displayed
+ and has no current group selected), then the last register group will
+ be returned. */
static const reggroup *
tui_reg_prev (const reggroup *current_group, struct gdbarch *gdbarch)
{
- const reggroup *group = NULL;
-
- if (current_group != NULL)
- {
- group = reggroup_prev (gdbarch, current_group);
- if (group == NULL)
- group = reggroup_prev (gdbarch, NULL);
- }
+ const reggroup *group = reggroup_prev (gdbarch, current_group);
+ if (group == NULL)
+ group = reggroup_prev (gdbarch, NULL);
return group;
}