mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 10:40:54 +00:00
Add font name completions to ui_font_family and terminal::font_family
This commit is contained in:
parent
f011953484
commit
ff67d9dea0
4 changed files with 46 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -7775,6 +7775,7 @@ dependencies = [
|
|||
"schemars",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"settings",
|
||||
"shellexpand",
|
||||
"smallvec",
|
||||
|
|
|
@ -33,6 +33,7 @@ thiserror.workspace = true
|
|||
lazy_static.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
rand.workspace = true
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels};
|
||||
use schemars::JsonSchema;
|
||||
use schemars::{
|
||||
gen::SchemaGenerator,
|
||||
schema::{InstanceType, RootSchema, Schema, SchemaObject},
|
||||
JsonSchema,
|
||||
};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use settings::SettingsJsonSchemaParams;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
|
@ -153,6 +159,39 @@ impl settings::Settings for TerminalSettings {
|
|||
) -> anyhow::Result<Self> {
|
||||
Self::load_via_json_merge(default_value, user_values)
|
||||
}
|
||||
fn json_schema(
|
||||
generator: &mut SchemaGenerator,
|
||||
_: &SettingsJsonSchemaParams,
|
||||
cx: &AppContext,
|
||||
) -> RootSchema {
|
||||
let mut root_schema = generator.root_schema_for::<Self::FileContent>();
|
||||
let available_fonts = cx
|
||||
.text_system()
|
||||
.all_font_names()
|
||||
.into_iter()
|
||||
.map(Value::String)
|
||||
.collect();
|
||||
let fonts_schema = SchemaObject {
|
||||
instance_type: Some(InstanceType::String.into()),
|
||||
enum_values: Some(available_fonts),
|
||||
..Default::default()
|
||||
};
|
||||
root_schema
|
||||
.definitions
|
||||
.extend([("FontFamilies".into(), fonts_schema.into())]);
|
||||
root_schema
|
||||
.schema
|
||||
.object
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.properties
|
||||
.extend([(
|
||||
"font_family".to_owned(),
|
||||
Schema::new_ref("#/definitions/FontFamilies".into()),
|
||||
)]);
|
||||
|
||||
root_schema
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
|
||||
|
|
|
@ -234,6 +234,10 @@ impl settings::Settings for ThemeSettings {
|
|||
"buffer_font_family".to_owned(),
|
||||
Schema::new_ref("#/definitions/FontFamilies".into()),
|
||||
),
|
||||
(
|
||||
"ui_font_family".to_owned(),
|
||||
Schema::new_ref("#/definitions/FontFamilies".into()),
|
||||
),
|
||||
]);
|
||||
|
||||
root_schema
|
||||
|
|
Loading…
Reference in a new issue