diff options
-rw-r--r-- | lib/lexer.tes | 4 | ||||
-rw-r--r-- | sample.teco_ini | 4 | ||||
-rw-r--r-- | src/interface-gtk/interface-gtk.cpp | 40 | ||||
-rw-r--r-- | src/interface-gtk/interface-gtk.h | 2 |
4 files changed, 35 insertions, 15 deletions
diff --git a/lib/lexer.tes b/lib/lexer.tes index af89c0e..89a2fd5 100644 --- a/lib/lexer.tes +++ b/lib/lexer.tes @@ -8,6 +8,10 @@ } @[lexer.auto]{ + 0EJ-1"> :Q[lexer.font]"> + 32ESSTYLESETFONTQ[lexer.font] + Q[lexer.font],32ESSTYLESETSIZEFRACTIONAL + ' ' :M[color.init] [_ :Q*"= Oend ' diff --git a/sample.teco_ini b/sample.teco_ini index cddb939..cd2a6cf 100644 --- a/sample.teco_ini +++ b/sample.teco_ini @@ -39,6 +39,10 @@ EMQ[$SCITECOPATH]/session.tes !end!} 0,32ED +! Tweak the default font name and size. + The size unit is 1pt/100 ! +! [lexer.font]Monospace 1300U[lexer.font] ! + ! Uncomment to enable default keyboard macros and function keys ! ! EMQ[$SCITECOPATH]/fnkeys.tes ! diff --git a/src/interface-gtk/interface-gtk.cpp b/src/interface-gtk/interface-gtk.cpp index a2d2a1b..ca14f2f 100644 --- a/src/interface-gtk/interface-gtk.cpp +++ b/src/interface-gtk/interface-gtk.cpp @@ -258,7 +258,6 @@ InterfaceGtk::main_impl(int &argc, char **&argv) gtk_widget_set_name(cmdline_widget, "sciteco-cmdline"); gtk_entry_set_has_frame(GTK_ENTRY(cmdline_widget), FALSE); gtk_editable_set_editable(GTK_EDITABLE(cmdline_widget), FALSE); - widget_set_font(cmdline_widget, "Courier"); g_signal_connect(G_OBJECT(cmdline_widget), "key-press-event", G_CALLBACK(cmdline_key_pressed_cb), event_queue); gtk_box_pack_start(GTK_BOX(vbox), cmdline_widget, FALSE, FALSE, 0); @@ -513,21 +512,29 @@ InterfaceGtk::popup_clear_impl(void) } void -InterfaceGtk::widget_set_font(GtkWidget *widget, const gchar *font_name) -{ - PangoFontDescription *font_desc; - - font_desc = pango_font_description_from_string(font_name); - gtk_widget_modify_font(widget, font_desc); - pango_font_description_free(font_desc); -} - -void InterfaceGtk::set_css_variables_from_view(ViewGtk *view) { + guint font_size; gchar buffer[256]; /* + * Unfortunately, we cannot use CSS variables to pass around + * font names and sizes, necessary for styling the command line + * widget. + * Therefore we just style it using generated CSS here. + * This one of the few non-deprecated ways that Gtk leaves us + * to set a custom font name. + * CSS customizations have to take that into account. + * NOTE: We don't actually know apriori how + * large our buffer should be, but luckily STYLEGETFONT with + * a sptr==0 will return only the size. + * This is undocumented in the Scintilla docs. + */ + gchar font_name[view->ssm(SCI_STYLEGETFONT, STYLE_DEFAULT) + 1]; + view->ssm(SCI_STYLEGETFONT, STYLE_DEFAULT, (sptr_t)font_name); + font_size = view->ssm(SCI_STYLEGETSIZEFRACTIONAL, STYLE_DEFAULT); + + /* * Generates a CSS that sets some predefined color variables. * This effectively "exports" Scintilla styles into the CSS * world. @@ -540,11 +547,18 @@ InterfaceGtk::set_css_variables_from_view(ViewGtk *view) "@define-color sciteco_default_fg_color " CSS_COLOR_FORMAT ";" "@define-color sciteco_default_bg_color " CSS_COLOR_FORMAT ";" "@define-color sciteco_calltip_fg_color " CSS_COLOR_FORMAT ";" - "@define-color sciteco_calltip_bg_color " CSS_COLOR_FORMAT ";", + "@define-color sciteco_calltip_bg_color " CSS_COLOR_FORMAT ";" + "#%s{" + "font: %s %u.%u" + "}", bgr2rgb(view->ssm(SCI_STYLEGETFORE, STYLE_DEFAULT)), bgr2rgb(view->ssm(SCI_STYLEGETBACK, STYLE_DEFAULT)), bgr2rgb(view->ssm(SCI_STYLEGETFORE, STYLE_CALLTIP)), - bgr2rgb(view->ssm(SCI_STYLEGETBACK, STYLE_CALLTIP))); + bgr2rgb(view->ssm(SCI_STYLEGETBACK, STYLE_CALLTIP)), + gtk_widget_get_name(cmdline_widget), + font_name, + font_size / SC_FONT_SIZE_MULTIPLIER, + font_size % SC_FONT_SIZE_MULTIPLIER); /* * The GError and return value has been deprecated. diff --git a/src/interface-gtk/interface-gtk.h b/src/interface-gtk/interface-gtk.h index e43b7bf..7762ee4 100644 --- a/src/interface-gtk/interface-gtk.h +++ b/src/interface-gtk/interface-gtk.h @@ -168,8 +168,6 @@ public: void handle_key_press(bool is_shift, bool is_ctl, guint keyval); private: - static void widget_set_font(GtkWidget *widget, const gchar *font_name); - void set_css_variables_from_view(ViewGtk *view); void refresh_info(void); |