ghostscope_ui/ui/
emoji.rs1use crate::ui::strings::UIStrings;
3
4#[derive(Debug, Clone)]
6pub struct EmojiConfig {
7 pub enabled: bool,
8}
9
10impl Default for EmojiConfig {
11 fn default() -> Self {
12 Self { enabled: true }
13 }
14}
15
16impl EmojiConfig {
17 pub fn new(enabled: bool) -> Self {
19 Self { enabled }
20 }
21
22 pub fn get_status_prefix(&self, status: StatusType) -> &'static str {
24 if self.enabled {
25 match status {
26 StatusType::Success => UIStrings::SUCCESS_PREFIX,
27 StatusType::Error => UIStrings::ERROR_PREFIX,
28 StatusType::Warning => UIStrings::WARNING_PREFIX,
29 StatusType::Info => UIStrings::INFO_PREFIX,
30 StatusType::Progress => UIStrings::PROGRESS_PREFIX,
31 }
32 } else {
33 match status {
34 StatusType::Success => UIStrings::SUCCESS_PREFIX_ASCII,
35 StatusType::Error => UIStrings::ERROR_PREFIX_ASCII,
36 StatusType::Warning => UIStrings::WARNING_PREFIX_ASCII,
37 StatusType::Info => UIStrings::INFO_PREFIX_ASCII,
38 StatusType::Progress => UIStrings::PROGRESS_PREFIX_ASCII,
39 }
40 }
41 }
42
43 pub fn get_script_status(&self, status: ScriptStatus) -> &'static str {
45 if self.enabled {
46 match status {
47 ScriptStatus::Success => UIStrings::SCRIPT_SUCCESS_EMOJI,
48 ScriptStatus::Error => UIStrings::SCRIPT_ERROR_EMOJI,
49 ScriptStatus::Partial => UIStrings::SCRIPT_PARTIAL_EMOJI,
50 ScriptStatus::Compiling => UIStrings::SCRIPT_COMPILING_EMOJI,
51 }
52 } else {
53 match status {
54 ScriptStatus::Success => "[SUCCESS]",
55 ScriptStatus::Error => "[ERROR]",
56 ScriptStatus::Partial => "[PARTIAL]",
57 ScriptStatus::Compiling => "[COMPILING]",
58 }
59 }
60 }
61
62 pub fn get_trace_element(&self, element: TraceElement) -> &'static str {
64 if self.enabled {
65 match element {
66 TraceElement::Target => UIStrings::TARGET_EMOJI,
67 TraceElement::Binary => UIStrings::BINARY_EMOJI,
68 TraceElement::Address => UIStrings::ADDRESS_EMOJI,
69 TraceElement::Line => UIStrings::LINE_EMOJI,
70 TraceElement::File => UIStrings::FILE_EMOJI,
71 TraceElement::Function => UIStrings::FUNCTION_EMOJI,
72 TraceElement::Variable => UIStrings::VARIABLE_EMOJI,
73 TraceElement::Probe => UIStrings::PROBE_EMOJI,
74 }
75 } else {
76 match element {
77 TraceElement::Target => "Target:",
78 TraceElement::Binary => "Binary:",
79 TraceElement::Address => "Address:",
80 TraceElement::Line => "Line:",
81 TraceElement::File => "File:",
82 TraceElement::Function => "Function:",
83 TraceElement::Variable => "Variable:",
84 TraceElement::Probe => "Probe:",
85 }
86 }
87 }
88
89 pub fn get_trace_status(&self, status: TraceStatusType) -> &'static str {
91 if self.enabled {
92 match status {
93 TraceStatusType::Active => UIStrings::ACTIVE_EMOJI,
94 TraceStatusType::Disabled => UIStrings::DISABLED_EMOJI,
95 TraceStatusType::Failed => UIStrings::FAILED_EMOJI,
96 TraceStatusType::Skipped => UIStrings::SKIPPED_EMOJI,
97 }
98 } else {
99 match status {
100 TraceStatusType::Active => "[ACTIVE]",
101 TraceStatusType::Disabled => "[DISABLED]",
102 TraceStatusType::Failed => "[FAILED]",
103 TraceStatusType::Skipped => "[SKIPPED]",
104 }
105 }
106 }
107}
108
109#[derive(Debug, Clone, Copy)]
111pub enum StatusType {
112 Success,
113 Error,
114 Warning,
115 Info,
116 Progress,
117}
118
119#[derive(Debug, Clone, Copy)]
121pub enum ScriptStatus {
122 Success,
123 Error,
124 Partial,
125 Compiling,
126}
127
128#[derive(Debug, Clone, Copy)]
130pub enum TraceElement {
131 Target,
132 Binary,
133 Address,
134 Line,
135 File,
136 Function,
137 Variable,
138 Probe,
139}
140
141#[derive(Debug, Clone, Copy)]
143pub enum TraceStatusType {
144 Active,
145 Disabled,
146 Failed,
147 Skipped,
148}