Exemple #1
0
void
term_set_font(GtkWidget *win, VteTerminal *term, size_t index)
{
    PangoFontDescription *font_desc = NULL;
    glong width, height;

    if (index >= sizeof fonts / sizeof fonts[0])
    {
        fprintf(stderr, __NAME__": Warning: Invalid font index\n");
        return;
    }

    width = vte_terminal_get_column_count(term);
    height = vte_terminal_get_row_count(term);

    font_desc = pango_font_description_from_string(fonts[index]);
    vte_terminal_set_font(term, font_desc);
    pango_font_description_free(font_desc);
    vte_terminal_set_font_scale(term, 1);

    term_set_size(win, term, width, height);

    if (win != NULL)
        vte_terminal_set_geometry_hints_for_window(VTE_TERMINAL(term),
                                                   GTK_WINDOW(win));
}
Exemple #2
0
static void
adjust_font_size(GtkWidget *widget, gpointer data, gdouble factor)
{
	VteTerminal *terminal;
        gdouble scale;
        glong char_width, char_height;
	gint columns, rows, owidth, oheight;

	/* Read the screen dimensions in cells. */
	terminal = VTE_TERMINAL(widget);
	columns = vte_terminal_get_column_count(terminal);
	rows = vte_terminal_get_row_count(terminal);

	/* Take into account padding and border overhead. */
	gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
        char_width = vte_terminal_get_char_width (terminal);
        char_height = vte_terminal_get_char_height (terminal);
	owidth -= char_width * columns;
	oheight -= char_height * rows;

	scale = vte_terminal_get_font_scale(terminal);
        vte_terminal_set_font_scale(terminal, scale * factor);

        /* This above call will have changed the char size! */
        char_width = vte_terminal_get_char_width (terminal);
        char_height = vte_terminal_get_char_height (terminal);

	gtk_window_resize(GTK_WINDOW(data),
			  columns * char_width + owidth,
			  rows * char_height + oheight);
}
Exemple #3
0
void
term_set_font_scale(GtkWidget *win, VteTerminal *term, gdouble mult)
{
    gdouble s;
    glong width, height;

    width = vte_terminal_get_column_count(term);
    height = vte_terminal_get_row_count(term);

    s = vte_terminal_get_font_scale(term);
    s *= mult;
    vte_terminal_set_font_scale(term, s);
    term_set_size(win, term, width, height);
    vte_terminal_set_geometry_hints_for_window(VTE_TERMINAL(term),
                                               GTK_WINDOW(win));
}
Exemple #4
0
gboolean
sig_key_press(GtkWidget *widget, GdkEvent *event, gpointer data)
{
    VteTerminal *term = VTE_TERMINAL(widget);
    GtkWidget *win = (GtkWidget *)data;

    if (((GdkEventKey *)event)->state & GDK_CONTROL_MASK)
    {
        switch (((GdkEventKey *)event)->keyval)
        {
            case GDK_KEY_C:
                vte_terminal_copy_clipboard(term);
                return TRUE;
            case GDK_KEY_V:
                vte_terminal_paste_clipboard(term);
                return TRUE;
            case GDK_KEY_KP_0:
                vte_terminal_set_font_scale(term, 1);
                vte_terminal_set_geometry_hints_for_window(VTE_TERMINAL(term),
                                                           GTK_WINDOW(win));
                return TRUE;

            case GDK_KEY_KP_1: term_set_font(win, term, 0); return TRUE;
            case GDK_KEY_KP_2: term_set_font(win, term, 1); return TRUE;
            case GDK_KEY_KP_3: term_set_font(win, term, 2); return TRUE;
            case GDK_KEY_KP_4: term_set_font(win, term, 3); return TRUE;
            case GDK_KEY_KP_5: term_set_font(win, term, 4); return TRUE;
            case GDK_KEY_KP_6: term_set_font(win, term, 5); return TRUE;
            case GDK_KEY_KP_7: term_set_font(win, term, 6); return TRUE;
            case GDK_KEY_KP_8: term_set_font(win, term, 7); return TRUE;
            case GDK_KEY_KP_9: term_set_font(win, term, 8); return TRUE;
        }
    }

    return FALSE;
}
Exemple #5
0
 void terminal::set_font_scale(double i_font_scale) {
   if ( m_terminal != NULL && i_font_scale > 0 )
     vte_terminal_set_font_scale(m_terminal, i_font_scale);
 }