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
|
@ -97,7 +97,10 @@ use std::{
|
||||||
pub use sum_tree::Bias;
|
pub use sum_tree::Bias;
|
||||||
use sum_tree::TreeMap;
|
use sum_tree::TreeMap;
|
||||||
use text::{OffsetUtf16, Rope};
|
use text::{OffsetUtf16, Rope};
|
||||||
use theme::{ActiveTheme, PlayerColor, StatusColors, SyntaxTheme, ThemeColors, ThemeSettings};
|
use theme::{
|
||||||
|
observe_buffer_font_size_adjustment, ActiveTheme, PlayerColor, StatusColors, SyntaxTheme,
|
||||||
|
ThemeColors, ThemeSettings,
|
||||||
|
};
|
||||||
use ui::{
|
use ui::{
|
||||||
h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, Popover,
|
h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, Popover,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
@ -1812,6 +1815,7 @@ impl Editor {
|
||||||
cx.observe(&display_map, Self::on_display_map_changed),
|
cx.observe(&display_map, Self::on_display_map_changed),
|
||||||
cx.observe(&blink_manager, |_, _, cx| cx.notify()),
|
cx.observe(&blink_manager, |_, _, cx| cx.notify()),
|
||||||
cx.observe_global::<SettingsStore>(Self::settings_changed),
|
cx.observe_global::<SettingsStore>(Self::settings_changed),
|
||||||
|
observe_buffer_font_size_adjustment(cx, |_, cx| cx.notify()),
|
||||||
cx.observe_window_activation(|editor, cx| {
|
cx.observe_window_activation(|editor, cx| {
|
||||||
let active = cx.is_window_active();
|
let active = cx.is_window_active();
|
||||||
editor.blink_manager.update(cx, |blink_manager, cx| {
|
editor.blink_manager.update(cx, |blink_manager, cx| {
|
||||||
|
@ -8741,6 +8745,7 @@ impl Editor {
|
||||||
)),
|
)),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_searchable(&mut self, searchable: bool) {
|
pub fn set_searchable(&mut self, searchable: bool) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::one_themes::one_dark;
|
use crate::one_themes::one_dark;
|
||||||
use crate::{Theme, ThemeRegistry};
|
use crate::{Theme, ThemeRegistry};
|
||||||
use anyhow::Result;
|
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::{
|
use schemars::{
|
||||||
gen::SchemaGenerator,
|
gen::SchemaGenerator,
|
||||||
schema::{InstanceType, Schema, SchemaObject},
|
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 {
|
pub fn adjusted_font_size(size: Pixels, cx: &mut AppContext) -> Pixels {
|
||||||
if let Some(AdjustedBufferFontSize(adjusted_size)) = cx.try_global::<AdjustedBufferFontSize>() {
|
if let Some(AdjustedBufferFontSize(adjusted_size)) = cx.try_global::<AdjustedBufferFontSize>() {
|
||||||
let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;
|
let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue