diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-04-09 11:27:42 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-04-09 11:27:42 +0200 |
| commit | 68f64f20dd2f827f6076ec02d3eaa8961fd12022 (patch) | |
| tree | d857be0cf3a4f5c70b8154cdf7ff49527379fad9 /cli/component.cpp | |
| parent | de94f3d35557b4590e0c11de303d9d9c51217d5f (diff) | |
| download | kazbek-68f64f20dd2f827f6076ec02d3eaa8961fd12022.tar.gz | |
katja: Load updatable list on demand
Diffstat (limited to 'cli/component.cpp')
| -rw-r--r-- | cli/component.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/cli/component.cpp b/cli/component.cpp index e588959..db29052 100644 --- a/cli/component.cpp +++ b/cli/component.cpp @@ -32,18 +32,30 @@ namespace katja bool ScreenContainer::OnEvent(ftxui::Event event) { - if (event.character() == "q" && this->on_enter) + if (event == ftxui::Event::CtrlQ && this->on_enter) { on_enter(); return true; } int previously = this->menu_selected; - bool result = menu->OnEvent(event); + bool result{ false }; + if (event == ftxui::Event::CtrlP) + { + result = menu->OnEvent(ftxui::Event::ArrowLeft); + } + else if (event == ftxui::Event::CtrlN) + { + result = menu->OnEvent(ftxui::Event::ArrowRight); + } if (previously != this->menu_selected) { this->menu_pages.at(this->menu_selected)->Load(); } + if (!result) + { + result = this->menu_pages.at(this->menu_selected)->OnEvent(event); + } return result; } @@ -61,13 +73,14 @@ namespace katja { } - UpdatesPage::UpdatesPage(std::vector<package_identifier>&& updatable) - : updatable(std::move(updatable)) + UpdatesPage::UpdatesPage(std::shared_ptr<struct repository> repository, package_database database) + : repository(repository), database(database) { } void UpdatesPage::Load() { + this->updatable = repository->get_updates(this->database); } ftxui::Element UpdatesPage::OnRender() @@ -87,4 +100,18 @@ namespace katja void SearchPage::Load() { } + + ftxui::Element SearchPage::OnRender() + { + return ftxui::vbox({ + ftxui::hbox({ + this->search_input->Render() + }) + }); + } + + bool SearchPage::OnEvent(ftxui::Event event) + { + return this->search_input->OnEvent(event); + } } |
