Skip to main content

Theme

Struct Theme 

Source
pub struct Theme {
Show 32 fields pub user_message: Style, pub assistant_message: Style, pub system_message: Style, pub input_text: Style, pub input_cursor: Style, pub status_bar: Style, pub header: Style, pub panel_border: Style, pub panel_title: Style, pub highlight: Style, pub error: Style, pub thinking_message: Style, pub code_inline: Style, pub code_block: Style, pub streaming_cursor: Style, pub tool_command: Style, pub assistant_accent: Style, pub tool_accent: Style, pub diff_added_bg: Color, pub diff_removed_bg: Color, pub diff_word_added_bg: Color, pub diff_word_removed_bg: Color, pub diff_gutter_add: Style, pub diff_gutter_remove: Style, pub diff_header: Style, pub link: Style, pub table_border: Style, pub user_message_bg: Color, pub turn_separator: Style, pub tool_success: Style, pub tool_failure: Style, pub syntax_theme: SyntaxTheme,
}
Expand description

Visual theme for the TUI dashboard widgets.

Contains Style values for every distinct UI element — message roles, input fields, borders, diff gutters, hyperlinks, and status elements. The Default implementation provides a dark blue colour scheme.

Build a configured theme with Theme::from_palette_with_mode at startup and store it in the TUI App; widget render functions receive &Theme as a parameter.

§Examples

use zeph_tui::theme::{Theme, SemanticPalette, resolve_color_mode};
use zeph_config::ColorMode;

let palette = SemanticPalette::zephyr();
// Use Truecolor so the test is deterministic regardless of the CI environment.
let mode = resolve_color_mode(ColorMode::Truecolor);
let theme = Theme::from_palette_with_mode(&palette, mode);
assert_ne!(theme.user_message, theme.assistant_message);

Fields§

§user_message: Style

Style applied to user-role chat messages.

§assistant_message: Style

Style applied to assistant-role chat messages.

§system_message: Style

Style applied to system-role chat messages.

§input_text: Style

Style for the text body of the input field.

§input_cursor: Style

Style for the blinking cursor in the input field.

§status_bar: Style

Style for the status bar at the bottom of the screen.

§header: Style

Style for the top header bar (provider / model info).

§panel_border: Style

Style for panel border lines.

§panel_title: Style

Style for panel title labels.

§highlight: Style

Style for highlighted / selected items.

§error: Style

Style for error messages and indicators.

§thinking_message: Style

Style for thinking / reasoning messages.

§code_inline: Style

Style for inline code spans within chat messages.

§code_block: Style

Style for multi-line code blocks.

§streaming_cursor: Style

Style for the streaming cursor shown while the model is generating.

§tool_command: Style

Style for tool command lines (shell commands, etc.).

§assistant_accent: Style

Accent style for assistant messages (orange / warm tone).

§tool_accent: Style

Accent style for tool output messages (olive / warm tone).

§diff_added_bg: Color

Background colour for added lines in diffs.

§diff_removed_bg: Color

Background colour for removed lines in diffs.

§diff_word_added_bg: Color

Background colour for word-level added regions in diffs.

§diff_word_removed_bg: Color

Background colour for word-level removed regions in diffs.

§diff_gutter_add: Style

Style for the + gutter marker in diffs.

§diff_gutter_remove: Style

Style for the - gutter marker in diffs.

§diff_header: Style

Style for diff file/hunk headers.

§link: Style

Style for hyperlinks.

§table_border: Style

Style for table border lines.

§user_message_bg: Color

Background tint applied to user message lines.

§turn_separator: Style

Style for turn-separator lines between role changes.

§tool_success: Style

Style for the bullet of a successfully completed tool call.

§tool_failure: Style

Style for the bullet of a failed tool call.

§syntax_theme: SyntaxTheme

Syntax-highlight styles for code blocks and diffs.

Initialised once at startup; passed as &theme.syntax_theme to render_diff_lines and the syntax highlighter so that SyntaxTheme::default() is never called per frame.

Implementations§

Source§

impl Theme

Source

pub fn from_palette(p: &SemanticPalette) -> Self

Derive all widget styles from a SemanticPalette at truecolor fidelity.

Equivalent to from_palette_with_mode(p, EffectiveColorMode::Truecolor).

§Examples
use zeph_tui::theme::{Theme, SemanticPalette};

let theme = Theme::from_palette(&SemanticPalette::zephyr());
assert_ne!(theme.user_message, theme.assistant_message);
Source

pub fn from_palette_with_mode(p: &Palette, mode: Ecm) -> Self

Derive all widget styles from a SemanticPalette, downgrading colours for the given terminal capability.

This is the single derivation path — all Rgb values produced here pass through apply_mode (for Style fields) and map_color (for bare Color fields). The downgrade happens exactly once at startup, never per frame.

§Examples
use zeph_tui::theme::{Theme, SemanticPalette, EffectiveColorMode};

let t = Theme::from_palette_with_mode(&SemanticPalette::zephyr(), EffectiveColorMode::Ansi256);
// In Ansi256 mode, colours are indexed — no Rgb variants in fg/bg.
if let Some(fg) = t.user_message.fg {
    assert!(!matches!(fg, ratatui::style::Color::Rgb(..)));
}

Trait Implementations§

Source§

impl Default for Theme

Source§

fn default() -> Self

Returns the legacy hardcoded dark-blue colour scheme.

This implementation is byte-identical to the pre-2.0 default and is kept for backward compatibility. For a configurable theme, use Theme::from_palette_with_mode.

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more