commit 71f9ebaed717f24958b087a666842f6da8cd933b Author: trilader Date: Sun Nov 22 16:17:14 2020 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84e1d89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.conf +*.sqlite +*.pro.user +build-*/ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..183e07c --- /dev/null +++ b/main.cpp @@ -0,0 +1,634 @@ +#define _X_OPEN_SOURCE + +#include "tui.h" +#include "yt.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +static std::string user_home; + +std::vector channels; +std::unordered_map> videos; + +std::optional selected_channel; +size_t current_video_count = 0; +size_t selected_video = 0; +size_t videos_per_page = 0; +size_t current_page_count = 0; +size_t title_offset = 0; +bool any_title_in_next_half = false; + +#define SC(x) { const int res = (x); if(res != SQLITE_OK && res != SQLITE_ROW && res != SQLITE_DONE) { fprintf(stderr, "%s failed: (%d) %s\n", #x, res, sqlite3_errstr(res)); std::abort(); }} + +static termpaint_attr* get_attr(const AttributeSetType type, const bool highlight=false) +{ + return highlight ? attributes[type].highlight : attributes[type].normal; +} + +void draw_channel_list(const std::vector