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
This commit is contained in:
Nick Treleaven 2008-09-15 16:53:31 +00:00
parent a0493aa678
commit e6c807c25b
2 changed files with 21 additions and 27 deletions

View File

@ -1,3 +1,9 @@
2008-09-15 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* plugins/splitwindow.c:
Use SCI_STYLEGET(FONT|SIZE) instead of parsing editor_font.
2008-09-12 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* plugins/splitwindow.c:

View File

@ -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 */
}