Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
use editor::{EditorSettings, ui_scrollbar_settings_from_raw};
use gpui::{App, Pixels};
pub use settings::{DockSide, FolderIndicator, Settings, ShowIndentGuides};
use settings::{IntoGpui, RegisterSetting};
use ui::scrollbars::{ScrollbarVisibility, ShowScrollbar};
#[derive(Debug, Clone, Copy, PartialEq, RegisterSetting)]
pub struct OutlinePanelSettings {
pub button: bool,
pub default_width: Pixels,
pub dock: DockSide,
pub file_icons: bool,
pub folder_indicator: FolderIndicator,
pub git_status: bool,
pub indent_size: f32,
pub indent_guides: IndentGuidesSettings,
pub auto_reveal_entries: bool,
pub auto_fold_dirs: bool,
pub scrollbar: ScrollbarSettings,
pub expand_outlines_with_depth: usize,
pub multi_buffer_hide_symbols: bool,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct ScrollbarSettings {
/// When to show the scrollbar in the project panel.
///
/// Default: inherits editor scrollbar settings
pub show: Option<ShowScrollbar>,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct IndentGuidesSettings {
pub show: ShowIndentGuides,
}
#[derive(Default)]
pub(crate) struct OutlinePanelSettingsScrollbarProxy;
impl ScrollbarVisibility for OutlinePanelSettingsScrollbarProxy {
fn visibility(&self, cx: &App) -> ShowScrollbar {
OutlinePanelSettings::get_global(cx)
.scrollbar
.show
.unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)
}
}
impl Settings for OutlinePanelSettings {
fn from_settings(content: &settings::SettingsContent) -> Self {
let panel = content.outline_panel.as_ref().unwrap();
Self {
button: panel.button.unwrap(),
default_width: panel.default_width.unwrap().into_gpui(),
dock: panel.dock.unwrap(),
file_icons: panel.file_icons.unwrap(),
folder_indicator: panel.folder_indicator.unwrap(),
git_status: panel.git_status.unwrap()
&& content
.git
.as_ref()
.unwrap()
.enabled
.unwrap()
.is_git_status_enabled(),
indent_size: *panel.indent_size.unwrap(),
indent_guides: IndentGuidesSettings {
show: panel.indent_guides.unwrap().show.unwrap(),
},
auto_reveal_entries: panel.auto_reveal_entries.unwrap(),
auto_fold_dirs: panel.auto_fold_dirs.unwrap(),
scrollbar: ScrollbarSettings {
show: panel
.scrollbar
.unwrap()
.show
.map(ui_scrollbar_settings_from_raw),
},
expand_outlines_with_depth: panel.expand_outlines_with_depth.unwrap(),
multi_buffer_hide_symbols: panel.multi_buffer_hide_symbols.unwrap(),
}
}
}