From bb87de3e03fc4c777b2caefd2c367317342948d4 Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Fri, 13 Mar 2026 21:15:27 -0400 Subject: [PATCH] Various bug and compilation fixes --- src/components/table.cpp | 1 + src/main.cpp | 4 +++- src/views/accounts.cpp | 1 + src/views/history.cpp | 37 +++++++++++++++++-------------------- src/views/wallet.cpp | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/components/table.cpp b/src/components/table.cpp index aa0c072..1dd3b11 100644 --- a/src/components/table.cpp +++ b/src/components/table.cpp @@ -26,6 +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. +#include #include #include #include diff --git a/src/main.cpp b/src/main.cpp index 969977b..5f2e9fb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +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. +#include #include #include #include @@ -289,7 +290,8 @@ int main(int, const char* argv[]) auto window = ftxui::CatchEvent(lwcli::view::manager(std::move(wm), std::move(prog.file)), [&] (ftxui::Event event) { - state.last_event = std::chrono::steady_clock::now().time_since_epoch().count(); + if (event != lwcli::event::refresh_wallet) + state.last_event = std::chrono::steady_clock::now().time_since_epoch().count(); if (event == ftxui::Event::CtrlC) { state.screen.ExitLoopClosure()(); diff --git a/src/views/accounts.cpp b/src/views/accounts.cpp index c80c06d..2a2a528 100644 --- a/src/views/accounts.cpp +++ b/src/views/accounts.cpp @@ -28,6 +28,7 @@ #include "wallet.h" +#include #include #include #include diff --git a/src/views/history.cpp b/src/views/history.cpp index 151b944..9c2e2fe 100644 --- a/src/views/history.cpp +++ b/src/views/history.cpp @@ -64,10 +64,12 @@ namespace lwcli { namespace view std::string hash_; std::vector transfers_; ftxui::Component note_input_; - const ftxui::Component cancel_; - ftxui::Component ok_; + ftxui::Component buttons_; ftxui::Component container_; + bool Focusable() const override final { return true; } + ftxui::Component ActiveChild() override final { return container_; } + bool OnEvent(ftxui::Event event) override final { if (event == event::refresh_wallet) @@ -79,7 +81,7 @@ namespace lwcli { namespace view virtual ftxui::Element OnRender() override final { - ftxui::Element buttons = ftxui::hcenter(ftxui::hbox(cancel_->Render(), ok_->Render())); + auto buttons = ftxui::hcenter(buttons_->Render()); if (!info_) { return ftxui::window( @@ -128,7 +130,7 @@ namespace lwcli { namespace view }; const std::size_t base_size = grid.size(); - for (const auto& transfer : transfers_) + for (const auto& transfer : info_->transfers()) { const std::string address = transfer.address.empty() ? std::string{_(" to Unknown Address")} : _(" to ") + transfer.address; @@ -159,13 +161,7 @@ namespace lwcli { namespace view bool on_refresh(const Monero::TransactionInfo* info) { - transfers_.clear(); info_ = info; - if (!info_) - return true; - - const auto& transfers = info->transfers(); - std::copy(transfers.begin(), transfers.end(), std::back_inserter(transfers_)); return true; } @@ -177,8 +173,7 @@ namespace lwcli { namespace view hash_(), transfers_(), note_input_(nullptr), - cancel_(ftxui::Button(_("Cancel"), [] () { throw event::close{}; }, ftxui::ButtonOption::Ascii())), - ok_(nullptr), + buttons_(), container_() { if (!history_) @@ -190,17 +185,19 @@ namespace lwcli { namespace view note_ = info->description(); auto options = ftxui::InputOption::Default(); options.cursor_position = note_.size(); + options.multiline = false; note_input_ = ftxui::Input(¬e_, std::move(options)); - ok_ = ftxui::Button(_("OK"), [this] () { - history_->setTxNote(hash_, note_); - throw event::close{}; - }, ftxui::ButtonOption::Ascii()); - - container_ = ftxui::Container::Vertical({ - ftxui::Container::Horizontal({cancel_, ok_}), - note_input_ + buttons_ = ftxui::Container::Horizontal({ + ftxui::Button(_("Cancel"), [] () { throw event::close{}; }, ftxui::ButtonOption::Ascii()), + ftxui::Button(_("OK"), [this] () { + history_->setTxNote(hash_, note_); + throw event::close{}; + }, ftxui::ButtonOption::Ascii()) }); + + container_ = ftxui::Container::Vertical({buttons_, note_input_}); + Add(container_); } }; diff --git a/src/views/wallet.cpp b/src/views/wallet.cpp index 890aaf2..1000abe 100644 --- a/src/views/wallet.cpp +++ b/src/views/wallet.cpp @@ -83,7 +83,7 @@ namespace lwcli { namespace view ftxui::Component ActiveChild() override final { if (state_.overlay) - return state_.overlay; + return state_.overlay; return ui_; }