👷 update device selection page

This commit is contained in:
Vladislav Nepogodin 2021-12-03 01:07:52 +04:00
parent b1aa7a8c62
commit d0bc5f469a
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
3 changed files with 7 additions and 4 deletions

View File

@ -116,7 +116,11 @@ void select_device() noexcept {
return menu->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
});
auto ok_callback = [&] { config_data["DEVICE"] = devices_list[selected]; };
auto ok_callback = [&] {
auto src = devices_list[selected];
const auto& lines = utils::make_multiline(src, " ");
config_data["DEVICE"] = lines[0];
};
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()});
auto controls = Renderer(controls_container, [&] {

View File

@ -110,8 +110,7 @@ bool prompt_char(const char* prompt, const char* color, char* read) noexcept {
return false;
}
auto make_multiline(std::string& str) noexcept -> std::vector<std::string> {
static constexpr std::string_view delim{"\n"};
auto make_multiline(std::string& str, const std::string_view&& delim) noexcept -> std::vector<std::string> {
std::vector<std::string> lines{};
std::size_t start{};

View File

@ -12,7 +12,7 @@ void print_banner() noexcept;
[[nodiscard]] bool is_connected() noexcept;
bool prompt_char(const char* prompt, const char* color = RESET, char* read = nullptr) noexcept;
void clear_screen() noexcept;
[[nodiscard]] auto make_multiline(std::string& str) noexcept -> std::vector<std::string>;
[[nodiscard]] auto make_multiline(std::string& str, const std::string_view&& delim = "\n") noexcept -> std::vector<std::string>;
auto exec(const std::string_view& command, bool capture_output = true) noexcept -> std::string;
[[nodiscard]] bool check_root() noexcept;