From 87d0da3a93b7f596ecfd62886efb2f1d965be0dd Mon Sep 17 00:00:00 2001 From: ComradeCrow Date: Wed, 12 Apr 2023 15:21:44 -0700 Subject: fix problems some of them --- src/YtdlpWrapper.cpp | 2 +- src/YtdlpWrapper.hpp | 5 ++--- src/invapi.cpp | 2 ++ src/invapi.hpp | 5 ++--- src/main.cpp | 5 +++-- src/tui.cpp | 7 ++++--- src/tui.hpp | 8 ++++---- 7 files changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/YtdlpWrapper.cpp b/src/YtdlpWrapper.cpp index ee799e0..e0598a0 100644 --- a/src/YtdlpWrapper.cpp +++ b/src/YtdlpWrapper.cpp @@ -16,6 +16,6 @@ YtdlpWrapper::YtdlpWrapper() { json YtdlpWrapper::getJsonSearch(const string& searchTerm) { const auto info = ytdl.attr("extract_info")("ytsearch:"+searchTerm, "download"_a=py::bool_(false)); - return json::parse(info.cast()); + return json::parse(static_cast(info)); } diff --git a/src/YtdlpWrapper.hpp b/src/YtdlpWrapper.hpp index 1e31569..a9522ea 100644 --- a/src/YtdlpWrapper.hpp +++ b/src/YtdlpWrapper.hpp @@ -1,6 +1,5 @@ -#ifndef YtdlpWrapper -#define YtdlpWrapper -#include "YtdlpWrapper.cpp" +#ifndef YTDLPWRAPPER_H +#define YTDLPWRAPPER_H #include #include #include diff --git a/src/invapi.cpp b/src/invapi.cpp index d56e701..47a9575 100644 --- a/src/invapi.cpp +++ b/src/invapi.cpp @@ -4,6 +4,8 @@ #include #include +#include "invapi.hpp" + using namespace std; using json = nlohmann::json; diff --git a/src/invapi.hpp b/src/invapi.hpp index e5c97d4..2d3357c 100644 --- a/src/invapi.hpp +++ b/src/invapi.hpp @@ -1,6 +1,5 @@ -#ifndef invapi -#define invapi -#include "invapi.cpp" +#ifndef INVAPI_H +#define INVAPI_H #include #include diff --git a/src/main.cpp b/src/main.cpp index 5bc7679..4267a73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,8 +7,8 @@ #include #include "tui.cpp" -#include "invapi.hpp" -#include "YtdlpWrapper.hpp" +#include "invapi.cpp" +// #include "YtdlpWrapper.cpp" using namespace std; @@ -21,6 +21,7 @@ int main() { tui.renderSearchBar(searchTerm, searchingFor); if (tui.isCancelled()) { + cerr << "cancelled!" << endl; return 0; } cout << searchTerm << "," << searchingFor << endl; diff --git a/src/tui.cpp b/src/tui.cpp index 8356c81..601f468 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -15,6 +15,7 @@ using namespace std; bool Tui::renderSearchBar(string& searchTerm, int& searchingFor) { + cancel = false; auto screen = ftxui::ScreenInteractive::Fullscreen(); @@ -26,7 +27,7 @@ bool Tui::renderSearchBar(string& searchTerm, int& searchingFor) { ftxui::Component selectSearchFor = ftxui::Toggle(&searchingForOptions, &searchingFor); string cancelLabel = "Cancel"; - ftxui::Component cancelButton = ftxui::Button(&cancelLabel, screen.ExitLoopClosure()); + ftxui::Component cancelButton = ftxui::Button(&cancelLabel, cancelAndExit(screen)); string searchLabel = "Search"; ftxui::Component searchButton = ftxui::Button(&searchLabel, screen.ExitLoopClosure()); @@ -67,8 +68,8 @@ bool Tui::isCancelled() { return cancel; } -void Tui::cancelAndExit(ftxui::ScreenInteractive& screen) { +ftxui::Closure Tui::cancelAndExit(ftxui::ScreenInteractive& screen) { cancel = true; - screen.ExitLoopClosure(); + return screen.ExitLoopClosure(); } \ No newline at end of file diff --git a/src/tui.hpp b/src/tui.hpp index af4d24c..112135c 100644 --- a/src/tui.hpp +++ b/src/tui.hpp @@ -1,5 +1,5 @@ -#ifndef Tui -#define Tui +#ifndef TUI_H +#define TUI_H #include #include "ftxui/component/captured_mouse.hpp" // for ftxui #include "ftxui/component/component.hpp" // for Input, Renderer, Vertical @@ -14,8 +14,8 @@ class Tui { bool renderSearchBar(std::string&, int&); bool isCancelled(); private: - void cancelAndExit(ftxui::ScreenInteractive&); - bool cancel; + ftxui::Closure cancelAndExit(ftxui::ScreenInteractive&); + bool cancel{false}; }; -- cgit 1.4.1-2-gfad0