Skip to content

Commit 6e3f4bd

Browse files
committed
Add 256-color variants to theme files and consolidate theme loading
Merge the separate default_theme256.toml into default_theme.toml so each theme file contains both [theme] and [theme256] sections. Add 256-color variants to both IBM1970 (default) and 42KM themes. Simplify config.rs to load a single theme file instead of two.
1 parent 8aa54fd commit 6e3f4bd

5 files changed

Lines changed: 486 additions & 267 deletions

File tree

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ FileCTRL is a light, opinionated, responsive, theme-able, and simple Text User I
99
- Simple interface with good defaults - works out of the box with [sensible settings](#configuration)
1010
- [Vim-like navigation](#default-keybindings) and [multi-select](#multi-select) - hjkl movement, marks, range mode
1111
- [Rebindable keys](#customizing-keybindings) - customize all keybindings via TOML config
12-
- [Customizable colors](#theming) - full truecolor and 256-color theme support with LS_COLORS integration
12+
- [Customizable colors](#theming) - full truecolor and 256 color theme support with LS_COLORS integration
1313
- Responsive layout - adapts columns and content to small and large terminal windows
1414

1515
## Installation
@@ -174,7 +174,7 @@ open_selected_file = "open %s"
174174
175175
### Theming
176176

177-
FileCTRL supports two theme sections: `[theme]` for truecolor terminals and `[theme256]` for 256-color terminals. At startup, FileCTRL detects truecolor support via the `$COLORTERM` environment variable. Use `--colors-256` to force the 256-color theme.
177+
FileCTRL supports two theme sections: `[theme]` for truecolor terminals and `[theme256]` for 256-color terminals. At startup, FileCTRL detects truecolor support via the `$COLORTERM` environment variable. Use `--colors-256` to force the 256 color theme.
178178

179179
#### Style properties
180180

@@ -191,7 +191,7 @@ All properties are optional. Omit any property to use its default. Set `fg` or `
191191
**Color formats:**
192192

193193
- **Truecolor** (`[theme]`): hex strings like `"#FF0000"`, or named colors like `"Red"`
194-
- **256-color** (`[theme256]`): decimal indexes `"0"` through `"255"`
194+
- **256 color** (`[theme256]`): decimal indexes `"0"` through `"255"`
195195

196196
**Available modifiers:** `"bold"`, `"dim"`, `"italic"`, `"underlined"`, `"blink"`, `"rapid_blink"`, `"reversed"`, `"crossed_out"`
197197

@@ -255,7 +255,6 @@ To get started with custom themes, export the built-in defaults as standalone fi
255255
filectrl --write-default-themes
256256
# Creates:
257257
# ~/.config/filectrl/theme.toml
258-
# ~/.config/filectrl/theme256.toml
259258
```
260259

261260
Then copy, rename, and edit them:
@@ -289,9 +288,8 @@ FileCTRL includes the following themes in the [`themes/`](themes/) directory:
289288

290289
Theme | Inspired by | Screenshot
291290
----- | ----------- | ----------
292-
[IBM1970](themes/ibm1970.toml) (default) | [vscode-ibm1970-theme](https://github.com/andornaut/vscode-ibm1970-theme) | [![IBM1970](./screenshots/IBM1970.png)](./screenshots/IBM1970.png)
293-
[42KM](themes/42km.toml) | [vscode-42km-theme](https://github.com/andornaut/vscode-42km-theme) | [![42KM](./screenshots/42KM.png)](./screenshots/42KM.png)
294-
[256 colors mode](themes/ibm1970-256.toml) (default when run with `--colors-256`) | | [![256 colors](./screenshots/colors256.png)](./screenshots/colors256.png)
291+
[IBM1970](./themes/ibm1970.toml) (default) | [vscode-ibm1970-theme](https://github.com/andornaut/vscode-ibm1970-theme) | [![IBM1970](./screenshots/IBM1970.png)](./screenshots/IBM1970.png)
292+
[42KM](./themes/42km.toml) | [vscode-42km-theme](https://github.com/andornaut/vscode-42km-theme) | [![42KM](./screenshots/42KM.png)](./screenshots/42KM.png)
295293

296294
```bash
297295
filectrl --include themes/42km.toml

src/app/config.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ static CONFIG: OnceLock<Config> = OnceLock::new();
1919
const CONFIG_RELATIVE_PATH: &str = "config.toml";
2020
const DEFAULT_CONFIG_BASE: &str = include_str!("config/default_config.toml");
2121
const DEFAULT_THEME: &str = include_str!("config/default_theme.toml");
22-
const DEFAULT_THEME256: &str = include_str!("config/default_theme256.toml");
2322
const DEFAULT_THEME_FILENAME: &str = "theme.toml";
24-
const DEFAULT_THEME256_FILENAME: &str = "theme256.toml";
2523

2624
#[derive(Debug, Deserialize)]
2725
pub struct FileSystemConfig {
@@ -155,12 +153,6 @@ impl Config {
155153
fs::write(&theme_path, DEFAULT_THEME)
156154
.map_err(|error| anyhow!("Cannot write theme file to {theme_path:?}: {error}"))?;
157155
info!("Wrote the default theme to {theme_path:?}");
158-
159-
let theme256_path = dir.join(DEFAULT_THEME256_FILENAME);
160-
fs::write(&theme256_path, DEFAULT_THEME256).map_err(|error| {
161-
anyhow!("Cannot write 256-color theme file to {theme256_path:?}: {error}")
162-
})?;
163-
info!("Wrote the default 256-color theme to {theme256_path:?}");
164156
Ok(())
165157
}
166158

@@ -284,13 +276,12 @@ fn merge_include_paths(mut value: Value, include_paths: &[PathBuf]) -> Result<Va
284276
Ok(value)
285277
}
286278

287-
/// Merges the embedded default config from its three source files:
288-
/// base config + truecolor theme + 256-color theme.
279+
/// Merges the embedded default config from its two source files:
280+
/// base config + theme (which includes both truecolor and 256-color variants).
289281
fn merge_default_config() -> Result<Value> {
290282
let base = parse_toml(DEFAULT_CONFIG_BASE)?;
291283
let theme = parse_toml(DEFAULT_THEME)?;
292-
let theme256 = parse_toml(DEFAULT_THEME256)?;
293-
Ok(merge_toml_values(merge_toml_values(base, theme), theme256))
284+
Ok(merge_toml_values(base, theme))
294285
}
295286

296287
/// Deep-merges two TOML values. Tables are merged recursively;

src/app/config/default_theme.toml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,242 @@ fg = "#DDDCCC"
236236
[theme.table.selected]
237237
bg = "#006B6B"
238238
fg = "#DDDCCC"
239+
240+
[theme256]
241+
# 256-color variant of the IBM1970 theme
242+
bg = "237" # #3a3a3a - dark gray (approx #423F2E)
243+
fg = "253" # #dadada - light gray (approx #DDDCCC)
244+
245+
[theme256.alert]
246+
fg = "144" # #afaf87 - olive sage (approx #9C9977)
247+
248+
[theme256.alert.error]
249+
fg = "160" # #d70000 - red
250+
251+
[theme256.alert.info]
252+
fg = "106" # #87af00 - green (approx #859900)
253+
254+
[theme256.alert.warn]
255+
fg = "130" # #af5f00 - rust (approx #b05533)
256+
257+
[theme256.breadcrumbs]
258+
bg = "236" # #303030 - dark (approx #373424)
259+
260+
[theme256.breadcrumbs.ancestor]
261+
fg = "253" # #dadada
262+
263+
[theme256.breadcrumbs.basename]
264+
bg = "30" # #008787 - dark teal (approx #006B6B)
265+
fg = "253" # #dadada
266+
modifiers = ["bold"]
267+
268+
[theme256.breadcrumbs.separator]
269+
fg = "144" # #afaf87 - olive sage (approx #9C9977)
270+
271+
[theme256.clipboard.copy]
272+
bg = "106" # #87af00 - green (approx #859900)
273+
fg = "235" # #262626
274+
275+
[theme256.clipboard.cut]
276+
bg = "136" # #af8700 - amber (approx #B58900)
277+
fg = "235" # #262626
278+
279+
[theme256.clipboard.delete]
280+
bg = "130" # #af5f00 - rust (approx #b05533)
281+
fg = "235" # #262626
282+
283+
[theme256.file_modified_date.less_than_minute]
284+
fg = "117" # #87d7ff - sky blue (approx #87CEEB)
285+
286+
[theme256.file_modified_date.less_than_hour]
287+
fg = "51" # #00ffff - cyan
288+
289+
[theme256.file_modified_date.less_than_day]
290+
fg = "46" # #00ff00 - bright green
291+
292+
[theme256.file_modified_date.less_than_month]
293+
fg = "226" # #ffff00 - yellow
294+
295+
[theme256.file_modified_date.less_than_year]
296+
fg = "201" # #ff00ff - magenta
297+
298+
[theme256.file_modified_date.greater_than_year]
299+
fg = "196" # #ff0000 - red
300+
301+
[theme256.file_size.bytes]
302+
fg = "117" # #87d7ff - sky blue
303+
304+
[theme256.file_size.kib]
305+
fg = "51" # #00ffff - cyan
306+
307+
[theme256.file_size.mib]
308+
fg = "46" # #00ff00 - bright green
309+
310+
[theme256.file_size.gib]
311+
fg = "226" # #ffff00 - yellow
312+
313+
[theme256.file_size.tib]
314+
fg = "201" # #ff00ff - magenta
315+
316+
[theme256.file_size.pib]
317+
fg = "196" # #ff0000 - red
318+
319+
[theme256.file_type]
320+
ls_colors_take_precedence = false
321+
322+
[theme256.file_type.block_device]
323+
bg = "230" # #ffffd7
324+
fg = "244" # #808080
325+
modifiers = ["bold"]
326+
327+
[theme256.file_type.character_device]
328+
bg = "230" # #ffffd7
329+
fg = "244" # #808080
330+
modifiers = ["bold"]
331+
332+
[theme256.file_type.directory]
333+
fg = "33" # #0087ff - blue
334+
335+
[theme256.file_type.directory_other_writable]
336+
bg = "235" # #262626
337+
fg = "33" # #0087ff
338+
339+
[theme256.file_type.directory_sticky]
340+
bg = "33" # #0087ff
341+
fg = "230" # #ffffd7
342+
343+
[theme256.file_type.directory_sticky_other_writable]
344+
bg = "64" # #5f8700
345+
fg = "230" # #ffffd7
346+
347+
[theme256.file_type.door]
348+
bg = "230" # #ffffd7
349+
fg = "136" # #af8700
350+
modifiers = ["bold"]
351+
352+
[theme256.file_type.executable]
353+
fg = "64" # #5f8700
354+
modifiers = ["bold"]
355+
356+
[theme256.file_type.missing]
357+
358+
[theme256.file_type.normal_file]
359+
fg = "254" # #e4e4e4
360+
361+
[theme256.file_type.pipe]
362+
bg = "230" # #ffffd7
363+
fg = "136" # #af8700
364+
modifiers = ["bold"]
365+
366+
[theme256.file_type.regular_file]
367+
fg = "254" # #e4e4e4
368+
369+
[theme256.file_type.setgid]
370+
bg = "136" # #af8700
371+
fg = "230" # #ffffd7
372+
373+
[theme256.file_type.setuid]
374+
bg = "160" # #d70000
375+
fg = "230" # #ffffd7
376+
377+
[theme256.file_type.socket]
378+
bg = "230" # #ffffd7
379+
fg = "136" # #af8700
380+
modifiers = ["bold"]
381+
382+
[theme256.file_type.symlink]
383+
fg = "37" # #00afaf - cyan
384+
modifiers = ["bold"]
385+
386+
[theme256.file_type.symlink_broken]
387+
bg = "235" # #262626
388+
fg = "160" # #d70000
389+
390+
[theme256.help]
391+
fg = "144" # #afaf87 - olive sage
392+
393+
[theme256.help.header]
394+
bg = "144" # #afaf87
395+
fg = "235" # #262626
396+
397+
[theme256.help.actions]
398+
fg = "253" # #dadada
399+
modifiers = ["bold"]
400+
401+
[theme256.help.shortcuts]
402+
fg = "253" # #dadada
403+
404+
[theme256.notice.filter]
405+
bg = "73" # #5fafaf - teal (approx #33A999)
406+
fg = "235" # #262626
407+
408+
[theme256.notice.progress]
409+
bg = "30" # #008787 - dark teal
410+
fg = "73" # #5fafaf - teal
411+
412+
[theme256.prompt.cursor]
413+
bg = "30" # #008787
414+
fg = "253" # #dadada
415+
416+
[theme256.prompt.delete]
417+
bg = "130" # #af5f00 - rust
418+
fg = "235" # #262626
419+
420+
[theme256.prompt.input]
421+
bg = "236" # #303030
422+
fg = "253" # #dadada
423+
424+
[theme256.prompt.label]
425+
bg = "73" # #5fafaf - teal
426+
fg = "235" # #262626
427+
428+
[theme256.prompt.selected]
429+
bg = "37" # #00afaf - cyan (approx #2AA198)
430+
fg = "253" # #dadada
431+
432+
[theme256.scrollbar]
433+
show_ends = false
434+
435+
[theme256.scrollbar.ends]
436+
bg = "100" # #878700 - darker olive (approx #7c7755)
437+
fg = "236" # #303030
438+
439+
[theme256.scrollbar.thumb]
440+
bg = "236" # #303030
441+
fg = "144" # #afaf87
442+
443+
[theme256.scrollbar.track]
444+
fg = "100" # #878700
445+
446+
[theme256.status.detail]
447+
bg = "37" # #00afaf - cyan (approx #2AA198)
448+
fg = "235" # #262626
449+
450+
[theme256.status.label]
451+
bg = "30" # #008787 - dark teal
452+
fg = "253" # #dadada
453+
454+
[theme256.table.body]
455+
bg = "237" # #3a3a3a
456+
fg = "253" # #dadada
457+
458+
[theme256.table.delete]
459+
bg = "136" # #af8700 - amber
460+
fg = "235" # #262626
461+
462+
[theme256.table.header]
463+
bg = "100" # #878700 - darker olive (approx #7c7755)
464+
fg = "235" # #262626
465+
466+
[theme256.table.header_sorted]
467+
bg = "144" # #afaf87 - olive sage
468+
fg = "235" # #262626
469+
modifiers = ["bold"]
470+
471+
[theme256.table.marked]
472+
bg = "37" # #00afaf - cyan (approx #2AA198)
473+
fg = "253" # #dadada
474+
475+
[theme256.table.selected]
476+
bg = "30" # #008787 - dark teal
477+
fg = "253" # #dadada

0 commit comments

Comments
 (0)