diff options
| -rw-r--r-- | guix.scm | 8 | ||||
| -rw-r--r-- | src/main.c | 27 |
2 files changed, 35 insertions, 0 deletions
@@ -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 @@ -3,10 +3,12 @@ #include "font.h" #include "media.h" #include "render.h" +#include "util.h" #include <GLFW/glfw3.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #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"); |
