From 297c353e40a9bc0ffe1c7fd3638300a24353b9de Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Thu, 2 Dec 2021 02:23:41 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20add=20devices=20ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tui.cpp | 23 +++++++++++++++++++++++ src/utils.cpp | 7 ------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/tui.cpp b/src/tui.cpp index b4fb678..66b7bfa 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -1,5 +1,6 @@ #include "tui.hpp" #include "definitions.hpp" +#include "utils.hpp" #include #include @@ -31,6 +32,28 @@ ftxui::Element centered_widget(ftxui::Component& container, const std::string_vi }); } +// Simple code to show devices / partitions. +void show_devices() { + auto screen = ScreenInteractive::Fullscreen(); + const auto& lsblk = utils::exec("lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | grep \"disk\\|part\\|lvm\\|crypt\\|NAME\\|MODEL\\|TYPE\\|FSTYPE\\|SIZE\\|MOUNTPOINT\""); + + /* clang-format off */ + auto button_option = ButtonOption(); + button_option.border = false; + auto button_back = Button("Back", screen.ExitLoopClosure(), &button_option); + /* clang-format on */ + + auto container = Container::Horizontal({ + button_back, + }); + + auto renderer = Renderer(container, [&] { + return tui::centered_widget(container, "New CLI Installer", text(lsblk.data()) | size(HEIGHT, GREATER_THAN, 5)); + }); + + screen.Loop(renderer); +} + void init() noexcept { auto screen = ScreenInteractive::Fullscreen(); diff --git a/src/utils.cpp b/src/utils.cpp index 7956280..46e94eb 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -99,13 +99,6 @@ bool prompt_char(const char* prompt, const char* color, char* read) noexcept { return false; } -// Simple code to show devices / partitions. -void show_devices() { - [[maybe_unused]] const auto& lsblk = utils::exec("lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | grep \"disk\\|part\\|lvm\\|crypt\\|NAME\\|MODEL\\|TYPE\\|FSTYPE\\|SIZE\\|MOUNTPOINT\""); - - // DIALOG " $_DevShowOpt " --textbox /tmp/.devlist 0 0 -} - void id_system() noexcept { auto* config_instance = Config::instance(); auto& config_data = config_instance->data();