diff options
author | ComradeCrow <comradecrow@vivaldi.net> | 2023-04-12 15:21:44 -0700 |
---|---|---|
committer | ComradeCrow <comradecrow@vivaldi.net> | 2023-04-12 15:21:44 -0700 |
commit | 87d0da3a93b7f596ecfd62886efb2f1d965be0dd (patch) | |
tree | 9b94607b66eb59d1695b70ba47ba35628c3f7060 | |
parent | 9d53072e32c60aa51784182a0a608ce204cab9e6 (diff) | |
download | ytcpp-87d0da3a93b7f596ecfd62886efb2f1d965be0dd.tar.gz |
fix problems
some of them
-rw-r--r-- | src/YtdlpWrapper.cpp | 2 | ||||
-rw-r--r-- | src/YtdlpWrapper.hpp | 5 | ||||
-rw-r--r-- | src/invapi.cpp | 2 | ||||
-rw-r--r-- | src/invapi.hpp | 5 | ||||
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/tui.cpp | 7 | ||||
-rw-r--r-- | src/tui.hpp | 8 |
7 files changed, 18 insertions, 16 deletions
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<std::string>()); + return json::parse(static_cast<std::string>(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 <string> #include <pybind11/embed.h> #include <nlohmann/json.hpp> 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 <cpr/cpr.h> #include <nlohmann/json.hpp> +#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 <string> #include <vector> 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 <vector> #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 <string> #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}; }; |