Notify editors on buffer font size changes
This commit is contained in:
parent
e57c32effb
commit
8f262892a0
2 changed files with 16 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
|||
use crate::one_themes::one_dark;
|
||||
use crate::{Theme, ThemeRegistry};
|
||||
use anyhow::Result;
|
||||
use gpui::{px, AppContext, Font, FontFeatures, FontStyle, FontWeight, Pixels};
|
||||
use gpui::{
|
||||
px, AppContext, Font, FontFeatures, FontStyle, FontWeight, Pixels, Subscription, ViewContext,
|
||||
};
|
||||
use schemars::{
|
||||
gen::SchemaGenerator,
|
||||
schema::{InstanceType, Schema, SchemaObject},
|
||||
|
@ -80,6 +82,13 @@ impl ThemeSettings {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn observe_buffer_font_size_adjustment<V: 'static>(
|
||||
cx: &mut ViewContext<V>,
|
||||
f: impl 'static + Fn(&mut V, &mut ViewContext<V>),
|
||||
) -> Subscription {
|
||||
cx.observe_global::<AdjustedBufferFontSize>(f)
|
||||
}
|
||||
|
||||
pub fn adjusted_font_size(size: Pixels, cx: &mut AppContext) -> Pixels {
|
||||
if let Some(AdjustedBufferFontSize(adjusted_size)) = cx.try_global::<AdjustedBufferFontSize>() {
|
||||
let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue