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"
|
2026-10-27 06:44:22 +01:00
|
|
|
#include "xtc/xtc.h"
|
2026-10-27 01:21:04 +01:00
|
|
|
#include <cstring>
|
2026-10-26 22:51:25 +01:00
|
|
|
|
2026-10-27 01:58:27 +01:00
|
|
|
/**
|
|
|
|
|
* @brief Runs the FLTK application and reports command-line or startup failures.
|
|
|
|
|
*
|
|
|
|
|
* @param argc Number of command-line arguments including the program name.
|
|
|
|
|
* @param argv Command-line argument vector.
|
|
|
|
|
* @return EXIT_SUCCESS after the event loop exits, or EXIT_FAILURE for invalid usage or startup failure.
|
|
|
|
|
*/
|
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
|
|
|
}
|
2026-10-27 06:44:22 +01:00
|
|
|
if (argc == 2 && !std::strcmp(argv[1], "--diagnose")) {
|
|
|
|
|
unsigned int features = xtc_build_features();
|
|
|
|
|
std::printf("xtc %s; project formats 1..%u; JACK %s; LADSPA %s\nFor limits and recovery commands run xtc-check --diagnose/--help.\n",
|
|
|
|
|
XTC_VERSION_STRING,XTC_PROJECT_FORMAT_VERSION,features & XTC_FEATURE_JACK ? "compiled" : "disabled",
|
|
|
|
|
features & XTC_FEATURE_LADSPA ? "compiled" : "disabled");
|
|
|
|
|
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(
|
2026-10-27 06:44:22 +01:00
|
|
|
"Usage: xtc [PROJECT] or xtc [FLTK options]\n--version, --diagnose and --help work without a display or audio server.");
|
2026-10-27 01:37:21 +01:00
|
|
|
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
|
|
|
}
|