Several changes:

* Bump CMake min version to 3.5 (for CMake 4.0)
  * Add banner to main screen
  * Add secret keys option
  * Pin to newest lwsf
This commit is contained in:
Lee Clagett
2025-06-14 00:16:52 -04:00
parent 17c3515759
commit 961d9115dc
4 changed files with 95 additions and 15 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.5.0)
project(lwcli)
enable_language(CXX)
+1 -1
+5 -6
View File
@@ -577,11 +577,10 @@ namespace lwcli { namespace view
for (const auto& elem : stack_)
elements.push_back({elem.first, ftxui::xflex_grow(elem.second->Render())});
//ftxui::hbox({ftxui::text("┃ TWOUI.CIFRO.CODES ┃"), ftxui::filler(), ftxui::text("┃ 2 ┃"), ftxui::filler(), ftxui::text(" ┃ _M_onero ┃")}),
ftxui::Elements out{ //TWOUI.CIFRO.CODES
ftxui::hbox({ftxui::text(" ○━━━━━━━━┓"), ftxui::filler(), ftxui::text(" ○━━━━━┓"), ftxui::filler(), ftxui::text(" ○━━━━━━┓")}),
ftxui::hbox({ftxui::text("┃ cifro.codes ┃"), ftxui::filler(), ftxui::text("┃ z85.pub ┃"), ftxui::filler(), ftxui::text("┃ _M_onero ┃")}),
ftxui::hbox({ftxui::text("┗━━━━━━━━▶ "), ftxui::filler(), ftxui::text("┗━━━━━▶ "), ftxui::filler(), ftxui::text("┗━━━━━━▶ ")}),
ftxui::Elements out{
ftxui::text(" ○━━━━━━━━━━━━━━━━━┓") | ftxui::hcenter,
ftxui::text("┃ lwcli.cifro.codes ┃") | ftxui::hcenter,
ftxui::text("┗━━━━━━━━━━━━━━━━━▶ ") | ftxui::hcenter,
ftxui::separator(),
help_,
disclaimer_,
@@ -592,7 +591,7 @@ namespace lwcli { namespace view
decorate::banner(completion_->Render())
};
if (!state_.error.empty())
out[3] = ftxui::inverted(decorate::banner(ftxui::text(state_.error)));
out[7] = ftxui::inverted(decorate::banner(ftxui::text(state_.error)));
const auto base = ftxui::hcenter(ftxui::xflex_grow(ftxui::vbox(std::move(out))));
if (state_.overlay)
+88 -7
View File
@@ -173,6 +173,53 @@ namespace lwcli { namespace view
}
};
class show_keys_ final : public ftxui::ComponentBase
{
const ftxui::Element title_;
const ftxui::Component buttons_;
const ftxui::Element display_;
bool Focusable() const override final { return true; }
ftxui::Component ActiveChild() override final { return buttons_; }
static ftxui::Element get_keys(const std::shared_ptr<Monero::Wallet>& wal)
{
return ftxui::vbox({
ftxui::paragraph(wal->seed()),
ftxui::separator(),
ftxui::gridbox({
{ftxui::text("View Public: "), ftxui::text(wal->publicViewKey())},
{ftxui::text("Spend Public: "), ftxui::text(wal->publicSpendKey())},
{ftxui::text("View Key: "), ftxui::text(wal->secretViewKey())},
{ftxui::text("Spend Key: "), ftxui::text(wal->secretSpendKey())}
})
});
}
public:
explicit show_keys_(const std::shared_ptr<Monero::Wallet>& wal)
: ftxui::ComponentBase(),
title_(ftxui::text(_("Wallet (Secret) Keys"))),
buttons_(ftxui::Button(_("Close"), [] () { throw event::close{}; }, ascii())),
display_(get_keys(wal))
{}
bool OnEvent(ftxui::Event event) override final
{
buttons_->OnEvent(std::move(event));
return true;
}
ftxui::Element OnRender() override final
{
return ftxui::window(title_, ftxui::vbox({
ftxui::hcenter(buttons_->Render()),
ftxui::separator(),
display_
}));
}
};
class settings_ final : public ftxui::ComponentBase
{
const std::shared_ptr<Monero::Wallet> wal_;
@@ -181,9 +228,16 @@ namespace lwcli { namespace view
std::string error_;
ftxui::Component buttons_;
ftxui::Component ui_;
ftxui::Component overlay_;
ftxui::Element cached_;
bool Focusable() const override final { return true; }
ftxui::Component ActiveChild() override final { return ui_; }
ftxui::Component ActiveChild() override final
{
if (overlay_)
return overlay_;
return ui_;
}
public:
explicit settings_(std::shared_ptr<Monero::Wallet>&& wal)
@@ -193,7 +247,9 @@ namespace lwcli { namespace view
config_(std::make_unique<configuration>(*wal_)),
error_(),
buttons_(),
ui_()
ui_(),
overlay_(),
cached_()
{
buttons_ = ftxui::Container::Horizontal({
ftxui::Button(_("Cancel"), [] () { throw event::close{}; }, ascii()),
@@ -202,7 +258,8 @@ namespace lwcli { namespace view
config_->store(*wal_, error_);
if (error_.empty())
throw event::close{};
}, ascii())
}, ascii()),
ftxui::Button(_("Secret Keys"), [this] () { show_keys(); }, ascii())
});
ftxui::Components ui;
@@ -215,16 +272,39 @@ namespace lwcli { namespace view
Add(ui_);
}
void show_keys()
{
overlay_ = std::make_shared<show_keys_>(wal_);
Add(overlay_);
}
bool OnEvent(ftxui::Event event) override final
{
if (event == ftxui::Event::CtrlQ)
throw event::close{};
ui_->OnEvent(std::move(event));
try
{
if (overlay_)
return overlay_->OnEvent(std::move(event));
else if (event == ftxui::Event::CtrlQ)
throw event::close{};
ui_->OnEvent(std::move(event));
}
catch (const event::close&)
{
if (!overlay_)
throw;
overlay_->Detach();
overlay_.reset();
}
return true;
}
ftxui::Element OnRender() override final
{
if (overlay_)
{
return ftxui::dbox({cached_, decorate::overlay(overlay_->Render())});
}
const auto min_size = ftxui::size(ftxui::WIDTH, ftxui::GREATER_THAN, 5);
std::vector<ftxui::Elements> grid;
grid.reserve(config_->states.size());
@@ -237,11 +317,12 @@ namespace lwcli { namespace view
else
highlighted = ftxui::inverted(ftxui::text(error_));
return ftxui::window(title_, ftxui::vbox({
cached_ = ftxui::window(title_, ftxui::vbox({
ftxui::hcenter(buttons_->Render()),
highlighted,
ftxui::gridbox(std::move(grid))
}));
return cached_;
}
};
}