firstboot: auto-fill keymap/locale questions with data from firmware, if available (#42177)
Let's make the installer experience a tiny bit nicer, and prefill everything with the data the firmware gives us.
This commit is contained in:
@@ -283,6 +283,7 @@ static void clear_by_backspace(size_t n) {
|
||||
|
||||
int ask_string_full(
|
||||
char **ret,
|
||||
const char *prefill,
|
||||
GetCompletionsCallback get_completions,
|
||||
void *userdata,
|
||||
const char *text, ...) {
|
||||
@@ -296,8 +297,17 @@ int ask_string_full(
|
||||
_cleanup_free_ char *string = NULL;
|
||||
size_t n = 0;
|
||||
|
||||
if (get_completions) {
|
||||
/* Figure out what string to preselect the query with */
|
||||
if (prefill) {
|
||||
/* Prefill query with explicit data if specified */
|
||||
|
||||
string = strdup(prefill);
|
||||
if (!string)
|
||||
return -ENOMEM;
|
||||
|
||||
n = strlen(string);
|
||||
|
||||
} else if (get_completions) {
|
||||
/* Otherwise, figure out what string to preselect the query with */
|
||||
_cleanup_strv_free_ char **completions = NULL;
|
||||
r = get_completions("", GET_COMPLETIONS_PRESELECT, &completions, userdata);
|
||||
if (r < 0)
|
||||
|
||||
@@ -95,8 +95,8 @@ typedef enum GetCompletionsFlags {
|
||||
} GetCompletionsFlags;
|
||||
|
||||
typedef int (*GetCompletionsCallback)(const char *key, GetCompletionsFlags flags, char ***ret_list, void *userdata);
|
||||
int ask_string_full(char **ret, GetCompletionsCallback get_completions, void *userdata, const char *text, ...) _printf_(4, 5);
|
||||
#define ask_string(ret, text, ...) ask_string_full(ret, NULL, NULL, text, ##__VA_ARGS__)
|
||||
int ask_string_full(char **ret, const char *prefill, GetCompletionsCallback get_completions, void *userdata, const char *text, ...) _printf_(5, 6);
|
||||
#define ask_string(ret, text, ...) ask_string_full(ret, NULL, NULL, NULL, text, ##__VA_ARGS__)
|
||||
|
||||
bool any_key_to_proceed(void);
|
||||
int show_menu(char **x, size_t n_columns, size_t column_width, unsigned ellipsize_percentage, const char *grey_prefix, bool with_numbers);
|
||||
|
||||
Reference in New Issue
Block a user