freya_edit/
config.rs

1#[derive(Clone, Copy, PartialEq, Debug)]
2pub struct EditableConfig {
3    pub(crate) identation: u8,
4    pub(crate) allow_tabs: bool,
5    pub(crate) allow_changes: bool,
6    pub(crate) allow_clipboard: bool,
7}
8
9impl Default for EditableConfig {
10    fn default() -> Self {
11        Self::new()
12    }
13}
14
15impl EditableConfig {
16    /// Create a [`EditableConfig`].
17    pub fn new() -> Self {
18        Self {
19            identation: 4,
20            allow_tabs: false,
21            allow_changes: true,
22            allow_clipboard: true,
23        }
24    }
25
26    /// Specify a custom identation
27    pub fn with_identation(mut self, identation: u8) -> Self {
28        self.identation = identation;
29        self
30    }
31
32    /// Specify whether you want to allow tabs to be inserted
33    pub fn with_allow_tabs(mut self, allow_tabs: bool) -> Self {
34        self.allow_tabs = allow_tabs;
35        self
36    }
37
38    /// Allow changes through keyboard events or not
39    pub fn with_allow_changes(mut self, allow_changes: bool) -> Self {
40        self.allow_changes = allow_changes;
41        self
42    }
43
44    /// Allow clipboard keyboard events
45    pub fn with_allow_clipboard(mut self, allow_clipboard: bool) -> Self {
46        self.allow_clipboard = allow_clipboard;
47        self
48    }
49}