2026-10-26 22:51:25 +01:00
|
|
|
#include <FL/Fl.H>
|
2026-10-26 23:40:28 +01:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <exception>
|
2026-10-26 22:51:25 +01:00
|
|
|
#include "main_window.hpp"
|
2026-10-27 01:21:04 +01:00
|
|
|
#include "xtc/xtc_version.h"
|
|
|
|
|
#include <cstring>
|
2026-10-26 22:51:25 +01:00
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
2026-10-27 01:21:04 +01:00
|
|
|
if (argc == 2 && !std::strcmp(argv[1], "--version")) {
|
2026-10-27 01:37:21 +01:00
|
|
|
std::printf("%s %s\n", XTC_PROJECT_NAME, XTC_VERSION_STRING);
|
|
|
|
|
return EXIT_SUCCESS;
|
2026-10-27 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
if (argc == 2 && !std::strcmp(argv[1], "--help")) {
|
2026-10-27 01:37:21 +01:00
|
|
|
std::puts(
|
|
|
|
|
"Usage: xtc [PROJECT] or xtc [FLTK options]\n--version and --help work without a display or audio server.");
|
|
|
|
|
return EXIT_SUCCESS;
|
2026-10-27 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
const char *project_path = nullptr;
|
2026-10-27 01:37:21 +01:00
|
|
|
if (argc == 2 && argv[1][0] != '-') {
|
|
|
|
|
project_path = argv[1];
|
|
|
|
|
argc = 1;
|
|
|
|
|
argv[1] = nullptr;
|
|
|
|
|
}
|
2026-10-26 23:40:28 +01:00
|
|
|
try {
|
|
|
|
|
Fl::scheme("flat");
|
|
|
|
|
Fl::background(34, 36, 40);
|
|
|
|
|
Fl::background2(24, 26, 30);
|
|
|
|
|
Fl::foreground(230, 232, 236);
|
|
|
|
|
MainWindow window;
|
2026-10-27 01:21:04 +01:00
|
|
|
if (project_path) {
|
|
|
|
|
xtc_result result = window.open_project(project_path);
|
2026-10-27 01:37:21 +01:00
|
|
|
if (result != XTC_OK) {
|
|
|
|
|
std::fprintf(stderr, "Cannot open project: %s\n", xtc_result_string(result));
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
}
|
2026-10-27 01:21:04 +01:00
|
|
|
}
|
2026-10-26 23:40:28 +01:00
|
|
|
window.show(argc, argv);
|
|
|
|
|
return Fl::run();
|
|
|
|
|
} catch (const std::exception &error) {
|
|
|
|
|
std::fprintf(stderr, "GUI startup/runtime failure: %s\n", error.what());
|
|
|
|
|
} catch (...) {
|
|
|
|
|
std::fputs("Unexpected GUI startup/runtime failure.\n", stderr);
|
|
|
|
|
}
|
|
|
|
|
return EXIT_FAILURE;
|
2026-10-26 22:51:25 +01:00
|
|
|
}
|