mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-03 04:12:10 +08:00
Replace input_interactive_p with a method
This replaces the global input_interactive_p function with a new method ui::input_interactive_p.
This commit is contained in:
parent
8f7f9b3a91
commit
efd3baf0dc
@ -1176,7 +1176,7 @@ counted_command_line
|
||||
read_command_lines (const char *prompt_arg, int from_tty, int parse_commands,
|
||||
gdb::function_view<void (const char *)> validator)
|
||||
{
|
||||
if (from_tty && input_interactive_p (current_ui))
|
||||
if (from_tty && current_ui->input_interactive_p ())
|
||||
{
|
||||
if (deprecated_readline_begin_hook)
|
||||
{
|
||||
@ -1203,7 +1203,7 @@ read_command_lines (const char *prompt_arg, int from_tty, int parse_commands,
|
||||
validator);
|
||||
}
|
||||
|
||||
if (from_tty && input_interactive_p (current_ui)
|
||||
if (from_tty && current_ui->input_interactive_p ()
|
||||
&& deprecated_readline_end_hook)
|
||||
{
|
||||
(*deprecated_readline_end_hook) ();
|
||||
|
@ -322,8 +322,6 @@ extern void print_prompt (void);
|
||||
|
||||
struct ui;
|
||||
|
||||
extern int input_interactive_p (struct ui *);
|
||||
|
||||
extern bool info_verbose;
|
||||
|
||||
/* From printcmd.c */
|
||||
|
@ -687,7 +687,7 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
|
||||
}
|
||||
|
||||
/* Do history expansion if that is wished. */
|
||||
if (history_expansion_p && from_tty && input_interactive_p (current_ui))
|
||||
if (history_expansion_p && from_tty && current_ui->input_interactive_p ())
|
||||
{
|
||||
char *cmd_expansion;
|
||||
int expanded;
|
||||
@ -729,7 +729,7 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
|
||||
and then later fetch it from the value history and remove the
|
||||
'#'. The kill ring is probably better, but some people are in
|
||||
the habit of commenting things out. */
|
||||
if (*cmd != '\0' && from_tty && input_interactive_p (current_ui))
|
||||
if (*cmd != '\0' && from_tty && current_ui->input_interactive_p ())
|
||||
gdb_add_history (cmd);
|
||||
|
||||
/* Save into global buffer if appropriate. */
|
||||
|
18
gdb/top.c
18
gdb/top.c
@ -308,7 +308,7 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
|
||||
outstream (outstream_),
|
||||
errstream (errstream_),
|
||||
input_fd (fileno (instream)),
|
||||
input_interactive_p (ISATTY (instream)),
|
||||
m_input_interactive_p (ISATTY (instream)),
|
||||
prompt_state (PROMPT_NEEDED),
|
||||
m_gdb_stdout (new pager_file (new stdio_file (outstream))),
|
||||
m_gdb_stdin (new stdio_file (instream)),
|
||||
@ -1405,13 +1405,13 @@ command_line_input (const char *prompt_arg, const char *annotation_suffix)
|
||||
/* Don't use fancy stuff if not talking to stdin. */
|
||||
if (deprecated_readline_hook
|
||||
&& from_tty
|
||||
&& input_interactive_p (current_ui))
|
||||
&& current_ui->input_interactive_p ())
|
||||
{
|
||||
rl.reset ((*deprecated_readline_hook) (prompt));
|
||||
}
|
||||
else if (command_editing_p
|
||||
&& from_tty
|
||||
&& input_interactive_p (current_ui))
|
||||
&& current_ui->input_interactive_p ())
|
||||
{
|
||||
rl.reset (gdb_readline_wrapper (prompt));
|
||||
}
|
||||
@ -1875,7 +1875,7 @@ quit_force (int *exit_arg, int from_tty)
|
||||
any UI with a terminal, save history. */
|
||||
for (ui *ui : all_uis ())
|
||||
{
|
||||
if (input_interactive_p (ui))
|
||||
if (ui->input_interactive_p ())
|
||||
{
|
||||
save = 1;
|
||||
break;
|
||||
@ -1923,23 +1923,23 @@ show_interactive_mode (struct ui_file *file, int from_tty,
|
||||
if (interactive_mode == AUTO_BOOLEAN_AUTO)
|
||||
gdb_printf (file, "Debugger's interactive mode "
|
||||
"is %s (currently %s).\n",
|
||||
value, input_interactive_p (current_ui) ? "on" : "off");
|
||||
value, current_ui->input_interactive_p () ? "on" : "off");
|
||||
else
|
||||
gdb_printf (file, "Debugger's interactive mode is %s.\n", value);
|
||||
}
|
||||
|
||||
/* Returns whether GDB is running on an interactive terminal. */
|
||||
|
||||
int
|
||||
input_interactive_p (struct ui *ui)
|
||||
bool
|
||||
ui::input_interactive_p () const
|
||||
{
|
||||
if (batch_flag)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (interactive_mode != AUTO_BOOLEAN_AUTO)
|
||||
return interactive_mode == AUTO_BOOLEAN_TRUE;
|
||||
|
||||
return ui->input_interactive_p;
|
||||
return m_input_interactive_p;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -124,7 +124,7 @@ struct ui
|
||||
/* Whether ISATTY returns true on input_fd. Cached here because
|
||||
quit_force needs to know this _after_ input_fd might be
|
||||
closed. */
|
||||
int input_interactive_p;
|
||||
bool m_input_interactive_p;
|
||||
|
||||
/* See enum prompt_state's description. */
|
||||
enum prompt_state prompt_state;
|
||||
@ -154,6 +154,9 @@ struct ui
|
||||
|
||||
/* Unregister the UI's input file descriptor from the event loop. */
|
||||
void unregister_file_handler ();
|
||||
|
||||
/* Return true if this UI's input fd is a tty. */
|
||||
bool input_interactive_p () const;
|
||||
};
|
||||
|
||||
/* The main UI. This is the UI that is bound to stdin/stdout/stderr.
|
||||
|
@ -880,7 +880,7 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
|
||||
way, important error messages don't get lost when talking to GDB
|
||||
over a pipe. */
|
||||
if (current_ui->instream != current_ui->stdin_stream
|
||||
|| !input_interactive_p (current_ui)
|
||||
|| !current_ui->input_interactive_p ()
|
||||
/* Restrict queries to the main UI. */
|
||||
|| current_ui != main_ui)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user