Skip to content

Instantly share code, notes, and snippets.

@topolarity
Last active September 4, 2024 13:02
Show Gist options
  • Save topolarity/f4e422c70441a002af88510750788048 to your computer and use it in GitHub Desktop.
Save topolarity/f4e422c70441a002af88510750788048 to your computer and use it in GitHub Desktop.
const Basic = Palette(
# Property faces
:bold => Face(weight=:bold),
:light => Face(weight=:light),
:italic => Face(slant=:italic),
:underline => Face(underline=true),
:strikethrough => Face(strikethrough=true),
:inverse => Face(inverse=true),
# Basic color faces
:black => Face(foreground=:black),
:red => Face(foreground=:red),
:green => Face(foreground=:green),
:yellow => Face(foreground=:yellow),
:blue => Face(foreground=:blue),
:magenta => Face(foreground=:magenta),
:cyan => Face(foreground=:cyan),
:white => Face(foreground=:white),
:bright_black => Face(foreground=:bright_black),
:grey => Face(foreground=:bright_black),
:gray => Face(foreground=:bright_black),
:bright_red => Face(foreground=:bright_red),
:bright_green => Face(foreground=:bright_green),
:bright_yellow => Face(foreground=:bright_yellow),
:bright_blue => Face(foreground=:bright_blue),
:bright_magenta => Face(foreground=:bright_magenta),
:bright_cyan => Face(foreground=:bright_cyan),
:bright_white => Face(foreground=:bright_white),
; mutable = false # 'basic' faces are not overrideable
)
const Default = Palette(
# Useful common faces
:shadow => Face(foreground=:bright_black),
:region => Face(background=0x3a3a3a),
:emphasis => Face(foreground=:blue),
:highlight => Face(inherit=:emphasis, inverse=true),
:code => Face(foreground=:cyan),
# Styles of generic content categories
:error => Face(foreground=:bright_red),
:warning => Face(foreground=:yellow),
:success => Face(foreground=:green),
:info => Face(foreground=:bright_cyan),
:note => Face(foreground=:grey),
:tip => Face(foreground=:bright_green),
; inherit = Palette[StyledStrings.Basic], toml_name = "Default" # specifying a TOML name makes this customizable via Styles.toml
)
export Basic, Default # in StyledStrings
const stacktrace_palette = Palette(
# Stacktraces (on behalf of Base)
:frameindex => Face(),
:location => Face(inherit=:shadow),
:filename => Face(underline=true, inherit=:location),
:fileline => Face(inherit=:filename),
:repetition => Face(inherit=:warning),
:inlined => Face(inherit=:repetition),
:basemodule => Face(inherit=:shadow)
; inherit = Palette[StyledStrings.Default]
)
StyledStrings.set_default_palette!(Base.StackTraces, stacktrace_palette) # sets the default Palette used with styled"..." in the Module
const logging_palette = Palette(
# Log messages
:error => Face(inherit=[:error, :bold]),
:warn => Face(inherit=[:warning, :bold]),
:info => Face(inherit=[:info, :bold]),
:debug => Face(foreground=:blue, inherit=:bold),
; inherit = Palette[StyledStrings.Default], toml_name = "Logging"
)
const repl_palette = Palette(
# Julia prompts
:prompt => Face(weight=:bold),
:julia => Face(inherit=[:green, :prompt]),
:help => Face(inherit=[:yellow, :prompt]),
:shell => Face(inherit=[:red, :prompt]),
:pkg => Face(inherit=[:blue, :prompt]),
:beep => Face(inherit=[:shadow, :prompt]),
; inherit = Palette[StyledStrings.Default], toml_name = "REPL"
)
StyledStrings.set_default_palette!(REPL, repl_palette)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment