58 lines
2.0 KiB
Plaintext
58 lines
2.0 KiB
Plaintext
[[theming]]
|
|
= Theming
|
|
|
|
ifndef::snippets[:snippets: ../../../../src/test/java/org/springframework/shell/docs]
|
|
|
|
Current terminal implementations are rich in features and can usually show
|
|
something else that just plain text. For example, a text can be styled to be
|
|
_bold_ or have different colors. It's also common for terminals to be able
|
|
to show various characters from a unicode table like emoji's which are usually
|
|
used to make shell output more pretty.
|
|
|
|
Spring Shell supports these via it's theming framework which contains two parts.
|
|
Firstly, _styling_ can be used to change text type and secondly, _figures_ are used
|
|
to customize how characters are shown. These two parts are then combined as a _theme_.
|
|
|
|
For more detail about _theming_ internals, refer to see xref:appendices/techintro/theming.adoc[Theming].
|
|
|
|
NOTE: Default theme is named `default` but can be changed using the property
|
|
`spring.shell.theme.name`. There is also another built-in theme named `dump`
|
|
that uses no styling for colors and tries to not use any special figures.
|
|
|
|
You can modify existing styles and figures by overriding the default settings:
|
|
|
|
[source, java, indent=0]
|
|
----
|
|
include::{snippets}/ThemingSnippets.java[tag=custom-style-class]
|
|
----
|
|
|
|
[source, java, indent=0]
|
|
----
|
|
include::{snippets}/ThemingSnippets.java[tag=custom-figure-class]
|
|
----
|
|
|
|
You can also create a new theme, by creating a `ThemeSettings` and provide your own _style_
|
|
and _figure_ implementations:
|
|
|
|
[source, java, indent=0]
|
|
----
|
|
include::{snippets}/ThemingSnippets.java[tag=custom-theme-class]
|
|
----
|
|
|
|
Register a new bean `Theme` where you can return your custom `ThemeSettings`
|
|
and a _theme_ name.
|
|
|
|
[source, java, indent=0]
|
|
----
|
|
include::{snippets}/ThemingSnippets.java[tag=custom-theme-config]
|
|
----
|
|
|
|
You can use `ThemeResolver` to resolve _styles_ if you want to create
|
|
JLine-styled strings programmatically and _figures_ if you want to
|
|
theme characters for being more pretty.
|
|
|
|
[source, java, indent=0]
|
|
----
|
|
include::{snippets}/ThemingSnippets.java[tag=using-theme-resolver]
|
|
----
|