summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-03-09 13:51:05 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-03-09 13:51:05 +0100
commitddf4126c11823b0563c03bfd13feab6d4d04ccad (patch)
tree713e8988dc5e68cbd6da12abc1815b11a049f2a8
parent9f0bb1262d66fac1f2ca308bde470924e8c48328 (diff)
kmscon: implement dynamic font-resizing via shortcuts
This implements two new keyboard shortcuts zoom-in and zoom-out that increase/decrease font size of the current terminal. This is similar to how wlterm does it and allows runtime modification of fonts. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r--docs/man/kmscon.xml16
-rw-r--r--src/kmscon_conf.c12
-rw-r--r--src/kmscon_conf.h4
-rw-r--r--src/kmscon_terminal.c22
4 files changed, 54 insertions, 0 deletions
diff --git a/docs/man/kmscon.xml b/docs/man/kmscon.xml
index dbe0dcf..7777ede 100644
--- a/docs/man/kmscon.xml
+++ b/docs/man/kmscon.xml
@@ -372,6 +372,22 @@
</varlistentry>
<varlistentry>
+ <term><option>--grab-zoom-in {grab}</option></term>
+ <listitem>
+ <para>Increase font size of the current terminal.
+ (default: &lt;Ctrl&gt;Plus)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--grab-zoom-out {grab}</option></term>
+ <listitem>
+ <para>Decrease font size of the current terminal.
+ (default: &lt;Ctrl&gt;Minus)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--grab-session-next {grab}</option></term>
<listitem>
<para>Switch to next session.
diff --git a/src/kmscon_conf.c b/src/kmscon_conf.c
index 8edd5ee..d960c42 100644
--- a/src/kmscon_conf.c
+++ b/src/kmscon_conf.c
@@ -119,6 +119,10 @@ static void print_help()
"\t Shortcut to scroll page up\n"
"\t --grab-page-down <grab> [<Shift>Next]\n"
"\t Shortcut to scroll page down\n"
+ "\t --grab-zoom-in <grab> [<Ctrl>Plus]\n"
+ "\t Shortcut to increase font size\n"
+ "\t --grab-zoom-out <grab> [<Ctrl>Minus]\n"
+ "\t Shortcut to decrease font size\n"
"\t --grab-session-next <grab> [<Ctrl><Logo>Right]\n"
"\t Switch to next session\n"
"\t --grab-session-prev <grab> [<Ctrl><Logo>Left]\n"
@@ -510,6 +514,12 @@ static struct conf_grab def_grab_page_up =
static struct conf_grab def_grab_page_down =
CONF_SINGLE_GRAB(SHL_SHIFT_MASK, XKB_KEY_Next);
+static struct conf_grab def_grab_zoom_in =
+ CONF_SINGLE_GRAB(SHL_CONTROL_MASK, XKB_KEY_plus);
+
+static struct conf_grab def_grab_zoom_out =
+ CONF_SINGLE_GRAB(SHL_CONTROL_MASK, XKB_KEY_minus);
+
static struct conf_grab def_grab_session_next =
CONF_SINGLE_GRAB(SHL_CONTROL_MASK | SHL_LOGO_MASK, XKB_KEY_Right);
@@ -579,6 +589,8 @@ int kmscon_conf_new(struct conf_ctx **out)
CONF_OPTION_GRAB(0, "grab-scroll-down", &conf->grab_scroll_down, &def_grab_scroll_down),
CONF_OPTION_GRAB(0, "grab-page-up", &conf->grab_page_up, &def_grab_page_up),
CONF_OPTION_GRAB(0, "grab-page-down", &conf->grab_page_down, &def_grab_page_down),
+ CONF_OPTION_GRAB(0, "grab-zoom-in", &conf->grab_zoom_in, &def_grab_zoom_in),
+ CONF_OPTION_GRAB(0, "grab-zoom-out", &conf->grab_zoom_out, &def_grab_zoom_out),
CONF_OPTION_GRAB(0, "grab-session-next", &conf->grab_session_next, &def_grab_session_next),
CONF_OPTION_GRAB(0, "grab-session-prev", &conf->grab_session_prev, &def_grab_session_prev),
CONF_OPTION_GRAB(0, "grab-session-dummy", &conf->grab_session_dummy, &def_grab_session_dummy),
diff --git a/src/kmscon_conf.h b/src/kmscon_conf.h
index b18cc80..4cb4789 100644
--- a/src/kmscon_conf.h
+++ b/src/kmscon_conf.h
@@ -118,6 +118,10 @@ struct kmscon_conf_t {
struct conf_grab *grab_page_up;
/* page-down grab */
struct conf_grab *grab_page_down;
+ /* zoom-in grab */
+ struct conf_grab *grab_zoom_in;
+ /* zoom-out grab */
+ struct conf_grab *grab_zoom_out;
/* session-next grab */
struct conf_grab *grab_session_next;
/* session-prev grab */
diff --git a/src/kmscon_terminal.c b/src/kmscon_terminal.c
index d917fc7..740a27c 100644
--- a/src/kmscon_terminal.c
+++ b/src/kmscon_terminal.c
@@ -426,6 +426,28 @@ static void input_event(struct uterm_input *input,
ev->handled = true;
return;
}
+ if (conf_grab_matches(term->conf->grab_zoom_in,
+ ev->mods, ev->num_syms, ev->keysyms)) {
+ ev->handled = true;
+ if (term->font_attr.points + 1 < term->font_attr.points)
+ return;
+
+ ++term->font_attr.points;
+ if (font_set(term))
+ --term->font_attr.points;
+ return;
+ }
+ if (conf_grab_matches(term->conf->grab_zoom_out,
+ ev->mods, ev->num_syms, ev->keysyms)) {
+ ev->handled = true;
+ if (term->font_attr.points <= 1)
+ return;
+
+ --term->font_attr.points;
+ if (font_set(term))
+ ++term->font_attr.points;
+ return;
+ }
/* TODO: xkbcommon supports multiple keysyms, but it is currently
* unclear how this feature will be used. There is no keymap, which