From 71f9ebaed717f24958b087a666842f6da8cd933b Mon Sep 17 00:00:00 2001 From: trilader Date: Sun, 22 Nov 2020 16:17:14 +0100 Subject: [PATCH] Initial commit --- .gitignore | 4 + main.cpp | 634 +++++++++++++++++++++++++++++++++++++++++++++ tui.cpp | 537 ++++++++++++++++++++++++++++++++++++++ tui.h | 74 ++++++ yt-tool-tui.pro | 23 ++ yt.cpp | 266 +++++++++++++++++++ yt.h | 55 ++++ yttui.conf.example | 6 + 8 files changed, 1599 insertions(+) create mode 100644 .gitignore create mode 100644 main.cpp create mode 100644 tui.cpp create mode 100644 tui.h create mode 100644 yt-tool-tui.pro create mode 100644 yt.cpp create mode 100644 yt.h create mode 100644 yttui.conf.example 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