make vte font resizable

Work around unexposed interface. Ideally, imho, should be exposed by
VteTerminal itself.

This closes #45
This commit is contained in:
Simon Gomizelj 2012-11-30 11:56:00 -05:00
parent 27ccafdf77
commit ecc402414b
3 changed files with 27 additions and 1 deletions

View File

@ -113,6 +113,10 @@ COMMAND MODE
+------------------------+-----------------------------------------------------------+ +------------------------+-----------------------------------------------------------+
| ``N`` | previous search match | | ``N`` | previous search match |
+------------------------+-----------------------------------------------------------+ +------------------------+-----------------------------------------------------------+
| ``+`` | increase font size |
+------------------------+-----------------------------------------------------------+
| ``-`` | decrease font size |
+------------------------+-----------------------------------------------------------+
During scrollback search, the current selection is changed to the search match During scrollback search, the current selection is changed to the search match
and copied to the PRIMARY clipboard buffer. and copied to the PRIMARY clipboard buffer.

View File

@ -530,6 +530,22 @@ void window_title_cb(VteTerminal *vte, gboolean *dynamic_title) {
title ? title : "termite"); title ? title : "termite");
} }
static void update_font_size(VteTerminal *vte, int update) {
const PangoFontDescription *vte_desc = vte_terminal_get_font(vte);
PangoFontDescription *font_desc = pango_font_description_copy(vte_desc);
bool abs = pango_font_description_get_size_is_absolute(font_desc);
int size = pango_font_description_get_size(font_desc);
if (!abs)
update *= PANGO_SCALE;
size += update;
pango_font_description_set_size(font_desc, size);
vte_terminal_set_font(vte, font_desc);
pango_font_description_free(font_desc);
}
gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info) { gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info) {
const guint modifiers = event->state & gtk_accelerator_get_default_mod_mask(); const guint modifiers = event->state & gtk_accelerator_get_default_mod_mask();
if (info->select.mode != vi_mode::insert) { if (info->select.mode != vi_mode::insert) {
@ -655,6 +671,12 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
gtk_widget_show(info->panel.da); gtk_widget_show(info->panel.da);
overlay_show(&info->panel, overlay_mode::urlselect, false); overlay_show(&info->panel, overlay_mode::urlselect, false);
break; break;
case GDK_KEY_plus:
update_font_size(vte, 1);
break;
case GDK_KEY_minus:
update_font_size(vte, -1);
break;
} }
return TRUE; return TRUE;
} }

2
util

@ -1 +1 @@
Subproject commit 2a1badeeec68c0cd22ec111cfd376883100e6f43 Subproject commit d7ca0bd7dbe371e86fcd53bbce157d9454ce1574