From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 22/24] Use error_no_arg in TUI
Date: Sat, 04 Jan 2020 18:34:00 -0000 [thread overview]
Message-ID: <20200104183410.17114-23-tom@tromey.com> (raw)
In-Reply-To: <20200104183410.17114-1-tom@tromey.com>
This changes a couple of TUI commands to use error_no_arg. The
commands are also simplified a bit, and chnaged to use other gdb CLI
utility functions like skip_to_space. This lets us removes a couple
of defines that don't interact properly with gettext.
2020-01-04 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_set_focus_command)
(tui_set_win_height_command): Use error_no_arg.
(_initialize_tui_win): Update help text.
(FOCUS_USAGE, WIN_HEIGHT_USAGE): Don't define.
Change-Id: I2bf95c2e5cfe1472d068388fa39f0cf07591b76c
---
gdb/ChangeLog | 7 ++
gdb/tui/tui-win.c | 160 ++++++++++++++++++++--------------------------
2 files changed, 77 insertions(+), 90 deletions(-)
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 1cd0878b1b9..4f9478b62a0 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -68,9 +68,6 @@ static void parse_scrolling_args (const char *,
int *);
-#define WIN_HEIGHT_USAGE "Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n"
-#define FOCUS_USAGE "Usage: focus [WINDOW-NAME | next | prev]\n"
-
#ifndef ACS_LRCORNER
# define ACS_LRCORNER '+'
#endif
@@ -707,29 +704,27 @@ tui_set_focus_command (const char *arg, int from_tty)
{
tui_enable ();
- if (arg != NULL)
- {
- struct tui_win_info *win_info = NULL;
-
- if (subset_compare (arg, "next"))
- win_info = tui_next_win (tui_win_with_focus ());
- else if (subset_compare (arg, "prev"))
- win_info = tui_prev_win (tui_win_with_focus ());
- else
- win_info = tui_partial_win_by_name (arg);
+ if (arg == NULL)
+ error_no_arg (_("name of window to focus"));
- if (win_info == NULL)
- error (_("Unrecognized window name \"%s\""), arg);
- if (!win_info->is_visible ())
- error (_("Window \"%s\" is not visible"), arg);
+ struct tui_win_info *win_info = NULL;
- tui_set_win_focus_to (win_info);
- keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
- printf_filtered (_("Focus set to %s window.\n"),
- tui_win_with_focus ()->name ());
- }
+ if (subset_compare (arg, "next"))
+ win_info = tui_next_win (tui_win_with_focus ());
+ else if (subset_compare (arg, "prev"))
+ win_info = tui_prev_win (tui_win_with_focus ());
else
- error (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
+ win_info = tui_partial_win_by_name (arg);
+
+ if (win_info == NULL)
+ error (_("Unrecognized window name \"%s\""), arg);
+ if (!win_info->is_visible ())
+ error (_("Window \"%s\" is not visible"), arg);
+
+ tui_set_win_focus_to (win_info);
+ keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
+ printf_filtered (_("Focus set to %s window.\n"),
+ tui_win_with_focus ()->name ());
}
static void
@@ -875,66 +870,59 @@ tui_set_win_height_command (const char *arg, int from_tty)
{
/* Make sure the curses mode is enabled. */
tui_enable ();
- if (arg != NULL)
- {
- const char *buf = arg;
- const char *buf_ptr = buf;
- int new_height;
- struct tui_win_info *win_info;
+ if (arg == NULL)
+ error_no_arg (_("name of window"));
- buf_ptr = strchr (buf_ptr, ' ');
- if (buf_ptr != NULL)
- {
- /* Validate the window name. */
- gdb::string_view wname (buf, buf_ptr - buf);
- win_info = tui_partial_win_by_name (wname);
+ const char *buf = arg;
+ const char *buf_ptr = buf;
+ int new_height;
+ struct tui_win_info *win_info;
- if (win_info == NULL)
- error (_("Unrecognized window name \"%s\""), arg);
- if (!win_info->is_visible ())
- error (_("Window \"%s\" is not visible"), arg);
+ buf_ptr = skip_to_space (buf_ptr);
- /* Process the size. */
- buf_ptr = skip_spaces (buf_ptr);
+ /* Validate the window name. */
+ gdb::string_view wname (buf, buf_ptr - buf);
+ win_info = tui_partial_win_by_name (wname);
- if (*buf_ptr != '\0')
- {
- bool negate = false;
- bool fixed_size = true;
- int input_no;;
-
- if (*buf_ptr == '+' || *buf_ptr == '-')
- {
- if (*buf_ptr == '-')
- negate = true;
- fixed_size = false;
- buf_ptr++;
- }
- input_no = atoi (buf_ptr);
- if (input_no > 0)
- {
- if (negate)
- input_no *= (-1);
- if (fixed_size)
- new_height = input_no;
- else
- new_height = win_info->height + input_no;
-
- /* Now change the window's height, and adjust
- all other windows around it. */
- tui_adjust_window_height (win_info, new_height);
- tui_update_gdb_sizes ();
- }
- else
- warning (_("Invalid window height specified.\n%s"),
- WIN_HEIGHT_USAGE);
- }
+ if (win_info == NULL)
+ error (_("Unrecognized window name \"%s\""), arg);
+ if (!win_info->is_visible ())
+ error (_("Window \"%s\" is not visible"), arg);
+
+ /* Process the size. */
+ buf_ptr = skip_spaces (buf_ptr);
+
+ if (*buf_ptr != '\0')
+ {
+ bool negate = false;
+ bool fixed_size = true;
+ int input_no;;
+
+ if (*buf_ptr == '+' || *buf_ptr == '-')
+ {
+ if (*buf_ptr == '-')
+ negate = true;
+ fixed_size = false;
+ buf_ptr++;
+ }
+ input_no = atoi (buf_ptr);
+ if (input_no > 0)
+ {
+ if (negate)
+ input_no *= (-1);
+ if (fixed_size)
+ new_height = input_no;
+ else
+ new_height = win_info->height + input_no;
+
+ /* Now change the window's height, and adjust
+ all other windows around it. */
+ tui_adjust_window_height (win_info, new_height);
+ tui_update_gdb_sizes ();
}
else
- printf_filtered (WIN_HEIGHT_USAGE);
+ error (_("Invalid window height specified"));
}
- else
- printf_filtered (WIN_HEIGHT_USAGE);
}
/* See tui-data.h. */
@@ -1040,25 +1028,17 @@ Usage: tabset N"));
deprecate_cmd (cmd, "set tui tab-width");
cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\
-Set or modify the height of a specified window.\n"
-WIN_HEIGHT_USAGE
-"Window names are:\n\
- src : the source window\n\
- cmd : the command window\n\
- asm : the disassembly window\n\
- regs : the register display"));
+Set or modify the height of a specified window.\n\
+Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n\
+Use \"info win\" to see the names of the windows currently being displayed."));
add_com_alias ("wh", "winheight", class_tui, 0);
set_cmd_completer (cmd, winheight_completer);
add_info ("win", tui_all_windows_info,
_("List of all displayed windows."));
cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\
-Set focus to named window or next/prev window.\n"
-FOCUS_USAGE
-"Valid Window names are:\n\
- src : the source window\n\
- asm : the disassembly window\n\
- regs : the register display\n\
- cmd : the command window"));
+Set focus to named window or next/prev window.\n\
+Usage: focus [WINDOW-NAME | next | prev]\n\
+Use \"info win\" to see the names of the windows currently being displayed."));
add_com_alias ("fs", "focus", class_tui, 0);
set_cmd_completer (cmd, focus_completer);
add_com ("+", class_tui, tui_scroll_forward_command, _("\
--
2.17.2
next prev parent reply other threads:[~2020-01-04 18:34 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-04 18:34 [PATCH 00/24] Horizontal TUI layout + windows in Python Tom Tromey
2020-01-04 18:34 ` [PATCH 23/24] Add "usage" text to all TUI command help Tom Tromey
2020-01-04 18:34 ` [PATCH 14/24] Handle ambiguity in tui_partial_win_by_name Tom Tromey
2020-01-04 18:34 ` [PATCH 24/24] Fix cast in TUI_DISASM_WIN Tom Tromey
2020-01-04 18:34 ` [PATCH 18/24] Remove tui_set_win_focus_to Tom Tromey
2020-01-04 18:34 ` [PATCH 08/24] Add the "tui new-layout" command Tom Tromey
2020-01-04 18:44 ` Eli Zaretskii
2020-01-04 18:34 ` Tom Tromey [this message]
2020-01-04 18:34 ` [PATCH 03/24] Fix latent display bug in tui_data_window Tom Tromey
2020-01-04 18:34 ` [PATCH 16/24] TUI windows do not need to store their type Tom Tromey
2020-01-04 18:34 ` [PATCH 05/24] Reimplement TUI "C-x 1" binding Tom Tromey
2020-01-04 18:34 ` [PATCH 13/24] Reimplement tui_next_win and tui_prev_win Tom Tromey
2020-01-04 18:34 ` [PATCH 04/24] Simplify TUI C-x 2 binding Tom Tromey
2020-01-04 18:34 ` [PATCH 10/24] Change return type of tui_layout_base::adjust_size Tom Tromey
2020-01-04 18:34 ` [PATCH 20/24] Allow TUI windows in Python Tom Tromey
2020-01-04 18:57 ` Eli Zaretskii
2020-02-22 19:57 ` Tom Tromey
2020-02-22 20:18 ` Eli Zaretskii
2020-03-10 22:23 ` Simon Marchi
2020-03-11 0:23 ` Tom Tromey
2020-03-11 4:47 ` Simon Marchi
2020-03-11 5:07 ` Simon Marchi
2020-03-11 18:05 ` Tom Tromey
2020-01-04 18:34 ` [PATCH 11/24] Add horizontal splitting to TUI layout Tom Tromey
2020-01-04 18:47 ` Eli Zaretskii
2020-01-04 18:34 ` [PATCH 06/24] Reimplement "tui reg" command Tom Tromey
2020-01-04 18:34 ` [PATCH 02/24] Simplify tui_add_win_to_layout Tom Tromey
2020-01-04 18:34 ` [PATCH 12/24] Change TUI window iteration Tom Tromey
2020-01-04 18:34 ` [PATCH 15/24] Remove tui_delete_invisible_windows and tui_make_all_invisible Tom Tromey
2020-01-04 18:34 ` [PATCH 19/24] Remove the TUI annotation hack Tom Tromey
2020-01-04 18:34 ` [PATCH 01/24] Use TUI_DISASM_WIN instead of tui_win_list array Tom Tromey
2020-01-04 18:34 ` [PATCH 07/24] Remove hard-coded TUI layouts Tom Tromey
2020-01-04 18:34 ` [PATCH 21/24] Make some tui_source_window_base members "protected" Tom Tromey
2020-01-04 18:34 ` [PATCH 09/24] Allow TUI sub-layouts in "new-layout" command Tom Tromey
2020-01-04 18:54 ` [PATCH 17/24] Change how TUI windows are instantiated Tom Tromey
2020-02-22 20:22 ` [PATCH 00/24] Horizontal TUI layout + windows in Python Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200104183410.17114-23-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox