Browse Source

Move almost all of main.cpp to application.cpp and add standalone yttui.cpp

main
Daniel Schulte 12 months ago
parent
commit
9ae8dff7d9
  1. 25
      application.cpp
  2. 4
      application.h
  3. 14
      meson.build
  4. 7
      yttui.cpp

25
main.cpp → application.cpp

@ -491,7 +491,12 @@ void action_scroll_title_right() {
}
void action_show_video_detail() {
message_box("Details", "Video details go here...");
const size_t cols = termpaint_surface_width(surface);
const Channel &ch = channels.at(selected_channel);
const Video &selected = videos[ch.id][selected_video];
message_box("Description", text_wrap(selected.description, cols / 8 * 7));
//message_box("Description", selected.description);
}
using json = nlohmann::json;
@ -549,14 +554,13 @@ void config_get_string_list(std::vector<std::string> &buffer, const json &obj, c
}
}
int main()
static void run()
{
const std::string module_path = get_module_path();
user_home = std::string(std::getenv("HOME"));
std::string database_filename = user_home + "/.local/share/yttui.db";
curl_global_init(CURL_GLOBAL_ALL);
tp_init();
const std::vector<std::string> config_locations{user_home + "/.config", module_path};
std::string config_file;
@ -665,9 +669,20 @@ int main()
}
} while (!exit);
tp_shutdown();
db_shutdown();
curl_global_cleanup();
}
void run_standalone()
{
tp_init();
run();
tp_shutdown();
}
return 0;
void run_embedded(int pty_fd)
{
tp_init_from_fd(pty_fd);
run();
tp_shutdown();
}

4
application.h

@ -0,0 +1,4 @@
#pragma once
void run_standalone();
void run_embedded(int pty_fd);

14
meson.build

@ -9,18 +9,24 @@ curl_dep = dependency('libcurl')
json_dep = dependency('nlohmann_json', version: '>=3.5.0')
#ide:editable-filelist
src_files = [
application_files = [
'application.cpp',
'db.cpp',
'main.cpp',
'tui.cpp',
'yt.cpp',
]
deps = [
#ide:editable-filelist
application_deps = [
termpaint_dep,
sqlite3_dep,
curl_dep,
json_dep
]
executable('yttui', src_files, dependencies: deps, install: true)
application = static_library('yttui-application', application_files, dependencies: application_deps)
tui_files = [
'yttui.cpp',
]
executable('yttui', tui_files, link_with: [application], install: true)

7
yttui.cpp

@ -0,0 +1,7 @@
#include "application.h"
int main(int, char *[])
{
run_standalone();
return 0;
}
Loading…
Cancel
Save