diff --git a/src/tui.cpp b/src/tui.cpp index c6a0a86..ed7af02 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -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, [&] { diff --git a/src/utils.cpp b/src/utils.cpp index 9f504ce..60557e5 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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 { - static constexpr std::string_view delim{"\n"}; +auto make_multiline(std::string& str, const std::string_view&& delim) noexcept -> std::vector { std::vector lines{}; std::size_t start{}; diff --git a/src/utils.hpp b/src/utils.hpp index 5ce0975..1dd5263 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -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; +[[nodiscard]] auto make_multiline(std::string& str, const std::string_view&& delim = "\n") noexcept -> std::vector; auto exec(const std::string_view& command, bool capture_output = true) noexcept -> std::string; [[nodiscard]] bool check_root() noexcept;