mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 02:30:08 +01:00
cli: insert text to line so that user can edit it
'change' command puts current value on edit line, so that user can change it and confirm with <Enter>. Notes: * it works for libreadline * libedit has to be checked * doesn't work without any edit-line library - how to do that??
This commit is contained in:
parent
68d69bfce8
commit
07c92ec6e7
1 changed files with 16 additions and 0 deletions
|
|
@ -3284,6 +3284,20 @@ typedef struct {
|
|||
} EditLibSymbols;
|
||||
|
||||
static EditLibSymbols edit_lib_symbols;
|
||||
static char *pre_input_deftext;
|
||||
|
||||
static int
|
||||
set_deftext (void)
|
||||
{
|
||||
if ( pre_input_deftext
|
||||
&& edit_lib_symbols.rl_insert_text_func
|
||||
&& edit_lib_symbols.rl_startup_hook_x) {
|
||||
edit_lib_symbols.rl_insert_text_func (pre_input_deftext);
|
||||
pre_input_deftext = NULL;
|
||||
*edit_lib_symbols.rl_startup_hook_x = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GModule *
|
||||
load_cmd_line_edit_lib (void)
|
||||
|
|
@ -3725,6 +3739,8 @@ property_edit_submenu (NmCli *nmc, NMConnection *connection, NMSetting *curr_set
|
|||
break;
|
||||
|
||||
case NMC_EDITOR_SUB_CMD_CHANGE:
|
||||
*edit_lib_symbols.rl_startup_hook_x = set_deftext;
|
||||
pre_input_deftext = nmc_setting_get_property (curr_setting, prop_name, NULL);
|
||||
tmp_prompt = g_strdup_printf (_("Edit '%s' value: "), prop_name);
|
||||
prop_val_user = readline_x (tmp_prompt);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue