diff --git a/data/io.elementary.code.gschema.xml b/data/io.elementary.code.gschema.xml index 0cfce65a0..b132a14a1 100644 --- a/data/io.elementary.code.gschema.xml +++ b/data/io.elementary.code.gschema.xml @@ -152,6 +152,12 @@ Preferred Font Set the preferred font. + + + 1.0 + Terminal pane font scale + The system terminal font is scaled by this factor in the terminal pane + 'elementary-light' Preferred Style Scheme diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 3938c0efa..29e31bfd5 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -879,20 +879,29 @@ namespace Scratch { } public void set_default_zoom () { - terminal.set_default_font_size (); - Scratch.settings.set_string ("font", get_current_font () + " " + get_default_font_size ().to_string ()); + if (terminal.terminal.has_focus) { + terminal.set_default_font_size (); + } else { + Scratch.settings.set_string ("font", get_current_font () + " " + get_default_font_size ().to_string ()); + } } // Ctrl + scroll public void action_zoom_in () { - terminal.increment_size (); - zooming (Gdk.ScrollDirection.UP); + if (terminal.terminal.has_focus) { + terminal.increment_size (); + } else { + zooming (Gdk.ScrollDirection.UP); + } } // Ctrl + scroll public void action_zoom_out () { - terminal.decrement_size (); - zooming (Gdk.ScrollDirection.DOWN); + if (terminal.terminal.has_focus) { + terminal.decrement_size (); + } else { + zooming (Gdk.ScrollDirection.DOWN); + } } private void zooming (Gdk.ScrollDirection direction) { diff --git a/src/Widgets/Terminal.vala b/src/Widgets/Terminal.vala index 7b445eaab..28cd1a1b3 100644 --- a/src/Widgets/Terminal.vala +++ b/src/Widgets/Terminal.vala @@ -10,8 +10,9 @@ public class Code.Terminal : Gtk.Box { public const string ACTION_COPY = "action-copy"; public const string ACTION_PASTE = "action-paste"; - private const double MAX_SCALE = 5.0; - private const double MIN_SCALE = 0.2; + private const double SCROLL_THRESHOLD = 1.0; + private const double MAX_SCALE = 2.0; + private const double MIN_SCALE = 0.5; private const string LEGACY_SETTINGS_SCHEMA = "org.pantheon.terminal.settings"; private const string SETTINGS_SCHEMA = "io.elementary.terminal.settings"; private const string GNOME_DESKTOP_INTERFACE_SCHEMA = "org.gnome.desktop.interface"; @@ -35,7 +36,7 @@ public class Code.Terminal : Gtk.Box { private GLib.Pid child_pid; private Gtk.Clipboard current_clipboard; - + private double total_delta_y = 0; private Scratch.Application application; construct { @@ -43,6 +44,7 @@ public class Code.Terminal : Gtk.Box { terminal = new Vte.Terminal () { hexpand = true, vexpand = true, + scroll_unit_is_pixels = true, scrollback_lines = -1, cursor_blink_mode = SYSTEM // There is no Terminal setting so follow Gnome }; @@ -97,6 +99,7 @@ public class Code.Terminal : Gtk.Box { // "org.gnome.desktop.interface.color-scheme" } + Scratch.settings.bind ("terminal-fontscale", terminal, "font-scale", DEFAULT); // Always monitor changes in systen font as that is what Terminal usually follows // The terminal font key is by default "" and can only be changed by editing the settings externally application.notify["system-monospace-font"].connect (() => { @@ -168,6 +171,25 @@ public class Code.Terminal : Gtk.Box { copy_action.set_enabled (terminal.get_has_selection ()); }); + // Zoom font size independent of the source view + terminal.scroll_event.connect ((event) => { + var mods = event.state & Gdk.ModifierType.MODIFIER_MASK; + if ((mods & Gdk.ModifierType.CONTROL_MASK) > 0) { + total_delta_y += event.delta_y; + if (total_delta_y > SCROLL_THRESHOLD) { + total_delta_y = 0; + decrement_size (); + } else if (total_delta_y < -SCROLL_THRESHOLD) { + total_delta_y = 0; + increment_size (); + } + + return Gdk.EVENT_STOP; + } + + return Gdk.EVENT_PROPAGATE; + }); + spawn_shell (Scratch.saved_state.get_string ("last-opened-path")); var scrolled_window = new Gtk.ScrolledWindow (null, terminal.get_vadjustment ());