summaryrefslogtreecommitdiff
path: root/gdb/cli/cli-style.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-06-25 21:38:25 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-06-25 21:39:26 -0400
commit4c0ba02a749d84a7e569e010fca9f640c30d17df (patch)
treedb5935ef09b75752a45b41f724d63e0c1c7d6c69 /gdb/cli/cli-style.c
parentd6ff04a343f97026f7d23bb036e0f858b21f3bfd (diff)
downloadbinutils-gdb-4c0ba02a749d84a7e569e010fca9f640c30d17df.tar.gz
gdb: remove context parameter from add_setshow_enum_cmd
I propose removing the context parameter from add_setshow_enum_cmd. It was useful before add_setshow_enum_cmd returned both created commands, as the caller couldn't easily set the context itself. But now, I think it's fine to just let the caller do it. gdb/ChangeLog: * command.h (add_setshow_enum_cmd): Remove context parameter. * cli/cli-decode.c (add_setshow_enum_cmd): Likewise, and don't set context. * cli/cli-style.c (cli_style_option::add_setshow_commands): Set context here. Change-Id: I377c4e6820ec9d5069492ed28f4cba342ce1336e
Diffstat (limited to 'gdb/cli/cli-style.c')
-rw-r--r--gdb/cli/cli-style.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 0b88dba5622..aca19c51b84 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -230,32 +230,46 @@ cli_style_option::add_setshow_commands (enum command_class theclass,
0, set_list);
add_show_prefix_cmd (m_name, no_class, prefix_doc, &m_show_list,
0, show_list);
+ set_show_commands commands;
+
+ commands = add_setshow_enum_cmd
+ ("foreground", theclass, cli_colors,
+ &m_foreground,
+ _("Set the foreground color for this property."),
+ _("Show the foreground color for this property."),
+ nullptr,
+ do_set_value,
+ do_show_foreground,
+ &m_set_list, &m_show_list);
+ commands.set->set_context (this);
+ commands.show->set_context (this);
+
+ commands = add_setshow_enum_cmd
+ ("background", theclass, cli_colors,
+ &m_background,
+ _("Set the background color for this property."),
+ _("Show the background color for this property."),
+ nullptr,
+ do_set_value,
+ do_show_background,
+ &m_set_list, &m_show_list);
+ commands.set->set_context (this);
+ commands.show->set_context (this);
- add_setshow_enum_cmd ("foreground", theclass, cli_colors,
- &m_foreground,
- _("Set the foreground color for this property."),
- _("Show the foreground color for this property."),
- nullptr,
- do_set_value,
- do_show_foreground,
- &m_set_list, &m_show_list, (void *) this);
- add_setshow_enum_cmd ("background", theclass, cli_colors,
- &m_background,
- _("Set the background color for this property."),
- _("Show the background color for this property."),
- nullptr,
- do_set_value,
- do_show_background,
- &m_set_list, &m_show_list, (void *) this);
if (!skip_intensity)
- add_setshow_enum_cmd ("intensity", theclass, cli_intensities,
- &m_intensity,
- _("Set the display intensity for this property."),
- _("Show the display intensity for this property."),
- nullptr,
- do_set_value,
- do_show_intensity,
- &m_set_list, &m_show_list, (void *) this);
+ {
+ commands = add_setshow_enum_cmd
+ ("intensity", theclass, cli_intensities,
+ &m_intensity,
+ _("Set the display intensity for this property."),
+ _("Show the display intensity for this property."),
+ nullptr,
+ do_set_value,
+ do_show_intensity,
+ &m_set_list, &m_show_list);
+ commands.set->set_context (this);
+ commands.show->set_context (this);
+ }
}
static cmd_list_element *style_set_list;