Skip to content
pi-c Documentation
Login

Documentation

/* 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