r4d/
consts.rs

1//! Multiple constant variables
2
3use regex::Regex;
4
5/// Text display wrapper
6///
7/// This can be either simple string or "Color" crate's function
8#[cfg(feature = "color")]
9pub type ColorDisplayFunc = fn(string: &str, to_file: bool) -> Box<dyn std::fmt::Display>;
10
11/// Static source for lorem lipsum
12pub const LOREM_SOURCE: &str = "Lorem ipsum dolor sit amet consectetur adipiscing elit. In rhoncus sapien iaculis sapien congue a dictum urna malesuada. In hac habitasse platea dictumst. Quisque dapibus justo a mollis condimentum sapien ligula aliquam massa in vehicula tellus magna vitae enim. Aliquam mattis ligula in enim congue auctor. Pellentesque at sollicitudin velit. Quisque blandit lobortis turpis at malesuada. Donec vitae luctus mauris. Aenean efficitur risus id tortor blandit laoreet. Vestibulum commodo aliquam sapien. Cras aliquam eget leo iaculis cursus. Morbi iaculis justo sed tellus ultrices aliquet. Nam bibendum ut erat quis. ";
13
14lazy_static::lazy_static! {
15    /// Static lorem lipsum vector
16    pub static ref LOREM: Vec<&'static str> = LOREM_SOURCE.split(' ').collect();
17    /// Static lorem lipsum vector's length
18    pub static ref LOREM_WIDTH: usize = LOREM.len();
19}
20
21/// Get macro start character
22///
23/// This return custom character if given so
24pub(crate) fn macro_start(custom: Option<char>) -> char {
25    if let Some(start) = custom {
26        start
27    } else {
28        MACRO_START_CHAR
29    }
30}
31
32/// Get comment start chracter
33///
34/// This return custom character if given so
35pub(crate) fn comment_start(custom: Option<char>) -> char {
36    if let Some(start) = custom {
37        start
38    } else {
39        COMMENT_CHAR
40    }
41}
42
43// Platform agonistic consts
44/// Default macro character
45const MACRO_START_CHAR: char = '$';
46/// Default comment character
47const COMMENT_CHAR: char = '%';
48
49/// Escape character
50pub const ESCAPE_CHAR: char = '\\';
51/// Literal start character
52pub const LIT_CHAR: char = '*';
53/// Default main caller
54///
55/// This is default for input
56pub const MAIN_CALLER: &str = "@MAIN@";
57
58pub const MACRO_SPECIAL_ANON: &str = "_ANON_";
59
60lazy_static::lazy_static! {
61    // Numbers
62    // Macro attributes * ^ | +
63    // Underscore and reverse slash (\)
64    /// Unallowed regex pattern for macro attributes
65    pub static ref UNALLOWED_CHARS: Regex = Regex::new(r#"[a-zA-Z1-9\\_\*\^\|\(\)-=,:!]"#).expect("Failed to create regex expression");
66}
67
68// Diff related
69#[cfg(feature = "debug")]
70/// Source file for diff operation
71pub const DIFF_SOURCE_FILE: &str = "diff.src";
72#[cfg(feature = "debug")]
73/// Out file for diff operation
74pub const DIFF_OUT_FILE: &str = "diff.out";
75
76// LINE ENDING
77#[cfg(windows)]
78/// Platform specific line ending
79pub const LINE_ENDING: &str = "\r\n";
80#[cfg(not(windows))]
81/// Platform specific line ending
82pub const LINE_ENDING: &str = "\n";
83
84// PATH_SEPARATOR
85// On windows this should return double forward slash.
86// because only double forward slash is guaranteed to be evaluated as single
87// forward slash
88#[cfg(windows)]
89/// Platform specific path separator
90pub const PATH_SEPARATOR: &str = "\\\\";
91#[cfg(not(windows))]
92/// Platform specific path separator
93pub const PATH_SEPARATOR: &str = "/";
94
95#[cfg(feature = "debug")]
96/// Debug help message string
97pub const RDB_HELP: &str = include_str!("debug_help_message.txt");
98
99/// Empty String aRray
100pub const ESR: [&str; 0] = [];
101
102/// Define keyword
103pub const DEFINE_KEYWORD: &str = "define";