Skip to main content

tree_table/types/
statics.rs

1use alloc::boxed::Box;
2use alloc::string::{String, ToString};
3use hashbrown::HashSet;
4use once_cell::race::OnceBox;
5
6pub static EVENT_MODIFIED: &'static str = "TableModified";
7pub static EVENT_SELECT: &'static str = "TableSelect";
8// pub static EVENT_RENDER: &'static str = "TableRender";
9pub static EVENT_CLIPBOARD: &'static str = "TableClipboard";
10pub static EVENT_BULK_VALIDATE: &'static str = "BulkValidate";
11pub static ROWS: &str = "rows";
12pub static COLS: &str = "cols";
13pub static CELLS: &str = "cells";
14pub static NORMAL: &str = "normal";
15pub static HIDDEN: &str = "hidden";
16
17pub static VALID_INHERITS: OnceBox<HashSet<String>> = OnceBox::new();
18
19pub static DEFAULT_INHERIT: &str = "@prev";
20pub static DEFAULT_EMIT_EVENT_FOR_API: bool = true;
21pub static DEFAULT_UNDO_FOR_API: bool = true;
22pub static DEFAULT_SAVE_SELECTION_FOR_API: bool = true;
23pub static DEFAULT_EXPAND_FOR_API: bool = true;
24
25#[inline(always)]
26pub fn valid_inherits() -> &'static HashSet<String> {
27    VALID_INHERITS.get_or_init(|| {
28        let mut set = HashSet::new();
29        set.insert("@next".to_string());
30        set.insert("@prev".to_string());
31        set.insert("@none".to_string());
32        Box::new(set)
33    })
34}
35
36#[inline(always)]
37pub fn default_inherit() -> String {
38    DEFAULT_INHERIT.to_string()
39}
40
41#[inline(always)]
42pub fn default_emit_event_for_api() -> bool {
43    DEFAULT_EMIT_EVENT_FOR_API
44}
45
46#[inline(always)]
47pub fn default_undo_for_api() -> bool {
48    DEFAULT_UNDO_FOR_API
49}
50
51#[inline(always)]
52pub fn default_save_selection_for_api() -> bool {
53    DEFAULT_SAVE_SELECTION_FOR_API
54}
55
56#[inline(always)]
57pub fn default_expand_for_api() -> bool {
58    DEFAULT_EXPAND_FOR_API
59}
60
61#[inline(always)]
62pub fn get_true() -> bool {
63    true
64}