From e6c807c25bc732c971fa00da78067d670db9a3c0 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 15 Sep 2008 16:53:31 +0000 Subject: [PATCH] Use SCI_STYLEGET(FONT|SIZE) instead of parsing editor_font. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/split-window-plugin@2947 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 6 ++++++ plugins/splitwindow.c | 42 +++++++++++++++--------------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index a96ee995..8f902617 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-09-15 Nick Treleaven + + * plugins/splitwindow.c: + Use SCI_STYLEGET(FONT|SIZE) instead of parsing editor_font. + + 2008-09-12 Nick Treleaven * plugins/splitwindow.c: diff --git a/plugins/splitwindow.c b/plugins/splitwindow.c index 6880b90c..b16e7463 100644 --- a/plugins/splitwindow.c +++ b/plugins/splitwindow.c @@ -88,19 +88,27 @@ static void set_styles(ScintillaObject *oldsci, ScintillaObject *newsci) static void sci_set_font(ScintillaObject *sci, gint style, const gchar *font, - G_GNUC_UNUSED gint size) + gint size) { p_sci->send_message(sci, SCI_STYLESETFONT, style, (sptr_t) font); p_sci->send_message(sci, SCI_STYLESETSIZE, style, size); } -static void set_font(ScintillaObject *sci, const gchar *font_name, gint size) +static void update_font(ScintillaObject *current, ScintillaObject *sci) { - gint style; + gint style_id; + gint size; + gchar font_name[1024]; /* should be big enough */ + + p_sci->send_message(current, SCI_STYLEGETFONT, 0, (sptr_t)font_name); + size = sci_get_value(current, SCI_STYLEGETSIZE, 0); + + for (style_id = 0; style_id <= 127; style_id++) + { + sci_set_font(sci, style_id, font_name, size); + } - for (style = 0; style <= 127; style++) - sci_set_font(sci, style, font_name, size); /* line number and braces */ sci_set_font(sci, STYLE_LINENUMBER, font_name, size); sci_set_font(sci, STYLE_BRACELIGHT, font_name, size); @@ -108,26 +116,6 @@ static void set_font(ScintillaObject *sci, const gchar *font_name, gint size) } -/* TODO: maybe use SCI_STYLEGET(FONT|SIZE) instead */ -static void update_font(ScintillaObject *sci, const gchar *font_name, gint size) -{ - gchar *fname; - PangoFontDescription *font_desc; - - g_return_if_fail(font_name != NULL); - - font_desc = pango_font_description_from_string(font_name); - - fname = g_strdup_printf("!%s", pango_font_description_get_family(font_desc)); - size = pango_font_description_get_size(font_desc) / PANGO_SCALE; - - set_font(sci, fname, size); - - g_free(fname); - pango_font_description_free(font_desc); -} - - /* line numbers visibility */ static void set_line_numbers(ScintillaObject * sci, gboolean set, gint extra_width) { @@ -158,8 +146,7 @@ static void sync_to_current(ScintillaObject *current, ScintillaObject *sci) sdoc = (gpointer) p_sci->send_message(current, SCI_GETDOCPOINTER, 0, 0); p_sci->send_message(sci, SCI_SETDOCPOINTER, 0, GPOINTER_TO_INT(sdoc)); - update_font(sci, geany->interface_prefs->editor_font, 0); - + update_font(current, sci); lexer = p_sci->send_message(current, SCI_GETLEXER, 0, 0); p_sci->send_message(sci, SCI_SETLEXER, lexer, 0); set_styles(current, sci); @@ -167,6 +154,7 @@ static void sync_to_current(ScintillaObject *current, ScintillaObject *sci) pos = p_sci->get_current_position(current); p_sci->set_current_position(sci, pos, TRUE); + /* override some defaults */ set_line_numbers(sci, TRUE, 0); p_sci->send_message(sci, SCI_SETMARGINWIDTHN, 1, 0 ); /* hide marker margin */ }