diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-04-20 22:03:02 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-04-20 22:03:02 -0400 |
commit | f7279faf5c974ed150adad6e30f1e73406e07f8b (patch) | |
tree | 4bf465fa36dbc6273f7c595bd890c612c328c28e | |
parent | 7a833cb244bb56dc99afe9263074b1c5253c650d (diff) | |
download | runes-f7279faf5c974ed150adad6e30f1e73406e07f8b.tar.gz runes-f7279faf5c974ed150adad6e30f1e73406e07f8b.zip |
allow configuring the default window size
-rw-r--r-- | config.c | 19 | ||||
-rw-r--r-- | term.h | 2 | ||||
-rw-r--r-- | window-xlib.c | 4 |
3 files changed, 23 insertions, 2 deletions
@@ -9,6 +9,7 @@ static FILE *runes_config_get_config_file(); static void runes_config_process_config_file(RunesTerm *t, FILE *config_file); static void runes_config_set(RunesTerm *t, char *key, char *value); static char runes_config_parse_bool(char *val); +static int runes_config_parse_uint(char *val); static char *runes_config_parse_string(char *val); static cairo_pattern_t *runes_config_parse_color(char *val); @@ -31,6 +32,9 @@ static void runes_config_set_defaults(RunesTerm *t) t->fgdefault = cairo_pattern_create_rgb(0.827, 0.827, 0.827); t->bgdefault = cairo_pattern_create_rgb(0.0, 0.0, 0.0); + + t->default_rows = 24; + t->default_cols = 80; } static FILE *runes_config_get_config_file() @@ -144,6 +148,12 @@ static void runes_config_set(RunesTerm *t, char *key, char *val) t->fgdefault = newcolor; } } + else if (!strcmp(key, "rows")) { + t->default_rows = runes_config_parse_uint(val); + } + else if (!strcmp(key, "cols")) { + t->default_cols = runes_config_parse_uint(val); + } else { fprintf(stderr, "unknown option: '%s'\n", key); } @@ -163,6 +173,15 @@ static char runes_config_parse_bool(char *val) } } +static int runes_config_parse_uint(char *val) +{ + if (strspn(val, "0123456789") != strlen(val)) { + fprintf(stderr, "unknown unsigned integer value: '%s'\n", val); + } + + return atoi(val); +} + static char *runes_config_parse_string(char *val) { return strdup(val); @@ -33,6 +33,8 @@ struct runes_term { int ypixel; int fontx; int fonty; + int default_rows; + int default_cols; char *font_name; PangoLayout *layout; diff --git a/window-xlib.c b/window-xlib.c index 1842ff4..70cbf22 100644 --- a/window-xlib.c +++ b/window-xlib.c @@ -110,8 +110,8 @@ void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[]) normal_hints.min_height = t->fonty; normal_hints.width_inc = t->fontx; normal_hints.height_inc = t->fonty; - normal_hints.base_width = t->fontx * 80; - normal_hints.base_height = t->fonty * 24; + normal_hints.base_width = t->fontx * t->default_cols; + normal_hints.base_height = t->fonty * t->default_rows; XInitThreads(); |