1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
struct OpenWithProgram {
string name;
string[] command;
}
class Config {
public bool autohide_mouse;
public Vte.CursorShape cursor_shape;
public Vte.CursorBlinkMode cursor_blink;
public Pango.FontDescription font;
public int scrollback;
public bool scrollbar;
public bool allow_hyperlinks;
public Gdk.RGBA? foreground;
public Gdk.RGBA? background;
public Gdk.RGBA? cursor_foreground;
public Gdk.RGBA? cursor_background;
public Gdk.RGBA? selection_foreground;
public Gdk.RGBA? selection_background;
public Gdk.RGBA? bold;
public Gdk.RGBA[] palette = new Gdk.RGBA[16];
public OpenWithProgram[] open_with_programs;
struct PaletteEntry {
string name;
string normal;
string bright;
}
const PaletteEntry[] DEFAULT_PALETTE = {
{ "black", "black", "grey50" },
{ "red", "red3", "red" },
{ "green", "green3", "green" },
{ "yellow", "yellow3", "yellow" },
{ "blue", "blue2", "#5c5cff" },
{ "magenta", "magenta3", "magenta" },
{ "cyan", "cyan3", "cyan" },
{ "white", "grey90", "white" },
};
ConfigReader reader;
public Config() {
reader = new ConfigReader(Path.build_filename(Environment.get_user_config_dir(), PROGRAM_NAME, "config"));
load();
}
public void load() {
autohide_mouse = reader.read_boolean("misc", "autohide-mouse", false);
cursor_shape = reader.read_cursor("misc", "cursor-shape", "block");
cursor_blink = reader.read_blink("misc", "cursor-blink", "system");
font = Pango.FontDescription.from_string(reader.read_string("misc", "font", "Monospace 12"));
scrollback = reader.read_integer("misc", "scrollback", 10000);
scrollbar = reader.read_boolean("misc", "scrollbar", true);
allow_hyperlinks = reader.read_boolean("misc", "allow-hyperlinks", false);
foreground = reader.read_colour("colours", "foreground", null);
background = reader.read_colour("colours", "background", null);
cursor_foreground = reader.read_colour("colours", "cursor.foreground", null);
cursor_background = reader.read_colour("colours", "cursor.background", null);
selection_foreground = reader.read_colour("colours", "cursor.foreground", null);
selection_background = reader.read_colour("colours", "cursor.background", null);
bold = reader.read_colour("colours", "bold", null);
for (int i = 0; i < DEFAULT_PALETTE.length; i++) {
var entry = DEFAULT_PALETTE[i];
palette[i] = reader.read_colour("colours", "normal." + entry.name, entry.normal);
palette[i + 8] = reader.read_colour("colours", "bright." + entry.name, entry.bright);
}
open_with_programs = reader.read_open_with({});
reader.log_unknown_keys();
}
public string[] get_warnings() {
return reader.get_warnings();
}
}
|