summaryrefslogtreecommitdiff
path: root/cli/component.cpp
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-01-18 18:44:22 +0100
committerEugen Wissner <belka@caraus.de>2026-01-18 18:44:22 +0100
commitc9a3ebd623bf2f968f7fbdf5bb2d7dda480b9f1c (patch)
treee1a1837c62ffcf7cd0255395cdc449430cb9f352 /cli/component.cpp
parent2485d00c4c40713b6cb3c39595d69ea2cf497b47 (diff)
downloadkatja-c9a3ebd623bf2f968f7fbdf5bb2d7dda480b9f1c.tar.gz
Parse command line with boost program_options
Diffstat (limited to 'cli/component.cpp')
-rw-r--r--cli/component.cpp89
1 files changed, 0 insertions, 89 deletions
diff --git a/cli/component.cpp b/cli/component.cpp
deleted file mode 100644
index 6735077..0000000
--- a/cli/component.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- */
-module;
-
-#include <optional>
-#include <sstream>
-
-#include <ftxui/component/event.hpp>
-#include <ftxui/component/component.hpp>
-#include <ftxui/dom/elements.hpp>
-
-import katja.repository;
-
-export module katja.component;
-
-export namespace katja
-{
- class PackageListBase : public ftxui::ComponentBase
- {
- std::string title;
- const std::vector<package_identifier> packages;
- std::optional<std::size_t> selected;
-
- public:
- PackageListBase(const std::string& title, const std::vector<package_identifier>& packages = {})
- : title(title), packages(packages)
- {
- }
-
- ftxui::Element OnRender() override
- {
- std::vector<ftxui::Element> lines;
-
- for (const auto& package_identifier : this->packages)
- {
- auto line = ftxui::text(package_identifier.to_string()) | color(ftxui::Color::SkyBlue2);
- lines.push_back(line);
- }
- if (this->selected.has_value() && this->selected.value() < lines.size())
- {
- lines[this->selected.value()] |= ftxui::focus;
- }
- std::stringstream summary;
-
- summary << title << '(' << packages.size() << ')';
-
- return ftxui::window(ftxui::text(summary.str()), ftxui::vbox(lines) | ftxui::yframe);
- }
-
- bool OnEvent(ftxui::Event event) override
- {
- if (event == ftxui::Event::ArrowDown)
- {
- if (!this->selected.has_value() && !this->packages.empty())
- {
- this->selected = std::make_optional<std::size_t>(0);
- }
- else if (this->selected.has_value() && this->selected.value() + 1 < this->packages.size())
- {
- this->selected = std::make_optional<std::size_t>(this->selected.value() + 1);
- }
- return true;
- }
- else if (event == ftxui::Event::ArrowUp)
- {
- if (!this->selected.has_value() && !this->packages.empty())
- {
- this->selected = std::make_optional<std::size_t>(0);
- }
- else if (this->selected.has_value()
- && this->selected.value() < this->packages.size()
- && this->selected.value() > 0)
- {
- this->selected = std::make_optional<std::size_t>(this->selected.value() - 1);
- }
- return true;
- }
- return false;
- }
- };
-
- ftxui::Component PackageList(const std::string& title, const std::vector<package_identifier>& packages = {})
- {
- return ftxui::Make<PackageListBase>(title, packages);
- }
-}