You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { Color } from "../util/colors.ts";
|
|
import { ensureDir } from "../util/fs.ts";
|
|
|
|
export interface ColorPair {
|
|
regular: Color,
|
|
bright: Color,
|
|
}
|
|
export const pair = (regular: Color, bright: Color) => ({ regular, bright });
|
|
export interface Colors {
|
|
black: ColorPair,
|
|
red: ColorPair,
|
|
green: ColorPair,
|
|
yellow: ColorPair,
|
|
blue: ColorPair,
|
|
magenta: ColorPair,
|
|
cyan: ColorPair,
|
|
white: ColorPair,
|
|
}
|
|
export interface Conf {
|
|
foreground: Color,
|
|
background: Color,
|
|
selectionForeground: Color,
|
|
selectionBackground: Color,
|
|
cursor: Color,
|
|
cursorTextColor: Color | "background",
|
|
colors: Colors,
|
|
}
|
|
|
|
export const writeConf = async (r: Conf, path: string) => {
|
|
await ensureDir(path);
|
|
|
|
let s = '';
|
|
const l = (n: string, v: string) => `${n} ${v}\n`;
|
|
const c = (c: Color) => c;
|
|
|
|
s += l('foreground', c(r.foreground));
|
|
s += l('background', c(r.background));
|
|
s += l('selection_foreground', c(r.selectionForeground));
|
|
s += l('selection_background', c(r.selectionBackground));
|
|
s += l('cursor', c(r.foreground));
|
|
s += l('cursor_text_color', 'background');
|
|
s += l('color0', r.colors.black.regular);
|
|
s += l('color8', r.colors.black.bright);
|
|
s += l('color1', r.colors.red.regular);
|
|
s += l('color9', r.colors.red.bright);
|
|
s += l('color2', r.colors.green.regular);
|
|
s += l('color10', r.colors.green.bright);
|
|
s += l('color3', r.colors.yellow.regular);
|
|
s += l('color11', r.colors.yellow.bright);
|
|
s += l('color4', r.colors.blue.regular);
|
|
s += l('color12', r.colors.blue.bright);
|
|
s += l('color5', r.colors.magenta.regular);
|
|
s += l('color13', r.colors.magenta.bright);
|
|
s += l('color6', r.colors.cyan.regular);
|
|
s += l('color14', r.colors.cyan.bright);
|
|
s += l('color7', r.colors.white.regular);
|
|
s += l('color15', r.colors.white.bright);
|
|
|
|
return Deno.writeTextFile(path, s);
|
|
}
|