Skip to content
pi-c Artifact [b1d5a566d6]
Login

Artifact [b1d5a566d6]

Artifact b1d5a566d6425a0acb69ddc79f317f288b4e881454b75e22f6e8c62b1586befe:


/* The themes available to the TUI (themes.c): Pi's dark and light, and custom
 * theme files read through the input reader from the .json files of ~/.pic/themes and,
 * only when the workspace is trusted, of <workspace>/.pic/themes. */
#ifndef PIC_TUI_THEMES_H
#define PIC_TUI_THEMES_H

#include <stddef.h>

#include "theme.h"

typedef struct {
    tui_theme *t; /* dark, light, then the custom themes by name */
    size_t n;
} tui_themeset;

/* Loads every theme. Problems (an invalid file, a name two files claim, the reserved "system") come back as
 * lines of text in *warnings (malloc'd, "" when none; may be NULL to drop them): an invalid file is skipped,
 * and of two themes with one name the first found (user, then project) wins. 0, or -1 when out of memory. */
int tui_themeset_load(tui_themeset *s, const char *home, const char *workspace, int trusted, char **warnings);
void tui_themeset_free(tui_themeset *s);
const tui_theme *tui_themeset_find(const tui_themeset *s, const char *name);

/* The theme name a `theme` setting means in a terminal that is light or dark. Pi's forms: a name; "light/dark"
 * (the first for light terminals); "system" or nothing, which here is Pi's dark or light by the terminal.
 * An invalid setting ("a/b/c") is "system". Written to out; returns out. */
const char *tui_theme_setting_name(const char *setting, int light, char *out, size_t cap);

#endif