mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 05:39:24 +01:00
client: Enable non-interactive mode support for agent prompts
This commit is contained in:
parent
02e38304b3
commit
df32279a31
@ -509,7 +509,7 @@ static bool read_handler(struct l_io *io, void *user_data)
|
|||||||
{
|
{
|
||||||
rl_callback_read_char();
|
rl_callback_read_char();
|
||||||
|
|
||||||
if (display_agent_is_active())
|
if (display_agent_is_active() || !command_is_interactive_mode())
|
||||||
mask_input();
|
mask_input();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -547,14 +547,19 @@ void display_agent_prompt(const char *label, bool mask_input)
|
|||||||
{
|
{
|
||||||
char *prompt;
|
char *prompt;
|
||||||
|
|
||||||
if (agent_saved_input)
|
|
||||||
return;
|
|
||||||
|
|
||||||
masked_input.use_mask = mask_input;
|
masked_input.use_mask = mask_input;
|
||||||
|
|
||||||
if (mask_input)
|
if (mask_input)
|
||||||
reset_masked_input();
|
reset_masked_input();
|
||||||
|
|
||||||
|
prompt = l_strdup_printf(COLOR_BLUE "%s " COLOR_OFF, label);
|
||||||
|
|
||||||
|
if (command_is_interactive_mode()) {
|
||||||
|
if (agent_saved_input) {
|
||||||
|
l_free(prompt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
agent_saved_input = l_new(struct saved_input, 1);
|
agent_saved_input = l_new(struct saved_input, 1);
|
||||||
|
|
||||||
agent_saved_input->point = rl_point;
|
agent_saved_input->point = rl_point;
|
||||||
@ -564,16 +569,30 @@ void display_agent_prompt(const char *label, bool mask_input)
|
|||||||
rl_redisplay();
|
rl_redisplay();
|
||||||
|
|
||||||
rl_erase_empty_line = 0;
|
rl_erase_empty_line = 0;
|
||||||
|
|
||||||
prompt = l_strdup_printf(COLOR_BLUE "%s " COLOR_OFF, label);
|
|
||||||
rl_set_prompt(prompt);
|
rl_set_prompt(prompt);
|
||||||
|
} else {
|
||||||
|
rl_callback_handler_install(prompt, readline_callback);
|
||||||
|
|
||||||
|
if (!io)
|
||||||
|
io = l_io_new(fileno(stdin));
|
||||||
|
|
||||||
|
l_io_set_read_handler(io, read_handler, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
l_free(prompt);
|
l_free(prompt);
|
||||||
|
|
||||||
rl_forced_update_display();
|
rl_redisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_agent_prompt_release(const char *label)
|
void display_agent_prompt_release(const char *label)
|
||||||
{
|
{
|
||||||
|
if (!command_is_interactive_mode()) {
|
||||||
|
rl_callback_handler_remove();
|
||||||
|
l_io_destroy(io);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!agent_saved_input)
|
if (!agent_saved_input)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user