aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/config.vala
blob: 0234aac116b38e89a24f2b7c57ed577d14723cad (plain) (tree)
1
2
3
4
5
6
7
8
9

              

                                            
                                                


                                          
                                     














                                                     

         









                                                     
 
                            
 


                                                                                                                          

         


                                                                                      
                                                                                   


                                                                                                             
                                                                                          












                                                                                                             
                 
 
                                          

         

                                             

         
 
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];

	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);
		}

		reader.log_unknown_keys();
	}

	public string[] get_warnings() {
		return reader.get_warnings();
	}

}