aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-05-23 14:25:39 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-05-23 14:25:39 +0200
commit076e0e8f5e06ea7f32d8b9ff6f2fcffd261bfa06 (patch)
treef5f35e4637d33c15b256c973cbae8ec9c89c7eb9
parent13369625e79b419172d72c86a21865c35c7133e0 (diff)
downloadgterm-076e0e8f5e06ea7f32d8b9ff6f2fcffd261bfa06.tar.gz
add -geometry option
-rw-r--r--gterm.15
-rw-r--r--gterm.c9
2 files changed, 14 insertions, 0 deletions
diff --git a/gterm.1 b/gterm.1
index 704656a..d4374f9 100644
--- a/gterm.1
+++ b/gterm.1
@@ -33,6 +33,11 @@ Config file key: faceName.
The font size to use.
.br
Config file key: faceSize.
+.TP
+.BI -geometry " WxH"
+The width and height of the terminal window (in columns/rows, not pixels).
+.br
+Config file key: geometry.
\#
\#
.SH "CONFIG FILE"
diff --git a/gterm.c b/gterm.c
index 3c0eb1e..1edee11 100644
--- a/gterm.c
+++ b/gterm.c
@@ -20,6 +20,7 @@
#define GTERM_CFG_KEY_FONT_FACE "faceName"
#define GTERM_CFG_KEY_FONT_SIZE "faceSize"
+#define GTERM_CFG_KEY_GEOMETRY "geometry"
typedef struct gterm_opt {
char *opt;
@@ -30,6 +31,7 @@ typedef struct gterm_opt {
static const gterm_opt gterm_opts[] = {
{ .opt = "fa", .key = GTERM_CFG_KEY_FONT_FACE },
{ .opt = "fs", .key = GTERM_CFG_KEY_FONT_SIZE },
+ { .opt = "geometry", .key = GTERM_CFG_KEY_GEOMETRY },
};
static const gterm_opt *gterm_opt_find(char *arg)
@@ -142,6 +144,8 @@ static void gterm_vte_configure(gterm *gt)
char *fontdesc;
char *fontname;
char *fontsize;
+ char *str;
+ unsigned int cols, rows;
fontname = gterm_cfg_get(gt->cfg, GTERM_CFG_KEY_FONT_FACE);
fontsize = gterm_cfg_get(gt->cfg, GTERM_CFG_KEY_FONT_SIZE);
@@ -160,6 +164,11 @@ static void gterm_vte_configure(gterm *gt)
vte_terminal_set_font(VTE_TERMINAL(gt->terminal), font);
g_free(fontdesc);
}
+
+ str = gterm_cfg_get(gt->cfg, GTERM_CFG_KEY_GEOMETRY);
+ if (str && sscanf(str, "%dx%d", &cols, &rows) == 2) {
+ vte_terminal_set_size(VTE_TERMINAL(gt->terminal), cols, rows);
+ }
}
static void gterm_window_destroy(GtkWidget *widget, gpointer data)