settings_ui: Add UI and buffer font weight controls (#15104)
This PR adds settings controls for the UI and buffer font weight settings. It also does some work around grouping the settings into related sections. Release Notes: - N/A
This commit is contained in:
parent
7fb906d774
commit
274e56b086
16 changed files with 557 additions and 272 deletions
33
crates/settings/src/editable_setting_control.rs
Normal file
33
crates/settings/src/editable_setting_control.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
use fs::Fs;
|
||||
use gpui::{AppContext, RenderOnce, SharedString};
|
||||
|
||||
use crate::{update_settings_file, Settings};
|
||||
|
||||
/// A UI control that can be used to edit a setting.
|
||||
pub trait EditableSettingControl: RenderOnce {
|
||||
/// The type of the setting value.
|
||||
type Value: Send;
|
||||
|
||||
/// The settings type to which this setting belongs.
|
||||
type Settings: Settings;
|
||||
|
||||
/// Returns the name of this setting.
|
||||
fn name(&self) -> SharedString;
|
||||
|
||||
/// Reads the setting value from the settings.
|
||||
fn read(cx: &AppContext) -> Self::Value;
|
||||
|
||||
/// Applies the given setting file to the settings file contents.
|
||||
///
|
||||
/// This will be called when writing the setting value back to the settings file.
|
||||
fn apply(settings: &mut <Self::Settings as Settings>::FileContent, value: Self::Value);
|
||||
|
||||
/// Writes the given setting value to the settings files.
|
||||
fn write(value: Self::Value, cx: &AppContext) {
|
||||
let fs = <dyn Fs>::global(cx);
|
||||
|
||||
update_settings_file::<Self::Settings>(fs, cx, move |settings, _cx| {
|
||||
Self::apply(settings, value);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue