Add active pane magnification setting which grows the active pane making it easier to see it's contents

This commit is contained in:
K Simmons 2022-10-25 17:24:19 -07:00
parent 076d353e84
commit e2ba8d6df7
4 changed files with 273 additions and 230 deletions

View file

@ -1,230 +1,233 @@
{ {
// The name of the Zed theme to use for the UI // The name of the Zed theme to use for the UI
"theme": "One Dark", "theme": "One Dark",
// The name of a font to use for rendering text in the editor // The name of a font to use for rendering text in the editor
"buffer_font_family": "Zed Mono", "buffer_font_family": "Zed Mono",
// The default font size for text in the editor // The default font size for text in the editor
"buffer_font_size": 15, "buffer_font_size": 15,
// Whether to enable vim modes and key bindings // The factor to grow the active pane by. Defaults to 1.0
"vim_mode": false, // which gives the same size as all other panes.
// Whether to show the informational hover box when moving the mouse "active_pane_magnification": 1.0,
// over symbols in the editor. // Whether to enable vim modes and key bindings
"hover_popover_enabled": true, "vim_mode": false,
// Whether the cursor blinks in the editor. // Whether to show the informational hover box when moving the mouse
"cursor_blink": true, // over symbols in the editor.
// Whether to pop the completions menu while typing in an editor without "hover_popover_enabled": true,
// explicitly requesting it. // Whether the cursor blinks in the editor.
"show_completions_on_input": true, "cursor_blink": true,
// Whether new projects should start out 'online'. Online projects // Whether to pop the completions menu while typing in an editor without
// appear in the contacts panel under your name, so that your contacts // explicitly requesting it.
// can see which projects you are working on. Regardless of this "show_completions_on_input": true,
// setting, projects keep their last online status when you reopen them. // Whether new projects should start out 'online'. Online projects
"projects_online_by_default": true, // appear in the contacts panel under your name, so that your contacts
// Whether to use language servers to provide code intelligence. // can see which projects you are working on. Regardless of this
"enable_language_server": true, // setting, projects keep their last online status when you reopen them.
// When to automatically save edited buffers. This setting can "projects_online_by_default": true,
// take four values. // Whether to use language servers to provide code intelligence.
// "enable_language_server": true,
// 1. Never automatically save: // When to automatically save edited buffers. This setting can
// "autosave": "off", // take four values.
// 2. Save when changing focus away from the Zed window:
// "autosave": "on_window_change",
// 3. Save when changing focus away from a specific buffer:
// "autosave": "on_focus_change",
// 4. Save when idle for a certain amount of time:
// "autosave": { "after_delay": {"milliseconds": 500} },
"autosave": "off",
// Where to place the dock by default. This setting can take three
// values:
//
// 1. Position the dock attached to the bottom of the workspace
// "default_dock_anchor": "bottom"
// 2. Position the dock to the right of the workspace like a side panel
// "default_dock_anchor": "right"
// 3. Position the dock full screen over the entire workspace"
// "default_dock_anchor": "expanded"
"default_dock_anchor": "right",
// Whether or not to perform a buffer format before saving
"format_on_save": "on",
// How to perform a buffer format. This setting can take two values:
//
// 1. Format code using the current language server:
// "format_on_save": "language_server"
// 2. Format code using an external command:
// "format_on_save": {
// "external": {
// "command": "prettier",
// "arguments": ["--stdin-filepath", "{buffer_path}"]
// }
// }
"formatter": "language_server",
// How to soft-wrap long lines of text. This setting can take
// three values:
//
// 1. Do not soft wrap.
// "soft_wrap": "none",
// 2. Soft wrap lines that overflow the editor:
// "soft_wrap": "editor_width",
// 3. Soft wrap lines at the preferred line length
// "soft_wrap": "preferred_line_length",
"soft_wrap": "none",
// The column at which to soft-wrap lines, for buffers where soft-wrap
// is enabled.
"preferred_line_length": 80,
// Whether to indent lines using tab characters, as opposed to multiple
// spaces.
"hard_tabs": false,
// How many columns a tab should occupy.
"tab_size": 4,
// Git gutter behavior configuration.
"git": {
// Control whether the git gutter is shown. May take 2 values:
// 1. Show the gutter
// "git_gutter": "tracked_files"
// 2. Hide the gutter
// "git_gutter": "hide"
"git_gutter": "tracked_files"
},
// Settings specific to journaling
"journal": {
// The path of the directory where journal entries are stored
"path": "~",
// What format to display the hours in
// May take 2 values:
// 1. hour12
// 2. hour24
"hour_format": "hour12"
},
// Settings specific to the terminal
"terminal": {
// What shell to use when opening a terminal. May take 3 values:
// 1. Use the system's default terminal configuration (e.g. $TERM).
// "shell": "system"
// 2. A program:
// "shell": {
// "program": "sh"
// }
// 3. A program with arguments:
// "shell": {
// "with_arguments": {
// "program": "/bin/bash",
// "arguments": ["--login"]
// }
// }
"shell": "system",
// What working directory to use when launching the terminal.
// May take 4 values:
// 1. Use the current file's project directory. Will Fallback to the
// first project directory strategy if unsuccessful
// "working_directory": "current_project_directory"
// 2. Use the first project in this workspace's directory
// "working_directory": "first_project_directory"
// 3. Always use this platform's home directory (if we can find it)
// "working_directory": "always_home"
// 4. Always use a specific directory. This value will be shell expanded.
// If this path is not a valid directory the terminal will default to
// this platform's home directory (if we can find it)
// "working_directory": {
// "always": {
// "directory": "~/zed/projects/"
// }
// }
// //
// 1. Never automatically save:
// "autosave": "off",
// 2. Save when changing focus away from the Zed window:
// "autosave": "on_window_change",
// 3. Save when changing focus away from a specific buffer:
// "autosave": "on_focus_change",
// 4. Save when idle for a certain amount of time:
// "autosave": { "after_delay": {"milliseconds": 500} },
"autosave": "off",
// Where to place the dock by default. This setting can take three
// values:
// //
"working_directory": "current_project_directory", // 1. Position the dock attached to the bottom of the workspace
// Set the cursor blinking behavior in the terminal. // "default_dock_anchor": "bottom"
// May take 4 values: // 2. Position the dock to the right of the workspace like a side panel
// 1. Never blink the cursor, ignoring the terminal mode // "default_dock_anchor": "right"
// "blinking": "off", // 3. Position the dock full screen over the entire workspace"
// 2. Default the cursor blink to off, but allow the terminal to // "default_dock_anchor": "expanded"
// set blinking "default_dock_anchor": "right",
// "blinking": "terminal_controlled", // Whether or not to perform a buffer format before saving
// 3. Always blink the cursor, ignoring the terminal mode "format_on_save": "on",
// "blinking": "on", // How to perform a buffer format. This setting can take two values:
"blinking": "terminal_controlled", //
// Set whether Alternate Scroll mode (code: ?1007) is active by default. // 1. Format code using the current language server:
// Alternate Scroll mode converts mouse scroll events into up / down key // "format_on_save": "language_server"
// presses when in the alternate screen (e.g. when running applications // 2. Format code using an external command:
// like vim or less). The terminal can still set and unset this mode. // "format_on_save": {
// May take 2 values: // "external": {
// 1. Default alternate scroll mode to on // "command": "prettier",
// "alternate_scroll": "on", // "arguments": ["--stdin-filepath", "{buffer_path}"]
// 2. Default alternate scroll mode to off // }
// "alternate_scroll": "off",
"alternate_scroll": "off",
// Set whether the option key behaves as the meta key.
// May take 2 values:
// 1. Rely on default platform handling of option key, on macOS
// this means generating certain unicode characters
// "option_to_meta": false,
// 2. Make the option keys behave as a 'meta' key, e.g. for emacs
// "option_to_meta": true,
"option_as_meta": false,
// Whether or not selecting text in the terminal will automatically
// copy to the system clipboard.
"copy_on_select": false,
// Any key-value pairs added to this list will be added to the terminal's
// enviroment. Use `:` to seperate multiple values.
"env": {
// "KEY": "value1:value2"
}
// Set the terminal's font size. If this option is not included,
// the terminal will default to matching the buffer's font size.
// "font_size": "15"
// Set the terminal's font family. If this option is not included,
// the terminal will default to matching the buffer's font family.
// "font_family": "Zed Mono"
},
// Different settings for specific languages.
"languages": {
"Plain Text": {
"soft_wrap": "preferred_line_length"
},
"C": {
"tab_size": 2
},
"C++": {
"tab_size": 2
},
"Elixir": {
"tab_size": 2
},
"Go": {
"tab_size": 4,
"hard_tabs": true
},
"Markdown": {
"soft_wrap": "preferred_line_length"
},
"Rust": {
"tab_size": 4
},
"JavaScript": {
"tab_size": 2
},
"TypeScript": {
"tab_size": 2
},
"TSX": {
"tab_size": 2
}
},
// LSP Specific settings.
"lsp": {
// Specify the LSP name as a key here.
// As of 8/10/22, supported LSPs are:
// pyright
// gopls
// rust-analyzer
// typescript-language-server
// vscode-json-languageserver
// "rust_analyzer": {
// //These initialization options are merged into Zed's defaults
// "initialization_options": {
// "checkOnSave": {
// "command": "clippy"
// }
// } // }
// } "formatter": "language_server",
} // How to soft-wrap long lines of text. This setting can take
// three values:
//
// 1. Do not soft wrap.
// "soft_wrap": "none",
// 2. Soft wrap lines that overflow the editor:
// "soft_wrap": "editor_width",
// 3. Soft wrap lines at the preferred line length
// "soft_wrap": "preferred_line_length",
"soft_wrap": "none",
// The column at which to soft-wrap lines, for buffers where soft-wrap
// is enabled.
"preferred_line_length": 80,
// Whether to indent lines using tab characters, as opposed to multiple
// spaces.
"hard_tabs": false,
// How many columns a tab should occupy.
"tab_size": 4,
// Git gutter behavior configuration.
"git": {
// Control whether the git gutter is shown. May take 2 values:
// 1. Show the gutter
// "git_gutter": "tracked_files"
// 2. Hide the gutter
// "git_gutter": "hide"
"git_gutter": "tracked_files"
},
// Settings specific to journaling
"journal": {
// The path of the directory where journal entries are stored
"path": "~",
// What format to display the hours in
// May take 2 values:
// 1. hour12
// 2. hour24
"hour_format": "hour12"
},
// Settings specific to the terminal
"terminal": {
// What shell to use when opening a terminal. May take 3 values:
// 1. Use the system's default terminal configuration (e.g. $TERM).
// "shell": "system"
// 2. A program:
// "shell": {
// "program": "sh"
// }
// 3. A program with arguments:
// "shell": {
// "with_arguments": {
// "program": "/bin/bash",
// "arguments": ["--login"]
// }
// }
"shell": "system",
// What working directory to use when launching the terminal.
// May take 4 values:
// 1. Use the current file's project directory. Will Fallback to the
// first project directory strategy if unsuccessful
// "working_directory": "current_project_directory"
// 2. Use the first project in this workspace's directory
// "working_directory": "first_project_directory"
// 3. Always use this platform's home directory (if we can find it)
// "working_directory": "always_home"
// 4. Always use a specific directory. This value will be shell expanded.
// If this path is not a valid directory the terminal will default to
// this platform's home directory (if we can find it)
// "working_directory": {
// "always": {
// "directory": "~/zed/projects/"
// }
// }
//
//
"working_directory": "current_project_directory",
// Set the cursor blinking behavior in the terminal.
// May take 4 values:
// 1. Never blink the cursor, ignoring the terminal mode
// "blinking": "off",
// 2. Default the cursor blink to off, but allow the terminal to
// set blinking
// "blinking": "terminal_controlled",
// 3. Always blink the cursor, ignoring the terminal mode
// "blinking": "on",
"blinking": "terminal_controlled",
// Set whether Alternate Scroll mode (code: ?1007) is active by default.
// Alternate Scroll mode converts mouse scroll events into up / down key
// presses when in the alternate screen (e.g. when running applications
// like vim or less). The terminal can still set and unset this mode.
// May take 2 values:
// 1. Default alternate scroll mode to on
// "alternate_scroll": "on",
// 2. Default alternate scroll mode to off
// "alternate_scroll": "off",
"alternate_scroll": "off",
// Set whether the option key behaves as the meta key.
// May take 2 values:
// 1. Rely on default platform handling of option key, on macOS
// this means generating certain unicode characters
// "option_to_meta": false,
// 2. Make the option keys behave as a 'meta' key, e.g. for emacs
// "option_to_meta": true,
"option_as_meta": false,
// Whether or not selecting text in the terminal will automatically
// copy to the system clipboard.
"copy_on_select": false,
// Any key-value pairs added to this list will be added to the terminal's
// enviroment. Use `:` to seperate multiple values.
"env": {
// "KEY": "value1:value2"
}
// Set the terminal's font size. If this option is not included,
// the terminal will default to matching the buffer's font size.
// "font_size": "15"
// Set the terminal's font family. If this option is not included,
// the terminal will default to matching the buffer's font family.
// "font_family": "Zed Mono"
},
// Different settings for specific languages.
"languages": {
"Plain Text": {
"soft_wrap": "preferred_line_length"
},
"C": {
"tab_size": 2
},
"C++": {
"tab_size": 2
},
"Elixir": {
"tab_size": 2
},
"Go": {
"tab_size": 4,
"hard_tabs": true
},
"Markdown": {
"soft_wrap": "preferred_line_length"
},
"Rust": {
"tab_size": 4
},
"JavaScript": {
"tab_size": 2
},
"TypeScript": {
"tab_size": 2
},
"TSX": {
"tab_size": 2
}
},
// LSP Specific settings.
"lsp": {
// Specify the LSP name as a key here.
// As of 8/10/22, supported LSPs are:
// pyright
// gopls
// rust-analyzer
// typescript-language-server
// vscode-json-languageserver
// "rust_analyzer": {
// //These initialization options are merged into Zed's defaults
// "initialization_options": {
// "checkOnSave": {
// "command": "clippy"
// }
// }
// }
}
} }

View file

@ -28,6 +28,7 @@ pub struct Settings {
pub buffer_font_family: FamilyId, pub buffer_font_family: FamilyId,
pub default_buffer_font_size: f32, pub default_buffer_font_size: f32,
pub buffer_font_size: f32, pub buffer_font_size: f32,
pub active_pane_magnification: f32,
pub cursor_blink: bool, pub cursor_blink: bool,
pub hover_popover_enabled: bool, pub hover_popover_enabled: bool,
pub show_completions_on_input: bool, pub show_completions_on_input: bool,
@ -235,6 +236,8 @@ pub struct SettingsFileContent {
#[serde(default)] #[serde(default)]
pub buffer_font_size: Option<f32>, pub buffer_font_size: Option<f32>,
#[serde(default)] #[serde(default)]
pub active_pane_magnification: Option<f32>,
#[serde(default)]
pub cursor_blink: Option<bool>, pub cursor_blink: Option<bool>,
#[serde(default)] #[serde(default)]
pub hover_popover_enabled: Option<bool>, pub hover_popover_enabled: Option<bool>,
@ -294,6 +297,7 @@ impl Settings {
.load_family(&[defaults.buffer_font_family.as_ref().unwrap()]) .load_family(&[defaults.buffer_font_family.as_ref().unwrap()])
.unwrap(), .unwrap(),
buffer_font_size: defaults.buffer_font_size.unwrap(), buffer_font_size: defaults.buffer_font_size.unwrap(),
active_pane_magnification: defaults.active_pane_magnification.unwrap(),
default_buffer_font_size: defaults.buffer_font_size.unwrap(), default_buffer_font_size: defaults.buffer_font_size.unwrap(),
cursor_blink: defaults.cursor_blink.unwrap(), cursor_blink: defaults.cursor_blink.unwrap(),
hover_popover_enabled: defaults.hover_popover_enabled.unwrap(), hover_popover_enabled: defaults.hover_popover_enabled.unwrap(),
@ -349,6 +353,10 @@ impl Settings {
data.projects_online_by_default, data.projects_online_by_default,
); );
merge(&mut self.buffer_font_size, data.buffer_font_size); merge(&mut self.buffer_font_size, data.buffer_font_size);
merge(
&mut self.active_pane_magnification,
data.active_pane_magnification,
);
merge(&mut self.default_buffer_font_size, data.buffer_font_size); merge(&mut self.default_buffer_font_size, data.buffer_font_size);
merge(&mut self.cursor_blink, data.cursor_blink); merge(&mut self.cursor_blink, data.cursor_blink);
merge(&mut self.hover_popover_enabled, data.hover_popover_enabled); merge(&mut self.hover_popover_enabled, data.hover_popover_enabled);
@ -440,6 +448,7 @@ impl Settings {
experiments: FeatureFlags::default(), experiments: FeatureFlags::default(),
buffer_font_family: cx.font_cache().load_family(&["Monaco"]).unwrap(), buffer_font_family: cx.font_cache().load_family(&["Monaco"]).unwrap(),
buffer_font_size: 14., buffer_font_size: 14.,
active_pane_magnification: 1.,
default_buffer_font_size: 14., default_buffer_font_size: 14.,
cursor_blink: true, cursor_blink: true,
hover_popover_enabled: true, hover_popover_enabled: true,

View file

@ -6,6 +6,7 @@ use gpui::{
}; };
use project::Project; use project::Project;
use serde::Deserialize; use serde::Deserialize;
use settings::Settings;
use theme::Theme; use theme::Theme;
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
@ -61,10 +62,17 @@ impl PaneGroup {
theme: &Theme, theme: &Theme,
follower_states: &FollowerStatesByLeader, follower_states: &FollowerStatesByLeader,
active_call: Option<&ModelHandle<ActiveCall>>, active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut RenderContext<Workspace>, cx: &mut RenderContext<Workspace>,
) -> ElementBox { ) -> ElementBox {
self.root self.root.render(
.render(project, theme, follower_states, active_call, cx) project,
theme,
follower_states,
active_call,
active_pane,
cx,
)
} }
pub(crate) fn panes(&self) -> Vec<&ViewHandle<Pane>> { pub(crate) fn panes(&self) -> Vec<&ViewHandle<Pane>> {
@ -102,12 +110,20 @@ impl Member {
Member::Axis(PaneAxis { axis, members }) Member::Axis(PaneAxis { axis, members })
} }
fn contains(&self, needle: &ViewHandle<Pane>) -> bool {
match self {
Member::Axis(axis) => axis.members.iter().any(|member| member.contains(needle)),
Member::Pane(pane) => pane == needle,
}
}
pub fn render( pub fn render(
&self, &self,
project: &ModelHandle<Project>, project: &ModelHandle<Project>,
theme: &Theme, theme: &Theme,
follower_states: &FollowerStatesByLeader, follower_states: &FollowerStatesByLeader,
active_call: Option<&ModelHandle<ActiveCall>>, active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut RenderContext<Workspace>, cx: &mut RenderContext<Workspace>,
) -> ElementBox { ) -> ElementBox {
enum FollowIntoExternalProject {} enum FollowIntoExternalProject {}
@ -234,7 +250,14 @@ impl Member {
.with_children(prompt) .with_children(prompt)
.boxed() .boxed()
} }
Member::Axis(axis) => axis.render(project, theme, follower_states, active_call, cx), Member::Axis(axis) => axis.render(
project,
theme,
follower_states,
active_call,
active_pane,
cx,
),
} }
} }
@ -340,12 +363,19 @@ impl PaneAxis {
theme: &Theme, theme: &Theme,
follower_state: &FollowerStatesByLeader, follower_state: &FollowerStatesByLeader,
active_call: Option<&ModelHandle<ActiveCall>>, active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut RenderContext<Workspace>, cx: &mut RenderContext<Workspace>,
) -> ElementBox { ) -> ElementBox {
let last_member_ix = self.members.len() - 1; let last_member_ix = self.members.len() - 1;
Flex::new(self.axis) Flex::new(self.axis)
.with_children(self.members.iter().enumerate().map(|(ix, member)| { .with_children(self.members.iter().enumerate().map(|(ix, member)| {
let mut member = member.render(project, theme, follower_state, active_call, cx); let mut flex = 1.0;
if member.contains(active_pane) {
flex = cx.global::<Settings>().active_pane_magnification;
}
let mut member =
member.render(project, theme, follower_state, active_call, active_pane, cx);
if ix < last_member_ix { if ix < last_member_ix {
let mut border = theme.workspace.pane_divider; let mut border = theme.workspace.pane_divider;
border.left = false; border.left = false;
@ -359,7 +389,7 @@ impl PaneAxis {
member = Container::new(member).with_border(border).boxed(); member = Container::new(member).with_border(border).boxed();
} }
FlexItem::new(member).flex(1.0, true).boxed() FlexItem::new(member).flex(flex, true).boxed()
})) }))
.boxed() .boxed()
} }

View file

@ -2670,6 +2670,7 @@ impl View for Workspace {
&theme, &theme,
&self.follower_states_by_leader, &self.follower_states_by_leader,
self.active_call(), self.active_call(),
self.active_pane(),
cx, cx,
)) ))
.flex(1., true) .flex(1., true)