settings.rs

 1use crate::watch;
 2use anyhow::Result;
 3use gpui::font_cache::{FamilyId, FontCache};
 4
 5#[derive(Clone)]
 6pub struct Settings {
 7    pub buffer_font_family: FamilyId,
 8    pub buffer_font_size: f32,
 9    pub tab_size: usize,
10    pub ui_font_family: FamilyId,
11    pub ui_font_size: f32,
12}
13
14impl Settings {
15    pub fn new(font_cache: &FontCache) -> Result<Self> {
16        Ok(Self {
17            buffer_font_family: font_cache.load_family(&["Fira Code", "Monaco"])?,
18            buffer_font_size: 14.0,
19            tab_size: 4,
20            ui_font_family: font_cache.load_family(&["SF Pro", "Helvetica"])?,
21            ui_font_size: 12.0,
22        })
23    }
24}
25
26pub fn channel(
27    font_cache: &FontCache,
28) -> Result<(watch::Sender<Settings>, watch::Receiver<Settings>)> {
29    Ok(watch::channel(Settings::new(font_cache)?))
30}