From c1ccd38b31d722c843ab311338e2b8d1905eb8f8 Mon Sep 17 00:00:00 2001 From: David Moc Date: Wed, 3 Jun 2026 03:22:35 +0200 Subject: Default config and fixed installing. --- guix.scm | 8 ++++++++ src/main.c | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/guix.scm b/guix.scm index bd2d244..6b312f7 100644 --- a/guix.scm +++ b/guix.scm @@ -2,6 +2,7 @@ (guix build-system gnu) (guix gexp) ((guix licenses) #:prefix license:) + (guix search-paths) (gnu packages fonts) (gnu packages gl) (gnu packages llvm) @@ -65,6 +66,13 @@ `(("font-dejavu" ,font-dejavu) ("glfw" ,glfw) ("mesa" ,mesa))) + (native-search-paths + (list (search-path-specification + (variable "C_INCLUDE_PATH") + (files '("include/ecex"))) + (search-path-specification + (variable "CPLUS_INCLUDE_PATH") + (files '("include/ecex"))))) (home-page "git.cdatgoose.org/ecex.git") (synopsis "Small C editor with CCDJIT-loaded C config and plugins") (description diff --git a/src/main.c b/src/main.c index 191a159..b3e7af4 100644 --- a/src/main.c +++ b/src/main.c @@ -3,10 +3,12 @@ #include "font.h" #include "media.h" #include "render.h" +#include "util.h" #include #include +#include #include #define WINDOW_WIDTH 1000 @@ -24,6 +26,9 @@ static void print_usage(const char *argv0) { fprintf(stderr, "env:\n"); fprintf(stderr, " ECEX_FONT=/path/to/font.ttf\n"); fprintf(stderr, " ECEX_INCLUDE=/path/to/ecex/include\n"); + fprintf(stderr, "\n"); + fprintf(stderr, "default config:\n"); + fprintf(stderr, " ~/.config/ecex/ecexrc.c\n"); } static int parse_args(int argc, @@ -66,6 +71,24 @@ static const char *select_font_path(ecex_t *ed, const char *font_path_arg) { return font_choose_path(NULL); } +static const char *find_default_config_path(void) { + static char path[4096]; + + const char *xdg_config = getenv("XDG_CONFIG_HOME"); + if (xdg_config && xdg_config[0]) { + snprintf(path, sizeof(path), "%s/ecex/ecexrc.c", xdg_config); + if (ecex_file_exists(path)) return path; + } + + const char *home = getenv("HOME"); + if (home && home[0]) { + snprintf(path, sizeof(path), "%s/.config/ecex/ecexrc.c", home); + if (ecex_file_exists(path)) return path; + } + + return NULL; +} + int main(int argc, char **argv) { const char *config_path = NULL; const char *font_path_arg = NULL; @@ -81,6 +104,10 @@ int main(int argc, char **argv) { return 1; } + if (!config_path) { + config_path = find_default_config_path(); + } + if (config_path) { if (ecex_load_c_config(ed, config_path) != 0) { fprintf(stderr, "ecex: continuing without config\n"); -- cgit v1.2.3