From d1f54e57fc8987d852c6263833971630ab334fff Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 7 Jun 2012 13:36:03 -0400 Subject: [PATCH] move cursor_blink and cursor_shape to the config --- config.h | 3 --- termite.c | 27 ++++++++++++++++++++++++--- termite.cfg | 6 ++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/config.h b/config.h index a4455d9..794606e 100644 --- a/config.h +++ b/config.h @@ -35,9 +35,6 @@ static const char *colors[16] = { "#ffffff", // bright white }; -#define CURSOR_BLINK SYSTEM // SYSTEM, ON or OFF -#define CURSOR_SHAPE BLOCK // BLOCK, UNDERLINE or IBEAM - static const char *term = "vte-256color"; // keybindings diff --git a/termite.c b/termite.c index 602a7ca..0f39e1c 100644 --- a/termite.c +++ b/termite.c @@ -294,6 +294,30 @@ static void load_config(GtkWindow *window, VteTerminal *vte) { IGNORE_ON_ERROR(error) { vte_terminal_set_scrollback_lines(vte, scrollback_lines); } + + gchar *cursor_blink = g_key_file_get_string(config, "options", "cursor_blink", &error); + IGNORE_ON_ERROR(error) { + if (!strcmp(cursor_blink, "SYSTEM")) { + vte_terminal_set_cursor_blink_mode(vte, VTE_CURSOR_BLINK_SYSTEM); + } else if (!strcmp(cursor_blink, "ON")) { + vte_terminal_set_cursor_blink_mode(vte, VTE_CURSOR_BLINK_ON); + } else if (!strcmp(cursor_blink, "OFF")) { + vte_terminal_set_cursor_blink_mode(vte, VTE_CURSOR_BLINK_OFF); + } + g_free(cursor_blink); + } + + gchar *cursor_shape = g_key_file_get_string(config, "options", "cursor_shape", &error); + IGNORE_ON_ERROR(error) { + if (!strcmp(cursor_shape, "BLOCK")) { + vte_terminal_set_cursor_shape(vte, VTE_CURSOR_SHAPE_BLOCK); + } else if (!strcmp(cursor_shape, "IBEAM")) { + vte_terminal_set_cursor_shape(vte, VTE_CURSOR_SHAPE_IBEAM); + } else if (!strcmp(cursor_shape, "UNDERLINE")) { + vte_terminal_set_cursor_shape(vte, VTE_CURSOR_SHAPE_UNDERLINE); + } + g_free(cursor_shape); + } } g_key_file_free(config); } @@ -387,9 +411,6 @@ int main(int argc, char **argv) { load_config(GTK_WINDOW(window), VTE_TERMINAL(vte)); - vte_terminal_set_cursor_shape(VTE_TERMINAL(vte), CONCAT2(VTE_CURSOR_SHAPE_, CURSOR_SHAPE)); - vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(vte), CONCAT2(VTE_CURSOR_BLINK_, CURSOR_BLINK)); - #ifdef TRANSPARENCY GdkScreen *screen = gtk_widget_get_screen(window); GdkVisual *visual = gdk_screen_get_rgba_visual(screen); diff --git a/termite.cfg b/termite.cfg index cc17844..0822df9 100644 --- a/termite.cfg +++ b/termite.cfg @@ -7,3 +7,9 @@ visible_bell = false mouse_autohide = false font = Monospace 9 scrollback_lines = 1000 + +# SYSTEM, ON or OFF +cursor_blink = SYSTEM + +# BLOCK, UNDERLINE or IBEAM +cursor_shape = BLOCK