Added settings for common terminal configurations

This commit is contained in:
Mikayla Maki 2022-07-15 18:27:10 -07:00
parent 024011a571
commit dc120c1e05
10 changed files with 283 additions and 100 deletions

View file

@ -39,15 +39,20 @@ where
Self(rx)
}
///Loads the given watched JSON file. In the special case that the file is
///empty (ignoring whitespace) or is not a file, this will return T::default()
async fn load(fs: Arc<dyn Fs>, path: &Path) -> Option<T> {
if fs.is_file(&path).await {
fs.load(&path)
.await
.log_err()
.and_then(|data| parse_json_with_comments(&data).log_err())
} else {
Some(T::default())
if !fs.is_file(&path).await {
return Some(T::default());
}
fs.load(&path).await.log_err().and_then(|data| {
if data.trim().is_empty() {
Some(T::default())
} else {
parse_json_with_comments(&data).log_err()
}
})
}
}

View file

@ -79,18 +79,25 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {
cx.update_global::<Settings, _, _>(|settings, cx| {
settings.buffer_font_size = (settings.buffer_font_size + 1.0).max(MIN_FONT_SIZE);
if let Some(terminal_font_size) = settings.terminal_overrides.font_size.as_mut() {
*terminal_font_size = (*terminal_font_size + 1.0).max(MIN_FONT_SIZE);
}
cx.refresh_windows();
});
});
cx.add_global_action(move |_: &DecreaseBufferFontSize, cx| {
cx.update_global::<Settings, _, _>(|settings, cx| {
settings.buffer_font_size = (settings.buffer_font_size - 1.0).max(MIN_FONT_SIZE);
if let Some(terminal_font_size) = settings.terminal_overrides.font_size.as_mut() {
*terminal_font_size = (*terminal_font_size - 1.0).max(MIN_FONT_SIZE);
}
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;
settings.terminal_overrides.font_size = settings.terminal_defaults.font_size;
cx.refresh_windows();
});
});