Color Schemes (#142)
* WIP: Color Schemes * Import/export using color_schemes config * Finish color scheme implementation * Add color scheme rename
This commit is contained in:
parent
01052fae0b
commit
89e1dcb83a
28 changed files with 2630 additions and 861 deletions
1493
Cargo.lock
generated
1493
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
20
Cargo.toml
20
Cargo.toml
|
|
@ -9,10 +9,13 @@ rust-version = "1.71"
|
|||
[dependencies]
|
||||
alacritty_terminal = "0.20"
|
||||
env_logger = "0.10"
|
||||
lazy_static = "1"
|
||||
hex_color = { version = "3", features = ["serde"] }
|
||||
indexmap = "2"
|
||||
lazy_static = "1"
|
||||
lexical-sort = "0.3.1"
|
||||
log = "0.4"
|
||||
palette = { version = "0.7", features = ["serde"] }
|
||||
ron = "0.8"
|
||||
serde = { version = "1", features = ["serde_derive"] }
|
||||
shlex = "1"
|
||||
tokio = { version = "1", features = ["sync"] }
|
||||
|
|
@ -21,11 +24,10 @@ i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester
|
|||
i18n-embed-fl = "0.6"
|
||||
rust-embed = "6"
|
||||
paste = "1.0"
|
||||
palette = "0.7"
|
||||
|
||||
[dependencies.smol_str]
|
||||
version = "0.2.1"
|
||||
features = ["serde"]
|
||||
[dependencies.cosmic-files]
|
||||
git = "https://github.com/pop-os/cosmic-files"
|
||||
default-features = false
|
||||
|
||||
[dependencies.cosmic-text]
|
||||
git = "https://github.com/pop-os/cosmic-text.git"
|
||||
|
|
@ -34,11 +36,15 @@ features = ["shape-run-cache"]
|
|||
[dependencies.libcosmic]
|
||||
git = "https://github.com/pop-os/libcosmic.git"
|
||||
default-features = false
|
||||
features = ["tokio", "winit"]
|
||||
features = ["multi-window", "tokio", "winit"]
|
||||
|
||||
[dependencies.smol_str]
|
||||
version = "0.2.1"
|
||||
features = ["serde"]
|
||||
|
||||
[features]
|
||||
default = ["wgpu"]
|
||||
wgpu = ["libcosmic/wgpu"]
|
||||
wgpu = ["libcosmic/wgpu", "cosmic-files/wgpu"]
|
||||
|
||||
[patch.crates-io]
|
||||
# https://github.com/rust-lang/libc/pull/3512
|
||||
|
|
|
|||
37
color-schemes/COSMIC Dark.ron
Normal file
37
color-schemes/COSMIC Dark.ron
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(
|
||||
name: "COSMIC Dark",
|
||||
foreground: "#C4C4C4",
|
||||
cursor: "#C4C4C4",
|
||||
bright_foreground: "#C4C4C4",
|
||||
dim_foreground: "#8E8E8E",
|
||||
normal: (
|
||||
black: "#1B1B1B",
|
||||
red: "#F16161",
|
||||
green: "#7CB987",
|
||||
yellow: "#DDC74C",
|
||||
blue: "#6296BE",
|
||||
magenta: "#BE6DEE",
|
||||
cyan: "#49BAC8",
|
||||
white: "#BEBEBE",
|
||||
),
|
||||
bright: (
|
||||
black: "#808080",
|
||||
red: "#FF8985",
|
||||
green: "#97D5A0",
|
||||
yellow: "#FAE365",
|
||||
blue: "#7DB1DA",
|
||||
magenta: "#D68EFF",
|
||||
cyan: "#49BAC8",
|
||||
white: "#C4C4C4",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#A04040",
|
||||
green: "#5D7D62",
|
||||
yellow: "#9E914A",
|
||||
blue: "#486073",
|
||||
magenta: "#7F46A1",
|
||||
cyan: "#3F7F87",
|
||||
white: "#898989",
|
||||
),
|
||||
)
|
||||
37
color-schemes/COSMIC Light.ron
Normal file
37
color-schemes/COSMIC Light.ron
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(
|
||||
name: "COSMIC Light",
|
||||
foreground: "#292929",
|
||||
cursor: "#292929",
|
||||
bright_foreground: "#808080",
|
||||
dim_foreground: "#181818",
|
||||
normal: (
|
||||
black: "#292929",
|
||||
red: "#8C151F",
|
||||
green: "#145129",
|
||||
yellow: "#624000",
|
||||
blue: "#003F5F",
|
||||
magenta: "#6D169C",
|
||||
cyan: "#004F57",
|
||||
white: "#BEBEBE",
|
||||
),
|
||||
bright: (
|
||||
black: "#808080",
|
||||
red: "#9D2329",
|
||||
green: "#235D34",
|
||||
yellow: "#714B00",
|
||||
blue: "#054B6F",
|
||||
magenta: "#7A28A9",
|
||||
cyan: "#005C5D",
|
||||
white: "#D7D7D7",
|
||||
),
|
||||
dim: (
|
||||
black: "#181818",
|
||||
red: "#652020",
|
||||
green: "#183C22",
|
||||
yellow: "#4A320A",
|
||||
blue: "#072D44",
|
||||
magenta: "#50256D",
|
||||
cyan: "#0B3C41",
|
||||
white: "#ABABAB",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Linux Console.ron
Normal file
38
color-schemes/Linux Console.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Linux Console",
|
||||
foreground: "#FFFFFF",
|
||||
background: "#000000",
|
||||
cursor: "#FFFFFF",
|
||||
bright_foreground: "#AAAAAA",
|
||||
dim_foreground: "#E2E2E2",
|
||||
normal: (
|
||||
black: "#000000",
|
||||
red: "#AA0000",
|
||||
green: "#00AA00",
|
||||
yellow: "#AA5500",
|
||||
blue: "#0000AA",
|
||||
magenta: "#AA00AA",
|
||||
cyan: "#00AAAA",
|
||||
white: "#AAAAAA",
|
||||
),
|
||||
bright: (
|
||||
black: "#555555",
|
||||
red: "#FF5555",
|
||||
green: "#55FF55",
|
||||
yellow: "#FFFF55",
|
||||
blue: "#5555FF",
|
||||
magenta: "#FF55FF",
|
||||
cyan: "#55FFFF",
|
||||
white: "#FFFFFF",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#70221A",
|
||||
green: "#458340",
|
||||
yellow: "#814514",
|
||||
blue: "#0A1B44",
|
||||
magenta: "#7E1B7E",
|
||||
cyan: "#278B8B",
|
||||
white: "#8F8F8F",
|
||||
),
|
||||
)
|
||||
38
color-schemes/OneHalfDark.ron
Normal file
38
color-schemes/OneHalfDark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "OneHalfDark",
|
||||
foreground: "#DCDFE4",
|
||||
background: "#282C34",
|
||||
cursor: "#FBFBFC",
|
||||
bright_foreground: "#FBFBFC",
|
||||
dim_foreground: "#A8A8A8",
|
||||
normal: (
|
||||
black: "#282C34",
|
||||
red: "#E06C75",
|
||||
green: "#98C379",
|
||||
yellow: "#E5C07B",
|
||||
blue: "#61AFEF",
|
||||
magenta: "#C678DD",
|
||||
cyan: "#56B6C2",
|
||||
white: "#DCDFE4",
|
||||
),
|
||||
bright: (
|
||||
black: "#5D677A",
|
||||
red: "#EE9397",
|
||||
green: "#B6DE9B",
|
||||
yellow: "#F4DFB8",
|
||||
blue: "#94C9F8",
|
||||
magenta: "#D89EE9",
|
||||
cyan: "#74D2DE",
|
||||
white: "#FBFBFC",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#904A4F",
|
||||
green: "#6F885F",
|
||||
yellow: "#A68C5D",
|
||||
blue: "#3E79A8",
|
||||
magenta: "#855194",
|
||||
cyan: "#467B82",
|
||||
white: "#A8A8A8",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Pop Dark.ron
Normal file
38
color-schemes/Pop Dark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Pop Dark",
|
||||
foreground: "#F2F2F2",
|
||||
background: "#333333",
|
||||
cursor: "#EEEEEC",
|
||||
bright_foreground: "#EEEEEC",
|
||||
dim_foreground: "#E4E4E4",
|
||||
normal: (
|
||||
black: "#333333",
|
||||
red: "#CC0000",
|
||||
green: "#4E9A06",
|
||||
yellow: "#C4A000",
|
||||
blue: "#3465A4",
|
||||
magenta: "#75507B",
|
||||
cyan: "#06989A",
|
||||
white: "#D3D7CF",
|
||||
),
|
||||
bright: (
|
||||
black: "#88807C",
|
||||
red: "#F15D22",
|
||||
green: "#73C48F",
|
||||
yellow: "#FFCE51",
|
||||
blue: "#48B9C7",
|
||||
magenta: "#AD7FA8",
|
||||
cyan: "#34E2E2",
|
||||
white: "#EEEEEC",
|
||||
),
|
||||
dim: (
|
||||
black: "#272727",
|
||||
red: "#A1362B",
|
||||
green: "#558737",
|
||||
yellow: "#B1942D",
|
||||
blue: "#3B5981",
|
||||
magenta: "#5D4D5F",
|
||||
cyan: "#288889",
|
||||
white: "#C7C7C7",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Rxvt Dark.ron
Normal file
38
color-schemes/Rxvt Dark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Rxvt Dark",
|
||||
foreground: "#FFFFFF",
|
||||
background: "#000000",
|
||||
cursor: "#FFFFFF",
|
||||
bright_foreground: "#FAEBD7",
|
||||
dim_foreground: "#DDDDDD",
|
||||
normal: (
|
||||
black: "#000000",
|
||||
red: "#CD0000",
|
||||
green: "#00CD00",
|
||||
yellow: "#CDCD00",
|
||||
blue: "#0000CD",
|
||||
magenta: "#CD00CD",
|
||||
cyan: "#00CDCD",
|
||||
white: "#FAEBD7",
|
||||
),
|
||||
bright: (
|
||||
black: "#404040",
|
||||
red: "#FF0000",
|
||||
green: "#00FF00",
|
||||
yellow: "#FFFF00",
|
||||
blue: "#0000FF",
|
||||
magenta: "#FF00FF",
|
||||
cyan: "#00FFFF",
|
||||
white: "#FFFFFF",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#872B22",
|
||||
green: "#549E4E",
|
||||
yellow: "#AAAB34",
|
||||
blue: "#0F2353",
|
||||
magenta: "#972596",
|
||||
cyan: "#31A7A6",
|
||||
white: "#E3C7A1",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Rxvt Light.ron
Normal file
38
color-schemes/Rxvt Light.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Rxvt Light",
|
||||
foreground: "#000000",
|
||||
background: "#FFFFFF",
|
||||
cursor: "#000000",
|
||||
bright_foreground: "#404040",
|
||||
dim_foreground: "#000000",
|
||||
normal: (
|
||||
black: "#000000",
|
||||
red: "#CD0000",
|
||||
green: "#00CD00",
|
||||
yellow: "#CDCD00",
|
||||
blue: "#0000CD",
|
||||
magenta: "#CD00CD",
|
||||
cyan: "#00CDCD",
|
||||
white: "#FAEBD7",
|
||||
),
|
||||
bright: (
|
||||
black: "#404040",
|
||||
red: "#FF0000",
|
||||
green: "#00FF00",
|
||||
yellow: "#FFFF00",
|
||||
blue: "#0000FF",
|
||||
magenta: "#FF00FF",
|
||||
cyan: "#00FFFF",
|
||||
white: "#FFFFFF",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#691F18",
|
||||
green: "#468742",
|
||||
yellow: "#94952C",
|
||||
blue: "#051130",
|
||||
magenta: "#7A1A7A",
|
||||
cyan: "#288F8F",
|
||||
white: "#D2B081",
|
||||
),
|
||||
)
|
||||
37
color-schemes/Selenized Black.ron
Normal file
37
color-schemes/Selenized Black.ron
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(
|
||||
name: "Selenized Black",
|
||||
foreground: "#B9B9B9",
|
||||
background: "#181818",
|
||||
cursor: "#777777",
|
||||
dim_foreground: "#848484",
|
||||
normal: (
|
||||
black: "#252525",
|
||||
red: "#ED4A46",
|
||||
green: "#70B433",
|
||||
yellow: "#DBB32D",
|
||||
blue: "#368AEB",
|
||||
magenta: "#EB6EB7",
|
||||
cyan: "#3FC5B7",
|
||||
white: "#777777",
|
||||
),
|
||||
bright: (
|
||||
black: "#3B3B3B",
|
||||
red: "#FF5E56",
|
||||
green: "#83C746",
|
||||
yellow: "#EFC541",
|
||||
blue: "#4F9CFE",
|
||||
magenta: "#FF81CA",
|
||||
cyan: "#56D8C9",
|
||||
white: "#DEDEDE",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#923833",
|
||||
green: "#527736",
|
||||
yellow: "#988038",
|
||||
blue: "#285892",
|
||||
magenta: "#A2497D",
|
||||
cyan: "#3E877F",
|
||||
white: "#464646",
|
||||
),
|
||||
)
|
||||
37
color-schemes/Selenized Dark.ron
Normal file
37
color-schemes/Selenized Dark.ron
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(
|
||||
name: "Selenized Dark",
|
||||
foreground: "#ADBCBC",
|
||||
background: "#103C48",
|
||||
cursor: "#72898F",
|
||||
dim_foreground: "#838383",
|
||||
normal: (
|
||||
black: "#184956",
|
||||
red: "#FA5750",
|
||||
green: "#75B938",
|
||||
yellow: "#DBB32D",
|
||||
blue: "#4695F7",
|
||||
magenta: "#F275BE",
|
||||
cyan: "#41C7B9",
|
||||
white: "#72898F",
|
||||
),
|
||||
bright: (
|
||||
black: "#2D5B69",
|
||||
red: "#FF665C",
|
||||
green: "#84C747",
|
||||
yellow: "#EBC13D",
|
||||
blue: "#58A3FF",
|
||||
magenta: "#FF84CD",
|
||||
cyan: "#53D6C7",
|
||||
white: "#CAD8D9",
|
||||
),
|
||||
dim: (
|
||||
black: "#061519",
|
||||
red: "#A63A35",
|
||||
green: "#567C39",
|
||||
yellow: "#988038",
|
||||
blue: "#2B62A6",
|
||||
magenta: "#AF4885",
|
||||
cyan: "#3F8981",
|
||||
white: "#525252",
|
||||
),
|
||||
)
|
||||
37
color-schemes/Selenized Light.ron
Normal file
37
color-schemes/Selenized Light.ron
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(
|
||||
name: "Selenized Light",
|
||||
foreground: "#53676D",
|
||||
background: "#FBF3DB",
|
||||
cursor: "#ECE3CC",
|
||||
dim_foreground: "#333333",
|
||||
normal: (
|
||||
black: "#ECE3CC",
|
||||
red: "#D2212D",
|
||||
green: "#489100",
|
||||
yellow: "#AD8900",
|
||||
blue: "#0072D4",
|
||||
magenta: "#CA4898",
|
||||
cyan: "#009C8F",
|
||||
white: "#909995",
|
||||
),
|
||||
bright: (
|
||||
black: "#D5CDB6",
|
||||
red: "#CC1729",
|
||||
green: "#428B00",
|
||||
yellow: "#A78300",
|
||||
blue: "#006DCE",
|
||||
magenta: "#C44392",
|
||||
cyan: "#00978A",
|
||||
white: "#3A4D53",
|
||||
),
|
||||
dim: (
|
||||
black: "#B5AC95",
|
||||
red: "#722423",
|
||||
green: "#335520",
|
||||
yellow: "#6E5917",
|
||||
blue: "#124276",
|
||||
magenta: "#75365B",
|
||||
cyan: "#1A6159",
|
||||
white: "#636363",
|
||||
),
|
||||
)
|
||||
37
color-schemes/Selenized White.ron
Normal file
37
color-schemes/Selenized White.ron
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(
|
||||
name: "Selenized White",
|
||||
foreground: "#474747",
|
||||
background: "#FFFFFF",
|
||||
cursor: "#EBEBEB",
|
||||
dim_foreground: "#181818",
|
||||
normal: (
|
||||
black: "#EBEBEB",
|
||||
red: "#D6000C",
|
||||
green: "#1D9700",
|
||||
yellow: "#C49700",
|
||||
blue: "#0064E4",
|
||||
magenta: "#DD0F9D",
|
||||
cyan: "#00AD9C",
|
||||
white: "#878787",
|
||||
),
|
||||
bright: (
|
||||
black: "#CDCDCD",
|
||||
red: "#BF0000",
|
||||
green: "#008400",
|
||||
yellow: "#AF8500",
|
||||
blue: "#0054CF",
|
||||
magenta: "#C7008B",
|
||||
cyan: "#009A8A",
|
||||
white: "#282828",
|
||||
),
|
||||
dim: (
|
||||
black: "#B3B3B3",
|
||||
red: "#71221B",
|
||||
green: "#2D5727",
|
||||
yellow: "#82661D",
|
||||
blue: "#153B75",
|
||||
magenta: "#841D5F",
|
||||
cyan: "#207166",
|
||||
white: "#555555",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Solarized Dark.ron
Normal file
38
color-schemes/Solarized Dark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Solarized Dark",
|
||||
foreground: "#839496",
|
||||
background: "#002B36",
|
||||
cursor: "#839496",
|
||||
bright_foreground: "#268BD2",
|
||||
dim_foreground: "#5D5D5D",
|
||||
normal: (
|
||||
black: "#073642",
|
||||
red: "#DC322F",
|
||||
green: "#859900",
|
||||
yellow: "#B58900",
|
||||
blue: "#268BD2",
|
||||
magenta: "#D33682",
|
||||
cyan: "#2AA198",
|
||||
white: "#EEE8D5",
|
||||
),
|
||||
bright: (
|
||||
black: "#002B36",
|
||||
red: "#CB4B16",
|
||||
green: "#586E75",
|
||||
yellow: "#657B83",
|
||||
blue: "#839496",
|
||||
magenta: "#6C71C4",
|
||||
cyan: "#93A1A1",
|
||||
white: "#FDF6E3",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#7D2C26",
|
||||
green: "#56621A",
|
||||
yellow: "#745918",
|
||||
blue: "#23577E",
|
||||
magenta: "#792E4E",
|
||||
cyan: "#296661",
|
||||
white: "#B7B09C",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Solarized Light.ron
Normal file
38
color-schemes/Solarized Light.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Solarized Light",
|
||||
foreground: "#657B83",
|
||||
background: "#FDF6E3",
|
||||
cursor: "#657B83",
|
||||
bright_foreground: "#B58900",
|
||||
dim_foreground: "#454545",
|
||||
normal: (
|
||||
black: "#073642",
|
||||
red: "#DC322F",
|
||||
green: "#859900",
|
||||
yellow: "#B58900",
|
||||
blue: "#268BD2",
|
||||
magenta: "#D33682",
|
||||
cyan: "#2AA198",
|
||||
white: "#EEE8D5",
|
||||
),
|
||||
bright: (
|
||||
black: "#002B36",
|
||||
red: "#CB4B16",
|
||||
green: "#586E75",
|
||||
yellow: "#657B83",
|
||||
blue: "#839496",
|
||||
magenta: "#6C71C4",
|
||||
cyan: "#93A1A1",
|
||||
white: "#FDF6E3",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#7D2C26",
|
||||
green: "#56621A",
|
||||
yellow: "#745918",
|
||||
blue: "#23577E",
|
||||
magenta: "#792E4E",
|
||||
cyan: "#296661",
|
||||
white: "#B7B09C",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Tango Dark.ron
Normal file
38
color-schemes/Tango Dark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Tango Dark",
|
||||
foreground: "#D3D7CF",
|
||||
background: "#2E3436",
|
||||
cursor: "#D3D7CF",
|
||||
bright_foreground: "#EEEEEC",
|
||||
dim_foreground: "#BABABA",
|
||||
normal: (
|
||||
black: "#2E3436",
|
||||
red: "#CC0000",
|
||||
green: "#4E9A06",
|
||||
yellow: "#C4A000",
|
||||
blue: "#3465A4",
|
||||
magenta: "#75507B",
|
||||
cyan: "#06989A",
|
||||
white: "#D3D7CF",
|
||||
),
|
||||
bright: (
|
||||
black: "#555753",
|
||||
red: "#EF2929",
|
||||
green: "#8AE234",
|
||||
yellow: "#FCE94F",
|
||||
blue: "#729FCF",
|
||||
magenta: "#AD7FA8",
|
||||
cyan: "#34E2E2",
|
||||
white: "#EEEEEC",
|
||||
),
|
||||
dim: (
|
||||
black: "#1B1B1B",
|
||||
red: "#8E2E24",
|
||||
green: "#4B7930",
|
||||
yellow: "#A28728",
|
||||
blue: "#324D71",
|
||||
magenta: "#504252",
|
||||
cyan: "#237A7B",
|
||||
white: "#BABABA",
|
||||
),
|
||||
)
|
||||
38
color-schemes/Tango Light.ron
Normal file
38
color-schemes/Tango Light.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "Tango Light",
|
||||
foreground: "#2E3436",
|
||||
background: "#EEEEEC",
|
||||
cursor: "#2E3436",
|
||||
bright_foreground: "#555753",
|
||||
dim_foreground: "#010101",
|
||||
normal: (
|
||||
black: "#2E3436",
|
||||
red: "#CC0000",
|
||||
green: "#4E9A06",
|
||||
yellow: "#C4A000",
|
||||
blue: "#3465A4",
|
||||
magenta: "#75507B",
|
||||
cyan: "#06989A",
|
||||
white: "#D3D7CF",
|
||||
),
|
||||
bright: (
|
||||
black: "#555753",
|
||||
red: "#EF2929",
|
||||
green: "#8AE234",
|
||||
yellow: "#FCE94F",
|
||||
blue: "#729FCF",
|
||||
magenta: "#AD7FA8",
|
||||
cyan: "#34E2E2",
|
||||
white: "#EEEEEC",
|
||||
),
|
||||
dim: (
|
||||
black: "#010101",
|
||||
red: "#681F18",
|
||||
green: "#395D24",
|
||||
yellow: "#846E1F",
|
||||
blue: "#213550",
|
||||
magenta: "#362C37",
|
||||
cyan: "#195E5F",
|
||||
white: "#9F9F9F",
|
||||
),
|
||||
)
|
||||
38
color-schemes/XTerm Dark.ron
Normal file
38
color-schemes/XTerm Dark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "XTerm Dark",
|
||||
foreground: "#FFFFFF",
|
||||
background: "#000000",
|
||||
cursor: "#FFFFFF",
|
||||
bright_foreground: "#E5E5E5",
|
||||
dim_foreground: "#DDDDDD",
|
||||
normal: (
|
||||
black: "#000000",
|
||||
red: "#CD0000",
|
||||
green: "#00CD00",
|
||||
yellow: "#CDCD00",
|
||||
blue: "#0000EE",
|
||||
magenta: "#CD00CD",
|
||||
cyan: "#00CDCD",
|
||||
white: "#E5E5E5",
|
||||
),
|
||||
bright: (
|
||||
black: "#7F7F7F",
|
||||
red: "#FF0000",
|
||||
green: "#00FF00",
|
||||
yellow: "#FFFF00",
|
||||
blue: "#5C5CFF",
|
||||
magenta: "#FF00FF",
|
||||
cyan: "#00FFFF",
|
||||
white: "#FFFFFF",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#872B22",
|
||||
green: "#549E4E",
|
||||
yellow: "#AAAB34",
|
||||
blue: "#152E69",
|
||||
magenta: "#972596",
|
||||
cyan: "#31A7A6",
|
||||
white: "#C3C3C3",
|
||||
),
|
||||
)
|
||||
38
color-schemes/XTerm Light.ron
Normal file
38
color-schemes/XTerm Light.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "XTerm Light",
|
||||
foreground: "#000000",
|
||||
background: "#FFFFFF",
|
||||
cursor: "#000000",
|
||||
bright_foreground: "#7F7F7F",
|
||||
dim_foreground: "#000000",
|
||||
normal: (
|
||||
black: "#000000",
|
||||
red: "#CD0000",
|
||||
green: "#00CD00",
|
||||
yellow: "#CDCD00",
|
||||
blue: "#0000EE",
|
||||
magenta: "#CD00CD",
|
||||
cyan: "#00CDCD",
|
||||
white: "#E5E5E5",
|
||||
),
|
||||
bright: (
|
||||
black: "#7F7F7F",
|
||||
red: "#FF0000",
|
||||
green: "#00FF00",
|
||||
yellow: "#FFFF00",
|
||||
blue: "#5C5CFF",
|
||||
magenta: "#FF00FF",
|
||||
cyan: "#00FFFF",
|
||||
white: "#FFFFFF",
|
||||
),
|
||||
dim: (
|
||||
black: "#000000",
|
||||
red: "#691F18",
|
||||
green: "#468742",
|
||||
yellow: "#94952C",
|
||||
blue: "#0B1D47",
|
||||
magenta: "#7A1A7A",
|
||||
cyan: "#288F8F",
|
||||
white: "#AEAEAE",
|
||||
),
|
||||
)
|
||||
38
color-schemes/gruvbox-dark.ron
Normal file
38
color-schemes/gruvbox-dark.ron
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(
|
||||
name: "gruvbox-dark",
|
||||
foreground: "#EBDBB2",
|
||||
background: "#282828",
|
||||
cursor: "#EBDBB2",
|
||||
bright_foreground: "#EBDBB2",
|
||||
dim_foreground: "#C0B28D",
|
||||
normal: (
|
||||
black: "#282828",
|
||||
red: "#CC241D",
|
||||
green: "#98971A",
|
||||
yellow: "#D79921",
|
||||
blue: "#458588",
|
||||
magenta: "#B16286",
|
||||
cyan: "#689D6A",
|
||||
white: "#A89984",
|
||||
),
|
||||
bright: (
|
||||
black: "#928374",
|
||||
red: "#FB4934",
|
||||
green: "#B8BB26",
|
||||
yellow: "#FABD2F",
|
||||
blue: "#83A598",
|
||||
magenta: "#D3869B",
|
||||
cyan: "#8EC07C",
|
||||
white: "#EBDBB2",
|
||||
),
|
||||
dim: (
|
||||
black: "#020202",
|
||||
red: "#7F2C24",
|
||||
green: "#6F6F29",
|
||||
yellow: "#A07732",
|
||||
blue: "#3A5A5C",
|
||||
magenta: "#724D5D",
|
||||
cyan: "#547055",
|
||||
white: "#747474",
|
||||
),
|
||||
)
|
||||
|
|
@ -2,6 +2,14 @@ new-terminal = New terminal
|
|||
|
||||
# Context Pages
|
||||
|
||||
## Color schemes
|
||||
color-schemes = Color schemes
|
||||
rename = Rename
|
||||
export = Export
|
||||
delete = Delete
|
||||
import = Import
|
||||
import-errors = Import errors
|
||||
|
||||
## Profiles
|
||||
profiles = Profiles
|
||||
name = Name
|
||||
|
|
@ -78,4 +86,5 @@ previous-tab = Previous tab
|
|||
split-horizontal = Split horizontal
|
||||
split-vertical = Split vertical
|
||||
pane-toggle-maximize = Toggle maximized
|
||||
menu-color-schemes = Color schemes...
|
||||
menu-settings = Settings...
|
||||
|
|
|
|||
11
res/icons/dialog-error-symbolic.svg
Normal file
11
res/icons/dialog-error-symbolic.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_412_3875)">
|
||||
<path d="M0 0H16V16H0V0Z" fill="#808080" fill-opacity="0.01"/>
|
||||
<path d="M8 1C6.14348 1 4.36301 1.7375 3.05025 3.05025C1.7375 4.36301 1 6.14348 1 8C1 9.85652 1.7375 11.637 3.05025 12.9497C4.36301 14.2625 6.14348 15 8 15C9.85652 15 11.637 14.2625 12.9497 12.9497C14.2625 11.637 15 9.85652 15 8C15 6.14348 14.2625 4.36301 12.9497 3.05025C11.637 1.7375 9.85652 1 8 1ZM7 3H9V9.004H7V3ZM7 11.004H9V13H7V11.004Z" fill="#F44336"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_412_3875">
|
||||
<rect width="16" height="16" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 670 B |
10
res/icons/view-more-symbolic.svg
Normal file
10
res/icons/view-more-symbolic.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_409_3577)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 2C10 1.46957 9.78926 0.960858 9.41418 0.585785C9.03911 0.210712 8.53043 0 8 0C7.46957 0 6.96089 0.210712 6.58582 0.585785C6.21074 0.960858 6 1.46957 6 2C6 2.53043 6.21074 3.03914 6.58582 3.41422C6.96089 3.78929 7.46957 4 8 4C8.53043 4 9.03911 3.78929 9.41418 3.41422C9.78926 3.03914 10 2.53043 10 2ZM10 8C10 7.46957 9.78926 6.96086 9.41418 6.58578C9.03911 6.21071 8.53043 6 8 6C7.46957 6 6.96089 6.21071 6.58582 6.58578C6.21074 6.96086 6 7.46957 6 8C6 8.53043 6.21074 9.03914 6.58582 9.41422C6.96089 9.78929 7.46957 10 8 10C8.53043 10 9.03911 9.78929 9.41418 9.41422C9.78926 9.03914 10 8.53043 10 8ZM10 14C10 13.4696 9.78926 12.9609 9.41418 12.5858C9.03911 12.2107 8.53043 12 8 12C7.46957 12 6.96089 12.2107 6.58582 12.5858C6.21074 12.9609 6 13.4696 6 14C6 14.5304 6.21074 15.0391 6.58582 15.4142C6.96089 15.7893 7.46957 16 8 16C8.53043 16 9.03911 15.7893 9.41418 15.4142C9.78926 15.0391 10 14.5304 10 14Z" fill="#232323"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_409_3577">
|
||||
<rect width="16" height="16" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
157
src/config.rs
157
src/config.rs
|
|
@ -5,6 +5,7 @@ use cosmic::{
|
|||
theme,
|
||||
};
|
||||
use cosmic_text::{Metrics, Stretch, Weight};
|
||||
use hex_color::HexColor;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -31,6 +32,139 @@ impl AppTheme {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct ColorSchemeId(pub u64);
|
||||
|
||||
//TODO: there is a lot of extra code to keep the exported color scheme clean,
|
||||
//consider how to reduce this
|
||||
fn de_color_opt<'de, D>(deserializer: D) -> Result<Option<HexColor>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let hex_color: HexColor = Deserialize::deserialize(deserializer)?;
|
||||
Ok(Some(hex_color))
|
||||
}
|
||||
|
||||
fn ser_color_opt<S>(hex_color_opt: &Option<HexColor>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::Error as _;
|
||||
match hex_color_opt {
|
||||
Some(hex_color) => Serialize::serialize(hex_color, serializer),
|
||||
None => Err(S::Error::custom("ser_color_opt called with None")),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct ColorSchemeAnsi {
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub black: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub red: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub green: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub yellow: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub blue: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub magenta: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub cyan: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub white: Option<HexColor>,
|
||||
}
|
||||
|
||||
impl ColorSchemeAnsi {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.black.is_none()
|
||||
&& self.red.is_none()
|
||||
&& self.green.is_none()
|
||||
&& self.yellow.is_none()
|
||||
&& self.blue.is_none()
|
||||
&& self.magenta.is_none()
|
||||
&& self.cyan.is_none()
|
||||
&& self.white.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct ColorScheme {
|
||||
pub name: String,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub foreground: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub background: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub cursor: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub bright_foreground: Option<HexColor>,
|
||||
#[serde(
|
||||
deserialize_with = "de_color_opt",
|
||||
serialize_with = "ser_color_opt",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub dim_foreground: Option<HexColor>,
|
||||
#[serde(skip_serializing_if = "ColorSchemeAnsi::is_empty")]
|
||||
pub normal: ColorSchemeAnsi,
|
||||
#[serde(skip_serializing_if = "ColorSchemeAnsi::is_empty")]
|
||||
pub bright: ColorSchemeAnsi,
|
||||
#[serde(skip_serializing_if = "ColorSchemeAnsi::is_empty")]
|
||||
pub dim: ColorSchemeAnsi,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct ProfileId(pub u64);
|
||||
|
|
@ -63,6 +197,7 @@ impl Default for Profile {
|
|||
#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct Config {
|
||||
pub app_theme: AppTheme,
|
||||
pub color_schemes: BTreeMap<ColorSchemeId, ColorScheme>,
|
||||
pub font_name: String,
|
||||
pub font_size: u16,
|
||||
pub font_weight: u16,
|
||||
|
|
@ -84,6 +219,7 @@ impl Default for Config {
|
|||
Self {
|
||||
app_theme: AppTheme::System,
|
||||
bold_font_weight: Weight::BOLD.0,
|
||||
color_schemes: BTreeMap::new(),
|
||||
dim_font_weight: Weight::NORMAL.0,
|
||||
focus_follow_mouse: false,
|
||||
font_name: "Fira Mono".to_string(),
|
||||
|
|
@ -102,6 +238,25 @@ impl Default for Config {
|
|||
}
|
||||
|
||||
impl Config {
|
||||
// Get a sorted and adjusted for duplicates list of color scheme names and ids
|
||||
pub fn color_scheme_names(&self) -> Vec<(String, ColorSchemeId)> {
|
||||
let mut color_scheme_names =
|
||||
Vec::<(String, ColorSchemeId)>::with_capacity(self.color_schemes.len());
|
||||
for (color_scheme_id, color_scheme) in self.color_schemes.iter() {
|
||||
let mut name = color_scheme.name.clone();
|
||||
|
||||
let mut copies = 1;
|
||||
while color_scheme_names.iter().find(|x| x.0 == name).is_some() {
|
||||
copies += 1;
|
||||
name = format!("{} ({})", color_scheme.name, copies);
|
||||
}
|
||||
|
||||
color_scheme_names.push((name, *color_scheme_id));
|
||||
}
|
||||
color_scheme_names.sort_by(|a, b| lexical_sort::natural_lexical_cmp(&a.0, &b.0));
|
||||
color_scheme_names
|
||||
}
|
||||
|
||||
fn font_size_adjusted(&self, zoom_adj: i8) -> f32 {
|
||||
let font_size = f32::from(self.font_size).max(1.0);
|
||||
let adj = f32::from(zoom_adj);
|
||||
|
|
@ -120,7 +275,7 @@ impl Config {
|
|||
(self.opacity as f32) / 100.0
|
||||
}
|
||||
|
||||
// Get a sorted and adjusted for duplicates list of profiles names and ids
|
||||
// Get a sorted and adjusted for duplicates list of profile names and ids
|
||||
pub fn profile_names(&self) -> Vec<(String, ProfileId)> {
|
||||
let mut profile_names = Vec::<(String, ProfileId)>::with_capacity(self.profiles.len());
|
||||
for (profile_id, profile) in self.profiles.iter() {
|
||||
|
|
|
|||
|
|
@ -30,11 +30,13 @@ impl IconCache {
|
|||
};
|
||||
}
|
||||
|
||||
bundle!("dialog-error-symbolic", 16);
|
||||
bundle!("edit-clear-symbolic", 16);
|
||||
bundle!("edit-delete-symbolic", 16);
|
||||
bundle!("list-add-symbolic", 16);
|
||||
bundle!("go-down-symbolic", 16);
|
||||
bundle!("go-up-symbolic", 16);
|
||||
bundle!("view-more-symbolic", 16);
|
||||
bundle!("window-close-symbolic", 16);
|
||||
|
||||
Self { cache }
|
||||
|
|
|
|||
331
src/main.rs
331
src/main.rs
|
|
@ -9,6 +9,7 @@ use cosmic::{
|
|||
cosmic_config::{self, ConfigSet, CosmicConfigEntry},
|
||||
cosmic_theme, executor,
|
||||
iced::{
|
||||
self,
|
||||
advanced::graphics::text::font_system,
|
||||
clipboard, event,
|
||||
futures::SinkExt,
|
||||
|
|
@ -20,17 +21,18 @@ use cosmic::{
|
|||
widget::{self, button, pane_grid, segmented_button, PaneGrid},
|
||||
Application, ApplicationExt, Element,
|
||||
};
|
||||
use cosmic_files::dialog::{Dialog, DialogKind, DialogMessage, DialogResult};
|
||||
use cosmic_text::{fontdb::FaceInfo, Family, Stretch, Weight};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
cmp,
|
||||
collections::{BTreeMap, BTreeSet, HashMap},
|
||||
env, process,
|
||||
env, fs, process,
|
||||
sync::{atomic::Ordering, Mutex},
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use config::{AppTheme, Config, Profile, ProfileId, CONFIG_VERSION};
|
||||
use config::{AppTheme, ColorScheme, ColorSchemeId, Config, Profile, ProfileId, CONFIG_VERSION};
|
||||
mod config;
|
||||
mod mouse_reporter;
|
||||
|
||||
|
|
@ -166,6 +168,7 @@ pub struct Flags {
|
|||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum Action {
|
||||
ColorSchemes,
|
||||
Copy,
|
||||
Find,
|
||||
PaneFocusDown,
|
||||
|
|
@ -204,6 +207,7 @@ pub enum Action {
|
|||
impl Action {
|
||||
pub fn message(self, entity_opt: Option<segmented_button::Entity>) -> Message {
|
||||
match self {
|
||||
Action::ColorSchemes => Message::ToggleContextPage(ContextPage::ColorSchemes),
|
||||
Action::Copy => Message::Copy(entity_opt),
|
||||
Action::Find => Message::Find(true),
|
||||
Action::PaneFocusDown => Message::PaneFocusAdjacent(pane_grid::Direction::Down),
|
||||
|
|
@ -245,6 +249,15 @@ impl Action {
|
|||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
AppTheme(AppTheme),
|
||||
ColorSchemeCollapse(ColorSchemeId),
|
||||
ColorSchemeDelete(ColorSchemeId),
|
||||
ColorSchemeExport(ColorSchemeId),
|
||||
ColorSchemeExportResult(ColorSchemeId, DialogResult),
|
||||
ColorSchemeExpand(ColorSchemeId),
|
||||
ColorSchemeRename(ColorSchemeId, String),
|
||||
ColorSchemeRenameSubmit,
|
||||
ColorSchemeImport,
|
||||
ColorSchemeImportResult(DialogResult),
|
||||
Config(Config),
|
||||
Copy(Option<segmented_button::Entity>),
|
||||
DefaultFont(usize),
|
||||
|
|
@ -254,6 +267,7 @@ pub enum Message {
|
|||
DefaultDimFontWeight(usize),
|
||||
DefaultBoldFontWeight(usize),
|
||||
DefaultZoomStep(usize),
|
||||
DialogMessage(DialogMessage),
|
||||
Key(Modifiers, Key),
|
||||
Find(bool),
|
||||
FindNext,
|
||||
|
|
@ -306,6 +320,7 @@ pub enum Message {
|
|||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ContextPage {
|
||||
ColorSchemes,
|
||||
Profiles,
|
||||
Settings,
|
||||
}
|
||||
|
|
@ -313,6 +328,7 @@ pub enum ContextPage {
|
|||
impl ContextPage {
|
||||
fn title(&self) -> String {
|
||||
match self {
|
||||
Self::ColorSchemes => fl!("color-schemes"),
|
||||
Self::Profiles => fl!("profiles"),
|
||||
Self::Settings => fl!("settings"),
|
||||
}
|
||||
|
|
@ -343,6 +359,7 @@ pub struct App {
|
|||
theme_names: Vec<String>,
|
||||
themes: HashMap<String, TermColors>,
|
||||
context_page: ContextPage,
|
||||
dialog_opt: Option<Dialog<Message>>,
|
||||
terminal_ids: HashMap<pane_grid::Pane, widget::Id>,
|
||||
find: bool,
|
||||
find_search_id: widget::Id,
|
||||
|
|
@ -350,15 +367,47 @@ pub struct App {
|
|||
term_event_tx_opt: Option<mpsc::Sender<(pane_grid::Pane, segmented_button::Entity, TermEvent)>>,
|
||||
startup_options: Option<tty::Options>,
|
||||
term_config: TermConfig,
|
||||
color_scheme_errors: Vec<String>,
|
||||
color_scheme_expanded: Option<ColorSchemeId>,
|
||||
color_scheme_renaming: Option<(ColorSchemeId, String)>,
|
||||
color_scheme_rename_id: widget::Id,
|
||||
profile_expanded: Option<ProfileId>,
|
||||
show_advanced_font_settings: bool,
|
||||
modifiers: Modifiers,
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn update_color_schemes(&mut self) {
|
||||
self.themes = terminal_theme::terminal_themes();
|
||||
for (color_scheme_name, color_scheme_id) in self.config.color_scheme_names() {
|
||||
if let Some(color_scheme) = self.config.color_schemes.get(&color_scheme_id) {
|
||||
if self
|
||||
.themes
|
||||
.insert(color_scheme_name.clone(), color_scheme.into())
|
||||
.is_some()
|
||||
{
|
||||
log::warn!(
|
||||
"custom color scheme {:?} replaces builtin one",
|
||||
color_scheme_name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.theme_names.clear();
|
||||
for theme_name in self.themes.keys() {
|
||||
self.theme_names.push(theme_name.clone());
|
||||
}
|
||||
self.theme_names
|
||||
.sort_by(|a, b| lexical_sort::natural_lexical_cmp(a, b));
|
||||
}
|
||||
|
||||
fn update_config(&mut self) -> Command<Message> {
|
||||
let theme = self.config.app_theme.theme();
|
||||
|
||||
// Update color schemes
|
||||
self.update_color_schemes();
|
||||
|
||||
// Update terminal window background color
|
||||
{
|
||||
let color = Color::from(theme.cosmic().background.base);
|
||||
|
|
@ -399,6 +448,20 @@ impl App {
|
|||
self.update_config()
|
||||
}
|
||||
|
||||
fn save_color_schemes(&mut self) -> Command<Message> {
|
||||
// Optimized for just saving color_schemes
|
||||
if let Some(ref config_handler) = self.config_handler {
|
||||
match config_handler.set("color_schemes", &self.config.color_schemes) {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
log::error!("failed to save config: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.update_color_schemes();
|
||||
Command::none()
|
||||
}
|
||||
|
||||
fn save_profiles(&mut self) -> Command<Message> {
|
||||
// Optimized for just saving profiles
|
||||
if let Some(ref config_handler) = self.config_handler {
|
||||
|
|
@ -434,11 +497,14 @@ impl App {
|
|||
None => (String::new(), "COSMIC Terminal".to_string()),
|
||||
};
|
||||
self.set_header_title(header_title);
|
||||
Command::batch([self.set_window_title(window_title), self.update_focus()])
|
||||
Command::batch([
|
||||
self.set_window_title(window_title, window::Id::MAIN),
|
||||
self.update_focus(),
|
||||
])
|
||||
} else {
|
||||
log::error!("Failed to get the specific pane");
|
||||
Command::batch([
|
||||
self.set_window_title("COSMIC Terminal".to_string()),
|
||||
self.set_window_title("COSMIC Terminal".to_string(), window::Id::MAIN),
|
||||
self.update_focus(),
|
||||
])
|
||||
}
|
||||
|
|
@ -521,6 +587,90 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
fn color_schemes(&self) -> Element<Message> {
|
||||
let cosmic_theme::Spacing { space_xxxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
|
||||
let mut sections = Vec::with_capacity(2 + self.color_scheme_errors.len());
|
||||
|
||||
if !self.config.color_schemes.is_empty() {
|
||||
let mut section = widget::settings::view_section("");
|
||||
for (color_scheme_name, color_scheme_id) in self.config.color_scheme_names() {
|
||||
let expanded = self.color_scheme_expanded == Some(color_scheme_id);
|
||||
let renaming = match &self.color_scheme_renaming {
|
||||
Some((id, value)) if id == &color_scheme_id => Some(value),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let button = if expanded {
|
||||
widget::button(icon_cache_get("view-more-symbolic", 16))
|
||||
.on_press(Message::ColorSchemeCollapse(color_scheme_id))
|
||||
} else {
|
||||
widget::button(icon_cache_get("view-more-symbolic", 16))
|
||||
.on_press(Message::ColorSchemeExpand(color_scheme_id))
|
||||
}
|
||||
.style(style::Button::Icon);
|
||||
|
||||
let menu = menu::color_scheme_menu(color_scheme_id, &color_scheme_name);
|
||||
|
||||
let popover = widget::popover(button, menu).show_popup(expanded);
|
||||
|
||||
let item = match renaming {
|
||||
Some(value) => widget::settings::item_row(vec![
|
||||
widget::text_input("", value)
|
||||
.id(self.color_scheme_rename_id.clone())
|
||||
.on_input(move |value| {
|
||||
Message::ColorSchemeRename(color_scheme_id, value)
|
||||
})
|
||||
.on_submit(Message::ColorSchemeRenameSubmit)
|
||||
.into(),
|
||||
popover.into(),
|
||||
]),
|
||||
None => widget::settings::item::builder(color_scheme_name).control(popover),
|
||||
};
|
||||
section = section.add(item);
|
||||
}
|
||||
sections.push(section.into());
|
||||
}
|
||||
|
||||
sections.push(
|
||||
widget::row::with_children(vec![
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::button::standard(fl!("import"))
|
||||
.on_press(Message::ColorSchemeImport)
|
||||
.into(),
|
||||
])
|
||||
.into(),
|
||||
);
|
||||
|
||||
for error in self.color_scheme_errors.iter() {
|
||||
sections.push(
|
||||
widget::row::with_children(vec![
|
||||
icon_cache_get("dialog-error-symbolic", 16)
|
||||
.style(style::Svg::custom(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
widget::svg::Appearance {
|
||||
color: Some(cosmic.destructive_text_color().into()),
|
||||
}
|
||||
}))
|
||||
.into(),
|
||||
widget::text(error)
|
||||
.style(style::Text::Custom(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
//TODO: re-export in libcosmic
|
||||
iced::widget::text::Appearance {
|
||||
color: Some(cosmic.destructive_text_color().into()),
|
||||
}
|
||||
}))
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_xxxs)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
widget::settings::view_column(sections).into()
|
||||
}
|
||||
|
||||
fn profiles(&self) -> Element<Message> {
|
||||
let cosmic_theme::Spacing {
|
||||
space_s,
|
||||
|
|
@ -652,7 +802,7 @@ impl App {
|
|||
|
||||
let add_profile = widget::row::with_children(vec![
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::button(widget::text(fl!("add-profile")))
|
||||
widget::button::standard(fl!("add-profile"))
|
||||
.on_press(Message::ProfileNew)
|
||||
.into(),
|
||||
]);
|
||||
|
|
@ -1067,9 +1217,6 @@ impl Application for App {
|
|||
zoom_steps.push(zoom_step);
|
||||
}
|
||||
|
||||
let themes = terminal_theme::terminal_themes();
|
||||
let mut theme_names: Vec<_> = themes.keys().cloned().collect();
|
||||
theme_names.sort();
|
||||
let pane_model = TerminalPaneGrid::new(segmented_button::ModelBuilder::default().build());
|
||||
let mut terminal_ids = HashMap::new();
|
||||
terminal_ids.insert(pane_model.focus, widget::Id::unique());
|
||||
|
|
@ -1094,9 +1241,10 @@ impl Application for App {
|
|||
zoom_adj: 0,
|
||||
zoom_step_names,
|
||||
zoom_steps,
|
||||
theme_names,
|
||||
themes,
|
||||
theme_names: Vec::new(),
|
||||
themes: HashMap::new(),
|
||||
context_page: ContextPage::Settings,
|
||||
dialog_opt: None,
|
||||
terminal_ids,
|
||||
find: false,
|
||||
find_search_id: widget::Id::unique(),
|
||||
|
|
@ -1104,6 +1252,10 @@ impl Application for App {
|
|||
startup_options: flags.startup_options,
|
||||
term_config: flags.term_config,
|
||||
term_event_tx_opt: None,
|
||||
color_scheme_errors: Vec::new(),
|
||||
color_scheme_expanded: None,
|
||||
color_scheme_renaming: None,
|
||||
color_scheme_rename_id: widget::Id::unique(),
|
||||
profile_expanded: None,
|
||||
show_advanced_font_settings: false,
|
||||
modifiers: Modifiers::empty(),
|
||||
|
|
@ -1172,6 +1324,137 @@ impl Application for App {
|
|||
self.config.app_theme = app_theme;
|
||||
return self.save_config();
|
||||
}
|
||||
Message::ColorSchemeCollapse(_color_scheme_id) => {
|
||||
self.color_scheme_expanded = None;
|
||||
}
|
||||
Message::ColorSchemeDelete(color_scheme_id) => {
|
||||
self.color_scheme_expanded = None;
|
||||
self.config.color_schemes.remove(&color_scheme_id);
|
||||
return self.save_color_schemes();
|
||||
}
|
||||
Message::ColorSchemeExport(color_scheme_id) => {
|
||||
self.color_scheme_expanded = None;
|
||||
if let Some(color_scheme) = self.config.color_schemes.get(&color_scheme_id) {
|
||||
if self.dialog_opt.is_none() {
|
||||
let (dialog, command) = Dialog::new(
|
||||
DialogKind::SaveFile {
|
||||
filename: format!("{}.ron", color_scheme.name),
|
||||
},
|
||||
None,
|
||||
Message::DialogMessage,
|
||||
move |result| {
|
||||
Message::ColorSchemeExportResult(color_scheme_id.clone(), result)
|
||||
},
|
||||
);
|
||||
self.dialog_opt = Some(dialog);
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::ColorSchemeExportResult(color_scheme_id, result) => {
|
||||
//TODO: show errors in UI
|
||||
self.dialog_opt = None;
|
||||
if let DialogResult::Open(paths) = result {
|
||||
let path = &paths[0];
|
||||
if let Some(color_scheme) = self.config.color_schemes.get(&color_scheme_id) {
|
||||
match ron::ser::to_string_pretty(
|
||||
&color_scheme,
|
||||
ron::ser::PrettyConfig::new(),
|
||||
) {
|
||||
Ok(ron) => match fs::write(path, &ron) {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"failed to export {:?} to {:?}: {}",
|
||||
color_scheme_id,
|
||||
path,
|
||||
err
|
||||
);
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"failed to serialize color scheme {:?}: {}",
|
||||
color_scheme_id,
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::error!("failed to find color scheme {:?}", color_scheme_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::ColorSchemeExpand(color_scheme_id) => {
|
||||
self.color_scheme_expanded = Some(color_scheme_id);
|
||||
}
|
||||
Message::ColorSchemeRename(color_scheme_id, color_scheme_name) => {
|
||||
self.color_scheme_expanded = None;
|
||||
let focus = self.color_scheme_renaming.is_none();
|
||||
self.color_scheme_renaming = Some((color_scheme_id, color_scheme_name));
|
||||
if focus {
|
||||
return widget::text_input::focus(self.color_scheme_rename_id.clone());
|
||||
}
|
||||
}
|
||||
Message::ColorSchemeRenameSubmit => {
|
||||
if let Some((color_scheme_id, color_scheme_name)) =
|
||||
self.color_scheme_renaming.take()
|
||||
{
|
||||
if let Some(color_scheme) = self.config.color_schemes.get_mut(&color_scheme_id)
|
||||
{
|
||||
color_scheme.name = color_scheme_name;
|
||||
return self.save_color_schemes();
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::ColorSchemeImport => {
|
||||
if self.dialog_opt.is_none() {
|
||||
self.color_scheme_errors.clear();
|
||||
let (dialog, command) = Dialog::new(
|
||||
DialogKind::OpenMultipleFiles,
|
||||
None,
|
||||
Message::DialogMessage,
|
||||
move |result| Message::ColorSchemeImportResult(result),
|
||||
);
|
||||
self.dialog_opt = Some(dialog);
|
||||
return command;
|
||||
}
|
||||
}
|
||||
Message::ColorSchemeImportResult(result) => {
|
||||
self.dialog_opt = None;
|
||||
if let DialogResult::Open(paths) = result {
|
||||
self.color_scheme_errors.clear();
|
||||
for path in paths.iter() {
|
||||
let mut file = match fs::File::open(path) {
|
||||
Ok(ok) => ok,
|
||||
Err(err) => {
|
||||
self.color_scheme_errors
|
||||
.push(format!("Failed to open {:?}: {}", path, err));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
match ron::de::from_reader::<_, ColorScheme>(&mut file) {
|
||||
Ok(color_scheme) => {
|
||||
// Get next color_scheme ID
|
||||
let color_scheme_id = self
|
||||
.config
|
||||
.color_schemes
|
||||
.last_key_value()
|
||||
.map(|(id, _)| ColorSchemeId(id.0 + 1))
|
||||
.unwrap_or_default();
|
||||
self.config
|
||||
.color_schemes
|
||||
.insert(color_scheme_id, color_scheme);
|
||||
}
|
||||
Err(err) => {
|
||||
self.color_scheme_errors
|
||||
.push(format!("Failed to parse {:?}: {}", path, err));
|
||||
}
|
||||
}
|
||||
}
|
||||
return self.save_color_schemes();
|
||||
}
|
||||
}
|
||||
Message::Config(config) => {
|
||||
if config != self.config {
|
||||
log::info!("update config");
|
||||
|
|
@ -1285,6 +1568,11 @@ impl Application for App {
|
|||
log::warn!("failed to find zoom step with index {}", index);
|
||||
}
|
||||
},
|
||||
Message::DialogMessage(dialog_message) => {
|
||||
if let Some(dialog) = &mut self.dialog_opt {
|
||||
return dialog.update(dialog_message);
|
||||
}
|
||||
}
|
||||
Message::Key(modifiers, key) => {
|
||||
for (key_bind, action) in self.key_binds.iter() {
|
||||
if key_bind.matches(modifiers, &key) {
|
||||
|
|
@ -1767,6 +2055,17 @@ impl Application for App {
|
|||
self.context_page = context_page;
|
||||
self.core.window.show_context = true;
|
||||
}
|
||||
|
||||
// Extra work to do to prepare context pages
|
||||
match self.context_page {
|
||||
ContextPage::ColorSchemes => {
|
||||
self.color_scheme_errors.clear();
|
||||
self.color_scheme_expanded = None;
|
||||
self.color_scheme_renaming = None;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.set_context_title(context_page.title());
|
||||
}
|
||||
Message::ShowAdvancedFontSettings(show) => {
|
||||
|
|
@ -1809,6 +2108,7 @@ impl Application for App {
|
|||
}
|
||||
|
||||
Some(match self.context_page {
|
||||
ContextPage::ColorSchemes => self.color_schemes(),
|
||||
ContextPage::Profiles => self.profiles(),
|
||||
ContextPage::Settings => self.settings(),
|
||||
})
|
||||
|
|
@ -1827,6 +2127,13 @@ impl Application for App {
|
|||
.into()]
|
||||
}
|
||||
|
||||
fn view_window(&self, window_id: window::Id) -> Element<Message> {
|
||||
match &self.dialog_opt {
|
||||
Some(dialog) => dialog.view(window_id),
|
||||
None => widget::text("Unknown window ID").into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
|
|
@ -2026,6 +2333,10 @@ impl Application for App {
|
|||
cosmic_theme::ThemeMode::version(),
|
||||
)
|
||||
.map(|_update| Message::SystemThemeChange),
|
||||
match &self.dialog_opt {
|
||||
Some(dialog) => dialog.subscription(),
|
||||
None => subscription::Subscription::none(),
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
src/menu.rs
35
src/menu.rs
|
|
@ -17,7 +17,7 @@ use cosmic::{
|
|||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{fl, Action, Config, KeyBind, Message};
|
||||
use crate::{fl, Action, ColorSchemeId, Config, KeyBind, Message};
|
||||
|
||||
macro_rules! menu_button {
|
||||
($($x:expr),+ $(,)?) => (
|
||||
|
|
@ -108,6 +108,38 @@ pub fn context_menu<'a>(
|
|||
.into()
|
||||
}
|
||||
|
||||
pub fn color_scheme_menu<'a>(id: ColorSchemeId, name: &str) -> Element<'a, Message> {
|
||||
let menu_item = |label, message| menu_button!(widget::text(label)).on_press(message);
|
||||
|
||||
widget::container(column!(
|
||||
menu_item(
|
||||
fl!("rename"),
|
||||
Message::ColorSchemeRename(id, name.to_string())
|
||||
),
|
||||
menu_item(fl!("export"), Message::ColorSchemeExport(id)),
|
||||
menu_item(fl!("delete"), Message::ColorSchemeDelete(id)),
|
||||
))
|
||||
.padding(1)
|
||||
//TODO: move style to libcosmic
|
||||
.style(theme::Container::custom(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
widget::container::Appearance {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
background: Some(Background::Color(component.base.into())),
|
||||
border: Border {
|
||||
radius: 8.0.into(),
|
||||
width: 1.0,
|
||||
color: component.divider.into(),
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}))
|
||||
.width(Length::Fixed(120.0))
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message> {
|
||||
//TODO: port to libcosmic
|
||||
let menu_root = |label| {
|
||||
|
|
@ -185,6 +217,7 @@ pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap<KeyBind, Action>) -> El
|
|||
menu_item(fl!("split-vertical"), Action::PaneSplitVertical),
|
||||
menu_item(fl!("pane-toggle-maximize"), Action::PaneToggleMaximized),
|
||||
MenuTree::new(horizontal_rule(1)),
|
||||
menu_item(fl!("menu-color-schemes"), Action::ColorSchemes),
|
||||
menu_item(fl!("menu-settings"), Action::Settings),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@ use alacritty_terminal::{
|
|||
term::color::Colors,
|
||||
vte::ansi::{NamedColor, Rgb},
|
||||
};
|
||||
|
||||
use hex_color::HexColor;
|
||||
use palette::{encoding::Srgb, rgb::Rgb as PRgb, FromColor, Okhsl};
|
||||
use std::collections::HashMap;
|
||||
use std::{collections::HashMap, fs};
|
||||
|
||||
use crate::config::{ColorScheme, ColorSchemeAnsi};
|
||||
|
||||
// Fill missing dim/bright colors with derived values from normal ones.
|
||||
#[allow(dead_code)]
|
||||
struct ColorDerive {
|
||||
dim_saturation_adjustment: f32,
|
||||
dim_lightness_adjustment: f32,
|
||||
|
|
@ -14,6 +17,7 @@ struct ColorDerive {
|
|||
bright_lightness_adjustment: f32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ColorDerive {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
|
|
@ -138,311 +142,108 @@ fn auto_colors() -> Colors {
|
|||
colors
|
||||
}
|
||||
|
||||
fn tango_palette() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
impl From<&ColorScheme> for Colors {
|
||||
fn from(color_scheme: &ColorScheme) -> Self {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
let encode_rgb = |rgb_opt: Option<HexColor>| -> Option<Rgb> {
|
||||
let rgb = rgb_opt?;
|
||||
Some(Rgb {
|
||||
r: rgb.r,
|
||||
g: rgb.g,
|
||||
b: rgb.b,
|
||||
})
|
||||
};
|
||||
|
||||
// Set normal colors
|
||||
colors[NamedColor::Black] = encode_rgb(color_scheme.normal.black);
|
||||
colors[NamedColor::Red] = encode_rgb(color_scheme.normal.red);
|
||||
colors[NamedColor::Green] = encode_rgb(color_scheme.normal.green);
|
||||
colors[NamedColor::Yellow] = encode_rgb(color_scheme.normal.yellow);
|
||||
colors[NamedColor::Blue] = encode_rgb(color_scheme.normal.blue);
|
||||
colors[NamedColor::Magenta] = encode_rgb(color_scheme.normal.magenta);
|
||||
colors[NamedColor::Cyan] = encode_rgb(color_scheme.normal.cyan);
|
||||
colors[NamedColor::White] = encode_rgb(color_scheme.normal.white);
|
||||
|
||||
// Set bright colors
|
||||
colors[NamedColor::BrightBlack] = encode_rgb(color_scheme.bright.black);
|
||||
colors[NamedColor::BrightRed] = encode_rgb(color_scheme.bright.red);
|
||||
colors[NamedColor::BrightGreen] = encode_rgb(color_scheme.bright.green);
|
||||
colors[NamedColor::BrightYellow] = encode_rgb(color_scheme.bright.yellow);
|
||||
colors[NamedColor::BrightBlue] = encode_rgb(color_scheme.bright.blue);
|
||||
colors[NamedColor::BrightMagenta] = encode_rgb(color_scheme.bright.magenta);
|
||||
colors[NamedColor::BrightCyan] = encode_rgb(color_scheme.bright.cyan);
|
||||
colors[NamedColor::BrightWhite] = encode_rgb(color_scheme.bright.white);
|
||||
|
||||
// Set dim colors
|
||||
colors[NamedColor::DimBlack] = encode_rgb(color_scheme.dim.black);
|
||||
colors[NamedColor::DimRed] = encode_rgb(color_scheme.dim.red);
|
||||
colors[NamedColor::DimGreen] = encode_rgb(color_scheme.dim.green);
|
||||
colors[NamedColor::DimYellow] = encode_rgb(color_scheme.dim.yellow);
|
||||
colors[NamedColor::DimBlue] = encode_rgb(color_scheme.dim.blue);
|
||||
colors[NamedColor::DimMagenta] = encode_rgb(color_scheme.dim.magenta);
|
||||
colors[NamedColor::DimCyan] = encode_rgb(color_scheme.dim.cyan);
|
||||
colors[NamedColor::DimWhite] = encode_rgb(color_scheme.dim.white);
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = encode_rgb(color_scheme.foreground);
|
||||
colors[NamedColor::Background] = encode_rgb(color_scheme.background);
|
||||
colors[NamedColor::Cursor] = encode_rgb(color_scheme.cursor);
|
||||
colors[NamedColor::BrightForeground] = encode_rgb(color_scheme.bright_foreground);
|
||||
colors[NamedColor::DimForeground] = encode_rgb(color_scheme.dim_foreground);
|
||||
|
||||
colors
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(&str, &Colors)> for ColorScheme {
|
||||
fn from(tuple: (&str, &Colors)) -> Self {
|
||||
let (name, colors) = tuple;
|
||||
|
||||
let encode_rgb = |rgb_opt: Option<Rgb>| -> Option<HexColor> {
|
||||
let rgb = rgb_opt?;
|
||||
Some(HexColor::rgb(rgb.r, rgb.g, rgb.b))
|
||||
};
|
||||
|
||||
Self {
|
||||
name: name.to_string(),
|
||||
foreground: encode_rgb(colors[NamedColor::Foreground]),
|
||||
background: encode_rgb(colors[NamedColor::Background]),
|
||||
cursor: encode_rgb(colors[NamedColor::Cursor]),
|
||||
bright_foreground: encode_rgb(colors[NamedColor::BrightForeground]),
|
||||
dim_foreground: encode_rgb(colors[NamedColor::DimForeground]),
|
||||
normal: ColorSchemeAnsi {
|
||||
black: encode_rgb(colors[NamedColor::Black]),
|
||||
red: encode_rgb(colors[NamedColor::Red]),
|
||||
green: encode_rgb(colors[NamedColor::Green]),
|
||||
yellow: encode_rgb(colors[NamedColor::Yellow]),
|
||||
blue: encode_rgb(colors[NamedColor::Blue]),
|
||||
magenta: encode_rgb(colors[NamedColor::Magenta]),
|
||||
cyan: encode_rgb(colors[NamedColor::Cyan]),
|
||||
white: encode_rgb(colors[NamedColor::White]),
|
||||
},
|
||||
bright: ColorSchemeAnsi {
|
||||
black: encode_rgb(colors[NamedColor::BrightBlack]),
|
||||
red: encode_rgb(colors[NamedColor::BrightRed]),
|
||||
green: encode_rgb(colors[NamedColor::BrightGreen]),
|
||||
yellow: encode_rgb(colors[NamedColor::BrightYellow]),
|
||||
blue: encode_rgb(colors[NamedColor::BrightBlue]),
|
||||
magenta: encode_rgb(colors[NamedColor::BrightMagenta]),
|
||||
cyan: encode_rgb(colors[NamedColor::BrightCyan]),
|
||||
white: encode_rgb(colors[NamedColor::BrightWhite]),
|
||||
},
|
||||
dim: ColorSchemeAnsi {
|
||||
black: encode_rgb(colors[NamedColor::DimBlack]),
|
||||
red: encode_rgb(colors[NamedColor::DimRed]),
|
||||
green: encode_rgb(colors[NamedColor::DimGreen]),
|
||||
yellow: encode_rgb(colors[NamedColor::DimYellow]),
|
||||
blue: encode_rgb(colors[NamedColor::DimBlue]),
|
||||
magenta: encode_rgb(colors[NamedColor::DimMagenta]),
|
||||
cyan: encode_rgb(colors[NamedColor::DimCyan]),
|
||||
white: encode_rgb(colors[NamedColor::DimWhite]),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x2E3436));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xCC0000));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x4E9A06));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xC4A000));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x3465A4));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0x75507B));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x06989A));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xD3D7CF));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x555753));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xEF2929));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x8AE234));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFCE94F));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x729FCF));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xAD7FA8));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x34E2E2));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xEEEEEC));
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn tango_dark() -> Colors {
|
||||
let mut colors = tango_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::White];
|
||||
colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// Dim less so colors are readable with default bg
|
||||
.with_dim_lightness_adjustment(-0.10)
|
||||
.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn tango_light() -> Colors {
|
||||
let mut colors = tango_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::Black];
|
||||
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn linux_console_palette() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x000000));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xAA0000));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x00AA00));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xAA5500));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x0000AA));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xAA00AA));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x00AAAA));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xAAAAAA));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x555555));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF5555));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x55FF55));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFFFF55));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x5555FF));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF55FF));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x55FFFF));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFFFFFF));
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn linux_console() -> Colors {
|
||||
let mut colors = linux_console_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::White];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// Dim less so colors are readable with default bg
|
||||
.with_dim_lightness_adjustment(-0.10)
|
||||
.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn xterm_palette() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x000000));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xCD0000));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x00CD00));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xCDCD00));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x0000EE));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xCD00CD));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x00CDCD));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xE5E5E5));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x7F7F7F));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF0000));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x00FF00));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFFFF00));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x5C5CFF));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF00FF));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00FFFF));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFFFFFF));
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn xterm_dark() -> Colors {
|
||||
let mut colors = xterm_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::White];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// Dim less so colors are readable with default bg
|
||||
.with_dim_lightness_adjustment(-0.12)
|
||||
.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn xterm_light() -> Colors {
|
||||
let mut colors = xterm_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::Black];
|
||||
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn rxvt_palette() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x000000));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xCD0000));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x00CD00));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xCDCD00));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x0000CD));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xCD00CD));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x00CDCD));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xFAEBD7));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x404040));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF0000));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x00FF00));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFFFF00));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x0000FF));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF00FF));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00FFFF));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFFFFFF));
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn rxvt_dark() -> Colors {
|
||||
let mut colors = rxvt_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::White];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// Dim less so colors are readable with default bg
|
||||
.with_dim_lightness_adjustment(-0.12)
|
||||
.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn rxvt_light() -> Colors {
|
||||
let mut colors = rxvt_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::Black];
|
||||
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn solarized_palette() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x073642));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xDC322F));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x859900));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xB58900));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x268BD2));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xD33682));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x2AA198));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xEEE8D5));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x002B36));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xCB4B16));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x586E75));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0x657B83));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x839496));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0x6C71C4));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x93A1A1));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFDF6E3));
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn solarized_dark() -> Colors {
|
||||
let mut colors = solarized_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightBlue];
|
||||
colors[NamedColor::Background] = colors[NamedColor::BrightBlack];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::Blue];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn solarized_light() -> Colors {
|
||||
let mut colors = solarized_palette();
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightYellow];
|
||||
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::Yellow];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
}
|
||||
|
||||
fn cosmic_dark() -> Colors {
|
||||
|
|
@ -533,308 +334,44 @@ fn cosmic_light() -> Colors {
|
|||
colors
|
||||
}
|
||||
|
||||
fn gruvbox_dark() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x282828));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xcc241d));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x98971a));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xd79921));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x458588));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xb16286));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x689d6a));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xa89984));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x928374));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xfb4934));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0xb8bb26));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xfabd2f));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x83a598));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xd3869b));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x8ec07c));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xebdbb2));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// Dim less so colors are readable with default bg
|
||||
.with_dim_lightness_adjustment(-0.15)
|
||||
.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn one_half_dark() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x282c34));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xe06c75));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x98c379));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xe5c07b));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x61afef));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xc678dd));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x56b6c2));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xdcdfe4));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x5d677a));
|
||||
|
||||
// Set this before filling bright colors (including BrightForeground)
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::White];
|
||||
|
||||
let color_derive = ColorDerive::new();
|
||||
|
||||
// Fill missing bright colors
|
||||
color_derive.fill_missing_brights(&mut colors);
|
||||
|
||||
// Set the rest of special colors
|
||||
colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
|
||||
|
||||
// Fill missing dim colors
|
||||
color_derive.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn pop_dark() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |r: u8, g: u8, b: u8| -> Rgb { Rgb { r, g, b } };
|
||||
|
||||
// Pop colors (from pop-desktop gsettings)
|
||||
colors[NamedColor::Black] = Some(encode_rgb(51, 51, 51));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(204, 0, 0));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(78, 154, 6));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(196, 160, 0));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(52, 101, 164));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(117, 80, 123));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(6, 152, 154));
|
||||
colors[NamedColor::White] = Some(encode_rgb(211, 215, 207));
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(136, 128, 124));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(241, 93, 34));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(115, 196, 143));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(255, 206, 81));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(72, 185, 199));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(173, 127, 168));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(52, 226, 226));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(238, 238, 236));
|
||||
|
||||
// Set special colors
|
||||
// Pop colors (from pop-desktop gsettings)
|
||||
colors[NamedColor::Foreground] = Some(encode_rgb(242, 242, 242));
|
||||
colors[NamedColor::Background] = Some(encode_rgb(51, 51, 51));
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// Dim less so colors are readable with default bg
|
||||
.with_dim_lightness_adjustment(-0.05)
|
||||
.fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn selenized_white() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0xEBEBEB));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xD6000C));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x1D9700));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xC49700));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x0064E4));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xDD0F9D));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x00AD9C));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0x878787));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0xCDCDCD));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xBF0000));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x008400));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xAF8500));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x0054CF));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xC7008B));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x009A8A));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0x282828));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Background] = Some(encode_rgb(0xFFFFFF));
|
||||
colors[NamedColor::Foreground] = Some(encode_rgb(0x474747));
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Black];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn selenized_light() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0xECE3CC));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xD2212D));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x489100));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xAD8900));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x0072D4));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xCA4898));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x009C8F));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0x909995));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0xD5CDB6));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xCC1729));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x428B00));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xA78300));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x006DCE));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xC44392));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00978A));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0x3A4D53));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Background] = Some(encode_rgb(0xFBF3DB));
|
||||
colors[NamedColor::Foreground] = Some(encode_rgb(0x53676D));
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Black];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn selenized_dark() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x184956));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xFA5750));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x75B938));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xDBB32D));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x4695F7));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xF275BE));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x41C7B9));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0x72898F));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x2D5B69));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF665C));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x84C747));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xEBC13D));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x58A3FF));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF84CD));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x53D6C7));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xCAD8D9));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Background] = Some(encode_rgb(0x103C48));
|
||||
colors[NamedColor::Foreground] = Some(encode_rgb(0xADBCBC));
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::White];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
fn selenized_black() -> Colors {
|
||||
let mut colors = auto_colors();
|
||||
|
||||
let encode_rgb = |data: u32| -> Rgb {
|
||||
Rgb {
|
||||
r: (data >> 16) as u8,
|
||||
g: (data >> 8) as u8,
|
||||
b: data as u8,
|
||||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x252525));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xED4A46));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x70B433));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0xDBB32D));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x368AEB));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0xEB6EB7));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x3FC5B7));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0x777777));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x3B3B3B));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF5E56));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x83C746));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xEFC541));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x4F9CFE));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF81CA));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x56D8C9));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xDEDEDE));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Background] = Some(encode_rgb(0x181818));
|
||||
colors[NamedColor::Foreground] = Some(encode_rgb(0xB9B9B9));
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::White];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
|
||||
colors
|
||||
}
|
||||
|
||||
// Get builtin themes
|
||||
pub fn terminal_themes() -> HashMap<String, Colors> {
|
||||
let mut themes = HashMap::new();
|
||||
themes.insert("Tango Dark".to_string(), tango_dark());
|
||||
themes.insert("Tango Light".to_string(), tango_light());
|
||||
themes.insert("XTerm Dark".to_string(), xterm_dark());
|
||||
themes.insert("XTerm Light".to_string(), xterm_light());
|
||||
themes.insert("Linux Console".to_string(), linux_console());
|
||||
themes.insert("Rxvt Dark".to_string(), rxvt_dark());
|
||||
themes.insert("Rxvt Light".to_string(), rxvt_light());
|
||||
themes.insert("Solarized Dark".to_string(), solarized_dark());
|
||||
themes.insert("Solarized Light".to_string(), solarized_light());
|
||||
themes.insert("COSMIC Dark".to_string(), cosmic_dark());
|
||||
themes.insert("COSMIC Light".to_string(), cosmic_light());
|
||||
themes.insert("gruvbox-dark".to_string(), gruvbox_dark());
|
||||
themes.insert("OneHalfDark".to_string(), one_half_dark());
|
||||
themes.insert("Pop Dark".to_string(), pop_dark());
|
||||
themes.insert("Selenized Black".to_string(), selenized_black());
|
||||
themes.insert("Selenized Dark".to_string(), selenized_dark());
|
||||
themes.insert("Selenized Light".to_string(), selenized_light());
|
||||
themes.insert("Selenized White".to_string(), selenized_white());
|
||||
themes
|
||||
}
|
||||
|
||||
// Helper function to export builtin themes to theme files
|
||||
#[allow(dead_code)]
|
||||
pub fn export() {
|
||||
for (name, theme) in terminal_themes() {
|
||||
let color_scheme = ColorScheme::from((name.as_str(), &theme));
|
||||
|
||||
// Ensure conversion to and from ColorScheme matches original theme
|
||||
{
|
||||
let theme_conv = Colors::from(&color_scheme);
|
||||
for i in 0..alacritty_terminal::term::color::COUNT {
|
||||
assert_eq!(theme[i], theme_conv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
let ron = match ron::ser::to_string_pretty(&color_scheme, ron::ser::PrettyConfig::new()) {
|
||||
Ok(ok) => ok,
|
||||
Err(err) => {
|
||||
log::error!("failed to export {name:?}: {err}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let path = format!("color-schemes/{name}.ron");
|
||||
match fs::write(&path, ron) {
|
||||
Ok(()) => {
|
||||
log::info!("exported {path:?}");
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("failed to esport {path:?}: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue