Add "Reset Zoom" action and application menu item
This commit is contained in:
parent
4a5317b6e4
commit
e1a05d451f
4 changed files with 16 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
"cmd-shift-S": "workspace::SaveAs",
|
||||
"cmd-=": "zed::IncreaseBufferFontSize",
|
||||
"cmd--": "zed::DecreaseBufferFontSize",
|
||||
"cmd-0": "zed::ResetBufferFontSize",
|
||||
"cmd-,": "zed::OpenSettings",
|
||||
"cmd-q": "zed::Quit",
|
||||
"cmd-n": "workspace::NewFile",
|
||||
|
|
|
@ -21,6 +21,7 @@ pub use keymap_file::{keymap_file_json_schema, KeymapFileContent};
|
|||
pub struct Settings {
|
||||
pub buffer_font_family: FamilyId,
|
||||
pub buffer_font_size: f32,
|
||||
pub default_buffer_font_size: f32,
|
||||
pub vim_mode: bool,
|
||||
pub tab_size: u32,
|
||||
pub soft_wrap: SoftWrap,
|
||||
|
@ -73,6 +74,7 @@ impl Settings {
|
|||
Ok(Self {
|
||||
buffer_font_family: font_cache.load_family(&[buffer_font_family])?,
|
||||
buffer_font_size: 15.,
|
||||
default_buffer_font_size: 15.,
|
||||
vim_mode: false,
|
||||
tab_size: 4,
|
||||
soft_wrap: SoftWrap::None,
|
||||
|
@ -126,6 +128,7 @@ impl Settings {
|
|||
Settings {
|
||||
buffer_font_family: cx.font_cache().load_family(&["Monaco"]).unwrap(),
|
||||
buffer_font_size: 14.,
|
||||
default_buffer_font_size: 14.,
|
||||
vim_mode: false,
|
||||
tab_size: 4,
|
||||
soft_wrap: SoftWrap::None,
|
||||
|
@ -162,6 +165,7 @@ impl Settings {
|
|||
}
|
||||
|
||||
merge(&mut self.buffer_font_size, data.buffer_font_size);
|
||||
merge(&mut self.default_buffer_font_size, data.buffer_font_size);
|
||||
merge(&mut self.vim_mode, data.vim_mode);
|
||||
merge(&mut self.format_on_save, data.format_on_save);
|
||||
merge(&mut self.soft_wrap, data.editor.soft_wrap);
|
||||
|
|
|
@ -164,6 +164,10 @@ pub fn menus() -> Vec<Menu<'static>> {
|
|||
name: "Zoom Out",
|
||||
action: Box::new(super::DecreaseBufferFontSize),
|
||||
},
|
||||
MenuItem::Action {
|
||||
name: "Reset Zoom",
|
||||
action: Box::new(super::ResetBufferFontSize),
|
||||
},
|
||||
MenuItem::Separator,
|
||||
MenuItem::Action {
|
||||
name: "Project Browser",
|
||||
|
|
|
@ -43,6 +43,7 @@ actions!(
|
|||
OpenKeymap,
|
||||
IncreaseBufferFontSize,
|
||||
DecreaseBufferFontSize,
|
||||
ResetBufferFontSize,
|
||||
InstallCommandLineInterface,
|
||||
]
|
||||
);
|
||||
|
@ -72,6 +73,12 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||
cx.refresh_windows();
|
||||
});
|
||||
});
|
||||
cx.add_global_action(move |_: &ResetBufferFontSize, cx| {
|
||||
cx.update_global::<Settings, _, _>(|settings, cx| {
|
||||
settings.buffer_font_size = settings.default_buffer_font_size;
|
||||
cx.refresh_windows();
|
||||
});
|
||||
});
|
||||
cx.add_global_action(move |_: &InstallCommandLineInterface, cx| {
|
||||
cx.spawn(|cx| async move { install_cli(&cx).await.context("error creating CLI symlink") })
|
||||
.detach_and_log_err(cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue