Skip to main content

settings_model/
text_assistance.rs

1//! The shared spelling preferences: the per-user `text_assistance` section every app's text
2//! fields follow.
3
4pub const SETTINGS_SECTION: &str = "text_assistance";
5
6#[cfg_attr(feature = "model", derive(tilo_resource::Model))]
7#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
8#[cfg_attr(feature = "model", model(defaults))]
9pub struct TextAssistancePrefs {
10    /// Underline words the spell checker does not know, in every text field.
11    pub check_spelling: bool,
12    /// Replace common misspellings with the word the checker suggests as they are typed.
13    pub auto_correct: bool,
14    /// The language the checker reads, as a BCP 47 tag; empty uses the person's interface language.
15    #[serde(default)]
16    pub spelling_language: String,
17}
18
19impl Default for TextAssistancePrefs {
20    fn default() -> Self {
21        Self {
22            check_spelling: true,
23            auto_correct: true,
24            spelling_language: String::new(),
25        }
26    }
27}
28
29impl crate::SettingsSchema for TextAssistancePrefs {
30    const SCOPE: crate::Scope = crate::Scope::Shared(SETTINGS_SECTION);
31}
32
33/// The section as a record the person edits by path.
34#[cfg(feature = "model")]
35#[tilo_resource::resource(kind = "settings.text-assistance")]
36impl TextAssistancePrefs {}