aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-20 22:03:02 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-20 22:03:02 -0400
commitf7279faf5c974ed150adad6e30f1e73406e07f8b (patch)
tree4bf465fa36dbc6273f7c595bd890c612c328c28e
parent7a833cb244bb56dc99afe9263074b1c5253c650d (diff)
downloadrunes-f7279faf5c974ed150adad6e30f1e73406e07f8b.tar.gz
runes-f7279faf5c974ed150adad6e30f1e73406e07f8b.zip
allow configuring the default window size
-rw-r--r--config.c19
-rw-r--r--term.h2
-rw-r--r--window-xlib.c4
3 files changed, 23 insertions, 2 deletions
diff --git a/config.c b/config.c
index 66295bb..75dbe8a 100644
--- a/config.c
+++ b/config.c
@@ -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);
diff --git a/term.h b/term.h
index 5dfcfc8..737b352 100644
--- a/term.h
+++ b/term.h
@@ -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();