<commit_before>#include <vte/vte.h>
#include <gdk/gdk.h>
#include "solarized_palette.h"
#include "term.h"


#if VTE_CHECK_VERSION(0,37,0)
static void got_child_exited(VteTerminal *vte, gint status, MarmiteHooks *hooks) {
#else
static void got_child_exited(VteTerminal *vte, MarmiteHooks *hooks) {
#endif
    if (hooks->all_done)
        hooks->all_done(hooks->data);
}

static void got_title_changed(VteTerminal *vte, MarmiteHooks *hooks) {
    if (hooks->set_title)
        hooks->set_title(hooks->data, vte_terminal_get_window_title(vte));
}


GObject *marmite_vte(MarmiteConfig *cfg, MarmiteHooks *hooks) {
    VteTerminal *vte = VTE_TERMINAL(vte_terminal_new());

    PangoFontDescription *font = pango_font_description_from_string(cfg->font);
    vte_terminal_set_font(vte, font);
    pango_font_description_free(font);

    vte_terminal_set_scrollback_lines(vte, cfg->scrollback);
    vte_terminal_set_mouse_autohide(vte, TRUE);

    if (hooks) {
        g_signal_connect(G_OBJECT(vte), "child-exited", G_CALLBACK(got_child_exited), hooks);
        g_signal_connect(G_OBJECT(vte), "window-title-changed", G_CALLBACK(got_title_changed), hooks);
    }

#if VTE_CHECK_VERSION(0,37,0)
    vte_terminal_set_colors(vte,
            &solarized_palette[solarized_mode[cfg->colour_mode].fg], &solarized_palette[solarized_mode[cfg->colour_mode].bg],
            solarized_palette, solarized_palette_size);
    vte_terminal_spawn_sync(vte, VTE_PTY_DEFAULT, NULL, cfg->command,
            NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, NULL);
#else
    vte_terminal_set_colors_rgba(vte,
            &solarized_palette[solarized_mode[cfg->colour_mode].fg], &solarized_palette[solarized_mode[cfg->colour_mode].bg],
            solarized_palette, solarized_palette_size);
    vte_terminal_fork_command_full(vte, VTE_PTY_DEFAULT, NULL, cfg->command,
            NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
#endif

    return G_OBJECT(vte);
}
<commit_msg>increase or decrease font size with keys<commit_after>#include <vte/vte.h>
#include <gdk/gdk.h>
#include "solarized_palette.h"
#include "term.h"


#if VTE_CHECK_VERSION(0,37,0)
static void got_child_exited(VteTerminal *vte, gint status, MarmiteHooks *hooks) {
#else
static void got_child_exited(VteTerminal *vte, MarmiteHooks *hooks) {
#endif
    if (hooks->all_done)
        hooks->all_done(hooks->data);
}

static void got_title_changed(VteTerminal *vte, MarmiteHooks *hooks) {
    if (hooks->set_title)
        hooks->set_title(hooks->data, vte_terminal_get_window_title(vte));
}

static void scale_font(VteTerminal *vte, gdouble *increment) {
    gdouble scale = vte_terminal_get_font_scale(vte);
    scale += *increment;
    if (scale >= 0.25 && scale <= 4.0)
        vte_terminal_set_font_scale(vte, scale);
}

GObject *marmite_vte(MarmiteConfig *cfg, MarmiteHooks *hooks) {
    VteTerminal *vte = VTE_TERMINAL(vte_terminal_new());

    PangoFontDescription *font = pango_font_description_from_string(cfg->font);
    vte_terminal_set_font(vte, font);
    pango_font_description_free(font);

    vte_terminal_set_scrollback_lines(vte, cfg->scrollback);
    vte_terminal_set_mouse_autohide(vte, TRUE);

    if (hooks) {
        g_signal_connect(G_OBJECT(vte), "child-exited", G_CALLBACK(got_child_exited), hooks);
        g_signal_connect(G_OBJECT(vte), "window-title-changed", G_CALLBACK(got_title_changed), hooks);
    }

    static const gdouble increase = 0.25, decrease = -0.25;
    g_signal_connect(G_OBJECT(vte), "increase-font-size", G_CALLBACK(scale_font), (gpointer)&increase);
    g_signal_connect(G_OBJECT(vte), "decrease-font-size", G_CALLBACK(scale_font), (gpointer)&decrease);

#if VTE_CHECK_VERSION(0,37,0)
    vte_terminal_set_colors(vte,
            &solarized_palette[solarized_mode[cfg->colour_mode].fg], &solarized_palette[solarized_mode[cfg->colour_mode].bg],
            solarized_palette, solarized_palette_size);
    vte_terminal_spawn_sync(vte, VTE_PTY_DEFAULT, NULL, cfg->command,
            NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, NULL);
#else
    vte_terminal_set_colors_rgba(vte,
            &solarized_palette[solarized_mode[cfg->colour_mode].fg], &solarized_palette[solarized_mode[cfg->colour_mode].bg],
            solarized_palette, solarized_palette_size);
    vte_terminal_fork_command_full(vte, VTE_PTY_DEFAULT, NULL, cfg->command,
            NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
#endif

    return G_OBJECT(vte);
}

{'fraction_non_alphanumeric': 0.11886537595677622, 'fraction_numerical': 0.006078343088698784, 'mean_word_length': 5.145228215767635, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1926150', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1711, 'n_words': 247}