Skip to main content

tree_table/args/
args_note.rs

1use crate::SpanKey;
2use crate::statics::default_emit_event_for_api;
3use crate::statics::default_expand_for_api;
4use crate::statics::default_save_selection_for_api;
5use crate::statics::default_undo_for_api;
6use alloc::string::String;
7use alloc::string::ToString;
8
9#[cfg_attr(feature = "tsify", derive(tsify::Tsify))]
10#[cfg_attr(feature = "tsify", tsify(from_wasm_abi))]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[derive(Debug, Clone, PartialEq)]
13pub struct NoteArgs {
14    pub key: SpanKey,
15    pub note: Option<String>,
16    pub bg: Option<String>,
17    pub fg: Option<String>,
18    pub readonly: bool,
19    #[cfg_attr(feature = "serde", serde(default = "default_emit_event_for_api"))]
20    pub emit: bool,
21    #[cfg_attr(feature = "serde", serde(default = "default_undo_for_api"))]
22    pub undo: bool,
23    #[cfg_attr(feature = "serde", serde(default = "default_save_selection_for_api"))]
24    pub save_selection: bool,
25    #[cfg_attr(feature = "serde", serde(default = "default_expand_for_api"))]
26    pub expand: bool,
27}
28
29impl Default for NoteArgs {
30    fn default() -> Self {
31        NoteArgs {
32            key: SpanKey::None,
33            note: None,
34            bg: None,
35            fg: None,
36            readonly: true,
37            emit: default_emit_event_for_api(),
38            undo: default_undo_for_api(),
39            save_selection: default_save_selection_for_api(),
40            expand: default_expand_for_api(),
41        }
42    }
43}
44
45#[cfg_attr(feature = "tsify", derive(tsify::Tsify))]
46#[cfg_attr(feature = "tsify", tsify(from_wasm_abi))]
47#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
48#[derive(Debug, Clone, PartialEq)]
49pub struct SetNoteArgs {
50    pub key: SpanKey,
51    pub note: Option<String>,
52    pub bg: Option<Option<String>>,
53    pub fg: Option<Option<String>>,
54    pub readonly: Option<bool>,
55    #[cfg_attr(feature = "serde", serde(default = "default_emit_event_for_api"))]
56    pub emit: bool,
57    #[cfg_attr(feature = "serde", serde(default = "default_undo_for_api"))]
58    pub undo: bool,
59    #[cfg_attr(feature = "serde", serde(default = "default_save_selection_for_api"))]
60    pub save_selection: bool,
61}
62
63impl Default for SetNoteArgs {
64    fn default() -> Self {
65        SetNoteArgs {
66            key: SpanKey::None,
67            note: Some("".to_string()),
68            bg: None,
69            fg: None,
70            readonly: None,
71            emit: default_emit_event_for_api(),
72            undo: default_undo_for_api(),
73            save_selection: default_save_selection_for_api(),
74        }
75    }
76}