1use std::borrow::Cow;
2use std::sync::Arc;
3
4use gpui::{AssetSource, Result, SharedString};
5use rust_embed::RustEmbed;
6use serde::{Deserialize, Serialize};
7use strum::{EnumIter, EnumString, IntoStaticStr};
8
9#[derive(
10 Debug, PartialEq, Eq, Copy, Clone, EnumIter, EnumString, IntoStaticStr, Serialize, Deserialize,
11)]
12#[strum(serialize_all = "snake_case")]
13pub enum IconName {
14 AcpRegistry,
15 AiAnthropic,
16 AiBedrock,
17 AiClaude,
18 AiDeepSeek,
19 AiEdit,
20 AiGemini,
21 AiGoogle,
22 AiLmStudio,
23 AiMistral,
24 AiOllama,
25 AiOpenAi,
26 AiOpenAiCompat,
27 AiOpenCode,
28 AiOpenRouter,
29 AiVercel,
30 AiXAi,
31 Archive,
32 ArrowCircle,
33 ArrowDown,
34 ArrowDown10,
35 ArrowDownRight,
36 ArrowLeft,
37 ArrowRight,
38 ArrowRightLeft,
39 ArrowUp,
40 ArrowUpRight,
41 AtSign,
42 Attach,
43 AudioOff,
44 AudioOn,
45 Backspace,
46 Bell,
47 BellDot,
48 BellOff,
49 BellRing,
50 Binary,
51 Blocks,
52 Bookmark,
53 BoltFilled,
54 BoltOutlined,
55 Book,
56 BookCopy,
57 Box,
58 BoxOpen,
59 CaseSensitive,
60 Chat,
61 Check,
62 CheckCircle,
63 CheckDouble,
64 ChevronDown,
65 ChevronDownUp,
66 ChevronLeft,
67 ChevronRight,
68 ChevronUp,
69 ChevronUpDown,
70 Circle,
71 CircleHelp,
72 Clock,
73 Close,
74 CloudDownload,
75 Code,
76 Command,
77 Control,
78 Copilot,
79 CopilotDisabled,
80 CopilotError,
81 CopilotInit,
82 Copy,
83 CountdownTimer,
84 Crosshair,
85 CursorIBeam,
86 Dash,
87 DatabaseZap,
88 Debug,
89 DebugBreakpoint,
90 DebugContinue,
91 DebugDetach,
92 DebugDisabledBreakpoint,
93 DebugDisabledLogBreakpoint,
94 DebugIgnoreBreakpoints,
95 DebugLogBreakpoint,
96 DebugPause,
97 DebugStepInto,
98 DebugStepOut,
99 DebugStepOver,
100 Diff,
101 DiffSplit,
102 DiffSplitAuto,
103 DiffUnified,
104 Disconnected,
105 Download,
106 EditorAtom,
107 EditorCursor,
108 EditorEmacs,
109 EditorJetBrains,
110 EditorSublime,
111 EditorVsCode,
112 Ellipsis,
113 Envelope,
114 Eraser,
115 Escape,
116 Exit,
117 ExpandDown,
118 ExpandUp,
119 ExpandVertical,
120 Eye,
121 EyeOff,
122 FastForward,
123 FastForwardOff,
124 File,
125 FileCode,
126 FileDiff,
127 FileDoc,
128 FileGeneric,
129 FileGit,
130 FileLock,
131 FileMarkdown,
132 FileRust,
133 FileTextFilled,
134 FileTextOutlined,
135 FileToml,
136 FileTree,
137 Filter,
138 Flame,
139 Folder,
140 FolderOpen,
141 FolderOpenAdd,
142 FolderSearch,
143 Font,
144 FontSize,
145 FontWeight,
146 ForwardArrow,
147 ForwardArrowUp,
148 GenericClose,
149 GenericMaximize,
150 GenericMinimize,
151 GenericRestore,
152 GitBranch,
153 GitBranchPlus,
154 GitCommit,
155 GitGraph,
156 GitMergeConflict,
157 GitWorktree,
158 Github,
159 Hash,
160 HistoryRerun,
161 Image,
162 Inception,
163 Indicator,
164 Info,
165 Json,
166 Keyboard,
167 Library,
168 LineHeight,
169 Link,
170 Linux,
171 ListCollapse,
172 ListFilter,
173 ListTodo,
174 ListTree,
175 ListX,
176 LoadCircle,
177 LocationEdit,
178 LockOutlined,
179 MagnifyingGlass,
180 Maximize,
181 MaximizeAlt,
182 Menu,
183 MenuAltTemp,
184 Mic,
185 MicMute,
186 Minimize,
187 NewThread,
188 Notepad,
189 OpenFolder,
190 Option,
191 PageDown,
192 PageUp,
193 Paperclip,
194 Pencil,
195 PencilUnavailable,
196 Person,
197 Pin,
198 PlayFilled,
199 PlayOutlined,
200 Plus,
201 Power,
202 Public,
203 PullRequest,
204 QueueMessage,
205 Quote,
206 Reader,
207 RefreshTitle,
208 Regex,
209 ReplNeutral,
210 Replace,
211 ReplaceAll,
212 ReplaceNext,
213 ReplyArrowRight,
214 Rerun,
215 Return,
216 RotateCcw,
217 RotateCw,
218 Scissors,
219 Screen,
220 SelectAll,
221 Send,
222 Server,
223 Settings,
224 Shift,
225 SignalHigh,
226 SignalLow,
227 SignalMedium,
228 Slash,
229 Sliders,
230 Space,
231 Sparkle,
232 Split,
233 SplitAlt,
234 SquareDot,
235 SquareMinus,
236 SquarePlus,
237 Star,
238 StarFilled,
239 Stop,
240 Tab,
241 Terminal,
242 TerminalAlt,
243 TextSnippet,
244 ThinkingMode,
245 ThinkingModeOff,
246 Thread,
247 ThreadFromSummary,
248 ThreadsSidebarLeftClosed,
249 ThreadsSidebarLeftOpen,
250 ThreadsSidebarRightClosed,
251 ThreadsSidebarRightOpen,
252 ThumbsDown,
253 ThumbsUp,
254 TodoComplete,
255 TodoPending,
256 TodoProgress,
257 ToolCopy,
258 ToolDeleteFile,
259 ToolDiagnostics,
260 ToolFolder,
261 ToolHammer,
262 ToolNotification,
263 ToolPencil,
264 ToolSearch,
265 ToolTerminal,
266 ToolThink,
267 ToolWeb,
268 Trash,
269 Triangle,
270 TriangleRight,
271 Undo,
272 Unpin,
273 User,
274 UserCheck,
275 UserGroup,
276 UserRoundPen,
277 Warning,
278 WholeWord,
279 ExclamationTriangle,
280 XCircle,
281 XCircleFilled,
282 XMark,
283}
284
285impl IconName {
286 pub fn path(&self) -> Arc<str> {
288 let file_stem: &'static str = self.into();
289 format!("icons/{file_stem}.svg").into()
290 }
291}
292
293#[derive(RustEmbed)]
298#[folder = "assets"]
299#[include = "icons/**/*.svg"]
300#[include = "fonts/**/*.ttf"]
301pub struct Assets;
302
303impl AssetSource for Assets {
304 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
305 Ok(Self::get(path).map(|f| f.data))
306 }
307
308 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
309 Ok(Self::iter()
310 .filter(|p| p.starts_with(path))
311 .map(|p| SharedString::from(p.to_string()))
312 .collect())
313 }
314}