From 1b32dc14602c4c09945dfbea7629949376082def Mon Sep 17 00:00:00 2001 From: Loric Brevet Date: Sun, 9 Nov 2025 17:22:14 +0100 Subject: [PATCH] Disable-able Syntax Highlighting Preference --- data/io.elementary.code.gschema.xml | 5 +++++ src/Dialogs/PreferencesDialog.vala | 1 + src/Widgets/FormatBar.vala | 2 +- src/Widgets/SourceView.vala | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/data/io.elementary.code.gschema.xml b/data/io.elementary.code.gschema.xml index 0f78a64f73..185986686b 100644 --- a/data/io.elementary.code.gschema.xml +++ b/data/io.elementary.code.gschema.xml @@ -106,6 +106,11 @@ Highlight Matching Brackets Whether Code should highlight matching brackets. + + true + Highlight source code syntax + Whether Code should apply syntax highlighting to documents. + "For Selection" Draw spaces and tabs with symbols diff --git a/src/Dialogs/PreferencesDialog.vala b/src/Dialogs/PreferencesDialog.vala index 53288c3985..ca081e591f 100644 --- a/src/Dialogs/PreferencesDialog.vala +++ b/src/Dialogs/PreferencesDialog.vala @@ -110,6 +110,7 @@ public class Scratch.Dialogs.Preferences : Granite.Dialog { var editor_box = new Gtk.Box (VERTICAL, 12); editor_box.add (new Granite.HeaderLabel (_("Editor"))); editor_box.add (new SettingSwitch (_("Highlight matching brackets"), "highlight-matching-brackets")); + editor_box.add (new SettingSwitch (_("Syntax highlighting"), "syntax-highlighting")); editor_box.add (draw_spaces_box); editor_box.add (new SettingSwitch (_("Mini Map"), "show-mini-map")); editor_box.add (new SettingSwitch (_("Wrap lines"), "line-wrap")); diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 53d4673eef..f7547fbd73 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -47,7 +47,7 @@ public class Code.FormatBar : Gtk.Box { lang_menubutton = new FormatButton () { icon = new ThemedIcon ("application-x-class-file-symbolic"), - tooltip_text = _("Syntax Highlighting") + tooltip_text = _("Document language") }; line_menubutton = new FormatButton () { diff --git a/src/Widgets/SourceView.vala b/src/Widgets/SourceView.vala index c03ddafbae..a196a34091 100644 --- a/src/Widgets/SourceView.vala +++ b/src/Widgets/SourceView.vala @@ -95,7 +95,7 @@ namespace Scratch.Widgets { var source_buffer = new Gtk.SourceBuffer (null); set_buffer (source_buffer); - source_buffer.highlight_syntax = true; + source_buffer.highlight_syntax = Scratch.settings.get_boolean ("syntax-highlighting"); source_buffer.mark_set.connect (on_mark_set); source_buffer.mark_deleted.connect (on_mark_deleted); highlight_current_line = true; @@ -239,6 +239,7 @@ namespace Scratch.Widgets { insert_spaces_instead_of_tabs = Scratch.settings.get_boolean ("spaces-instead-of-tabs"); var source_buffer = (Gtk.SourceBuffer) buffer; source_buffer.highlight_matching_brackets = Scratch.settings.get_boolean ("highlight-matching-brackets"); + source_buffer.highlight_syntax = Scratch.settings.get_boolean ("syntax-highlighting"); space_drawer.enable_matrix = false; switch ((ScratchDrawSpacesState) Scratch.settings.get_enum ("draw-spaces")) { case ScratchDrawSpacesState.ALWAYS: