Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

Add bottom-gutter quotes with settings

RoversX6c898c1c4896
diff --git a/wezterm-gui/src/bottom_quotes.rs b/wezterm-gui/src/bottom_quotes.rs
new file mode 100644
index 00000000..3f966860
--- /dev/null
+++ b/wezterm-gui/src/bottom_quotes.rs
@@ -0,0 +1,217 @@
+use crate::native_settings::NativeBottomQuoteMode;
+use anyhow::Context;
+use parking_lot::Mutex;
+use serde::{Deserialize, Serialize};
+use std::fs;
+use std::path::PathBuf;
+use std::sync::OnceLock;
+use std::time::{Duration, SystemTime, UNIX_EPOCH};
+
+const MIN_QUOTE_INTERVAL_MINUTES: u32 = 1;
+const MAX_QUOTE_INTERVAL_MINUTES: u32 = 24 * 60;
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub(crate) struct BottomQuote {
+ pub(crate) text: String,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) author: Option<String>,
+}
+
+impl BottomQuote {
+ pub(crate) fn display_text(&self) -> String {
+ let text = self.text.trim();
+ match self
+ .author
+ .as_deref()
+ .map(str::trim)
+ .filter(|s| !s.is_empty())
+ {
+ Some(author) if !text.is_empty() => format!("{text} - {author}"),
+ _ => text.to_string(),
+ }
+ }
+}
+
+#[derive(Debug, Clone)]
+struct QuoteCache {
+ modified: Option<SystemTime>,
+ quotes: Vec<BottomQuote>,
+}
+
+static QUOTE_CACHE: OnceLock<Mutex<Option<QuoteCache>>> = OnceLock::new();
+
+pub(crate) fn quotes_path() -> PathBuf {
+ crate::native_settings::settings_path().with_file_name("bottom_quotes.json")
+}
+
+pub(crate) fn ensure_quotes_file() -> anyhow::Result<PathBuf> {
+ let path = quotes_path();
+ if let Some(parent) = path.parent() {
+ fs::create_dir_all(parent)?;
+ }
+ if !path.exists() {
+ write_default_quotes(&path)?;
+ }
+ Ok(path)
+}
+
+pub(crate) fn reset_quotes_file() -> anyhow::Result<PathBuf> {
+ let path = quotes_path();
+ if let Some(parent) = path.parent() {
+ fs::create_dir_all(parent)?;
+ }
+ write_default_quotes(&path)?;
+ *QUOTE_CACHE.get_or_init(|| Mutex::new(None)).lock() = None;
+ Ok(path)
+}
+
+pub(crate) fn selected_quote(
+ mode: NativeBottomQuoteMode,
+ interval_minutes: u32,
+) -> Option<BottomQuote> {
+ let quotes = load_quotes();
+ if quotes.is_empty() {
+ return None;
+ }
+ let index = selected_index(mode, interval_minutes, quotes.len());
+ quotes.get(index).cloned()
+}
+
+pub(crate) fn next_rotation_delay(interval_minutes: u32) -> Duration {
+ let seconds = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .map(|duration| duration.as_secs())
+ .unwrap_or(0);
+ let interval_secs = interval_seconds(interval_minutes);
+ let remaining = interval_secs - (seconds % interval_secs);
+ Duration::from_secs(remaining.max(1))
+}
+
+fn load_quotes() -> Vec<BottomQuote> {
+ let path = quotes_path();
+ let modified = fs::metadata(&path).and_then(|meta| meta.modified()).ok();
+ let cache = QUOTE_CACHE.get_or_init(|| Mutex::new(None));
+ {
+ let guard = cache.lock();
+ if let Some(existing) = guard.as_ref() {
+ if existing.modified == modified {
+ return existing.quotes.clone();
+ }
+ }
+ }
+
+ let quotes = match fs::read_to_string(&path) {
+ Ok(data) => parse_quotes(&data).unwrap_or_else(|err| {
+ log::warn!("Unable to parse bottom quotes {}: {err:#}", path.display());
+ default_quotes()
+ }),
+ Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
+ if let Err(err) = ensure_quotes_file() {
+ log::warn!(
+ "Unable to create default bottom quotes {}: {err:#}",
+ path.display()
+ );
+ }
+ default_quotes()
+ }
+ Err(err) => {
+ log::warn!("Unable to read bottom quotes {}: {err:#}", path.display());
+ default_quotes()
+ }
+ };
+
+ *cache.lock() = Some(QuoteCache {
+ modified,
+ quotes: quotes.clone(),
+ });
+ quotes
+}
+
+fn write_default_quotes(path: &PathBuf) -> anyhow::Result<()> {
+ let data = serde_json::to_vec_pretty(&default_quotes())?;
+ let tmp = path.with_extension("json.tmp");
+ fs::write(&tmp, data).with_context(|| format!("write {}", tmp.display()))?;
+ fs::rename(&tmp, path).with_context(|| format!("replace {}", path.display()))?;
+ Ok(())
+}
+
+fn parse_quotes(data: &str) -> anyhow::Result<Vec<BottomQuote>> {
+ let quotes: Vec<BottomQuote> = serde_json::from_str(data)?;
+ Ok(quotes
+ .into_iter()
+ .filter(|quote| !quote.text.trim().is_empty())
+ .collect())
+}
+
+fn selected_index(mode: NativeBottomQuoteMode, interval_minutes: u32, len: usize) -> usize {
+ if len <= 1 {
+ return 0;
+ }
+ let interval_secs = interval_seconds(interval_minutes);
+ let bucket = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .map(|duration| duration.as_secs() / interval_secs)
+ .unwrap_or(0);
+ match mode {
+ NativeBottomQuoteMode::Timed => (bucket as usize) % len,
+ NativeBottomQuoteMode::PseudoRandom => (stable_hash(bucket) as usize) % len,
+ }
+}
+
+fn interval_seconds(interval_minutes: u32) -> u64 {
+ let minutes = interval_minutes.clamp(MIN_QUOTE_INTERVAL_MINUTES, MAX_QUOTE_INTERVAL_MINUTES);
+ u64::from(minutes) * 60
+}
+
+fn stable_hash(mut value: u64) -> u64 {
+ value ^= value >> 33;
+ value = value.wrapping_mul(0xff51afd7ed558ccd);
+ value ^= value >> 33;
+ value = value.wrapping_mul(0xc4ceb9fe1a85ec53);
+ value ^ (value >> 33)
+}
+
+fn default_quotes() -> Vec<BottomQuote> {
+ vec![
+ BottomQuote {
+ text: "Until death, all defeat is psychological. Be undefeatable.".to_string(),
+ author: None,
+ },
+ BottomQuote {
+ text: "If things are not failing, you are not innovating enough.".to_string(),
+ author: Some("Elon Musk".to_string()),
+ },
+ BottomQuote {
+ text: "I don't ever give up.".to_string(),
+ author: Some("Elon Musk".to_string()),
+ },
+ BottomQuote {
+ text: "Starting a company is like eating glass and staring into the abyss.".to_string(),
+ author: Some("Elon Musk".to_string()),
+ },
+ BottomQuote {
+ text: "Stay hungry. Stay foolish.".to_string(),
+ author: Some("Steve Jobs".to_string()),
+ },
+ BottomQuote {
+ text: "The best way to predict the future is to invent it.".to_string(),
+ author: Some("Alan Kay".to_string()),
+ },
+ BottomQuote {
+ text: "What I cannot create, I do not understand.".to_string(),
+ author: Some("Richard Feynman".to_string()),
+ },
+ BottomQuote {
+ text: "Programs must be written for people to read.".to_string(),
+ author: Some("Harold Abelson".to_string()),
+ },
+ BottomQuote {
+ text: "Simplicity is the soul of efficiency.".to_string(),
+ author: Some("Austin Freeman".to_string()),
+ },
+ BottomQuote {
+ text: "Make it work, make it right, make it fast.".to_string(),
+ author: Some("Kent Beck".to_string()),
+ },
+ ]
+}
diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs
index 76335653..424a026e 100644
--- a/wezterm-gui/src/main.rs
+++ b/wezterm-gui/src/main.rs
@@ -34,6 +34,7 @@ use wezterm_gui_subcommands::*;
use wezterm_mux_server_impl::update_mux_domains;
use wezterm_toast_notification::*;
+mod bottom_quotes;
mod colorease;
mod commands;
mod customglyph;
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rs
index b3137006..3f3e2205 100644
--- a/wezterm-gui/src/native_settings.rs
+++ b/wezterm-gui/src/native_settings.rs
@@ -11,6 +11,8 @@ pub(crate) const DEFAULT_SETTINGS_FONT_WEIGHT: u16 = 600;
pub(crate) const DEFAULT_SIDEBAR_FONT_SIZE: f64 = 15.0;
pub(crate) const DEFAULT_TAB_FONT_SIZE: f64 = 14.0;
pub(crate) const DEFAULT_PANE_HEADER_FONT_SIZE: f64 = 14.0;
+pub(crate) const DEFAULT_BOTTOM_QUOTE_INTERVAL_MINUTES: u32 = 60;
+pub(crate) const DEFAULT_BOTTOM_QUOTE_FONT_SIZE: f64 = 10.0;
pub(crate) const ONBOARDING_VERSION: u32 = 1;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
@@ -131,6 +133,35 @@ impl NativeLanguagePreference {
}
}
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub(crate) enum NativeBottomQuoteMode {
+ Timed,
+ PseudoRandom,
+}
+
+impl Default for NativeBottomQuoteMode {
+ fn default() -> Self {
+ Self::Timed
+ }
+}
+
+impl NativeBottomQuoteMode {
+ pub(crate) fn label(self) -> &'static str {
+ match self {
+ Self::Timed => "Timed",
+ Self::PseudoRandom => "Pseudo-random",
+ }
+ }
+
+ pub(crate) fn next(self) -> Self {
+ match self {
+ Self::Timed => Self::PseudoRandom,
+ Self::PseudoRandom => Self::Timed,
+ }
+ }
+}
+
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[serde(default)]
pub(crate) struct NativeAppearanceSettings {
@@ -143,6 +174,10 @@ pub(crate) struct NativeAppearanceSettings {
pub(crate) struct NativeTerminalSettings {
pub(crate) font_size: Option<f64>,
pub(crate) font_family: Option<String>,
+ pub(crate) bottom_quote_enabled: bool,
+ pub(crate) bottom_quote_mode: NativeBottomQuoteMode,
+ pub(crate) bottom_quote_interval_minutes: Option<u32>,
+ pub(crate) bottom_quote_font_size: Option<f64>,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
@@ -422,6 +457,22 @@ pub(crate) fn pane_header_font_size() -> f64 {
.clamp(10.0, 28.0)
}
+pub(crate) fn bottom_quote_interval_minutes(settings: &ThinkTermNativeSettings) -> u32 {
+ settings
+ .terminal
+ .bottom_quote_interval_minutes
+ .unwrap_or(DEFAULT_BOTTOM_QUOTE_INTERVAL_MINUTES)
+ .clamp(1, 24 * 60)
+}
+
+pub(crate) fn bottom_quote_font_size(settings: &ThinkTermNativeSettings) -> f64 {
+ settings
+ .terminal
+ .bottom_quote_font_size
+ .unwrap_or(DEFAULT_BOTTOM_QUOTE_FONT_SIZE)
+ .clamp(6.0, 20.0)
+}
+
pub(crate) fn main_window_renderer(
settings: &ThinkTermNativeSettings,
config_front_end: config::FrontEndSelection,
diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rs
index d36fec24..332f1e67 100644
--- a/wezterm-gui/src/settings_window.rs
+++ b/wezterm-gui/src/settings_window.rs
@@ -154,6 +154,12 @@ impl SettingsSection {
"Font Family",
"ThinkTerm Font Size",
"Native Font Family",
+ "Bottom Quote",
+ "Quote Font Size",
+ "Quote Rotation",
+ "Quote Interval",
+ "Open Quotes JSON",
+ "Reset Quotes JSON",
"Terminal",
],
Self::Workspaces => &["Workspace", "Sidebar", "Session", "Layout"],
@@ -238,6 +244,16 @@ enum SettingsAction {
ToggleMainRendererMenu,
SetMainRenderer(NativeRendererBackend),
RestartApplication,
+ ToggleBottomQuote,
+ CycleBottomQuoteMode,
+ DecreaseBottomQuoteFontSize,
+ IncreaseBottomQuoteFontSize,
+ ResetBottomQuoteFontSize,
+ DecreaseBottomQuoteInterval,
+ IncreaseBottomQuoteInterval,
+ ResetBottomQuoteInterval,
+ OpenBottomQuotesJson,
+ ResetBottomQuotesJson,
SearchInput,
DecreaseFontSize,
IncreaseFontSize,
@@ -1716,6 +1732,84 @@ impl SettingsWindow {
self.save_and_apply_native_terminal_settings();
}
+ fn current_bottom_quote_interval_minutes(&self) -> u32 {
+ crate::native_settings::bottom_quote_interval_minutes(&self.native_settings)
+ }
+
+ fn bottom_quote_interval_label(&self) -> String {
+ Self::format_bottom_quote_interval(self.current_bottom_quote_interval_minutes())
+ }
+
+ fn step_bottom_quote_interval(&mut self, delta: i32) {
+ let current = self.current_bottom_quote_interval_minutes() as i32;
+ let value = (current + delta).clamp(1, 24 * 60) as u32;
+ self.native_settings.terminal.bottom_quote_interval_minutes = Some(value);
+ self.save_and_apply_bottom_quote_settings(format!(
+ "Bottom quote interval is now {}.",
+ Self::format_bottom_quote_interval(value)
+ ));
+ }
+
+ fn reset_bottom_quote_interval(&mut self) {
+ self.native_settings.terminal.bottom_quote_interval_minutes = None;
+ self.save_and_apply_bottom_quote_settings(format!(
+ "Bottom quote interval reset to {}.",
+ Self::format_bottom_quote_interval(
+ crate::native_settings::DEFAULT_BOTTOM_QUOTE_INTERVAL_MINUTES
+ )
+ ));
+ }
+
+ fn format_bottom_quote_interval(minutes: u32) -> String {
+ if minutes < 60 {
+ format!("{minutes} min")
+ } else if minutes % 60 == 0 {
+ let hours = minutes / 60;
+ if hours == 1 {
+ "1 h".to_string()
+ } else {
+ format!("{hours} h")
+ }
+ } else {
+ format!("{} h {} min", minutes / 60, minutes % 60)
+ }
+ }
+
+ fn current_bottom_quote_font_size(&self) -> f64 {
+ crate::native_settings::bottom_quote_font_size(&self.native_settings)
+ }
+
+ fn bottom_quote_font_size_label(&self) -> String {
+ Self::format_bottom_quote_font_size(self.current_bottom_quote_font_size())
+ }
+
+ fn step_bottom_quote_font_size(&mut self, delta: f64) {
+ let value = (self.current_bottom_quote_font_size() + delta).clamp(6.0, 20.0);
+ self.native_settings.terminal.bottom_quote_font_size = Some(value);
+ self.save_and_apply_bottom_quote_settings(format!(
+ "Bottom quote font size is now {}.",
+ Self::format_bottom_quote_font_size(value)
+ ));
+ }
+
+ fn reset_bottom_quote_font_size(&mut self) {
+ self.native_settings.terminal.bottom_quote_font_size = None;
+ self.save_and_apply_bottom_quote_settings(format!(
+ "Bottom quote font size reset to {}.",
+ Self::format_bottom_quote_font_size(
+ crate::native_settings::DEFAULT_BOTTOM_QUOTE_FONT_SIZE
+ )
+ ));
+ }
+
+ fn format_bottom_quote_font_size(size: f64) -> String {
+ if (size.round() - size).abs() < f64::EPSILON {
+ format!("{size:.0} pt")
+ } else {
+ format!("{size:.1} pt")
+ }
+ }
+
fn current_chrome_font_size_value(&self, area: ChromeFontArea) -> f64 {
let value = match area {
ChromeFontArea::Settings => self.native_settings.chrome.settings_font_size,
@@ -1820,6 +1914,20 @@ impl SettingsWindow {
}
}
+ fn save_and_apply_bottom_quote_settings(&mut self, status: String) {
+ match crate::native_settings::save(&self.native_settings) {
+ Ok(()) => {
+ if let Some(front_end) = crate::frontend::try_front_end() {
+ front_end.invalidate_all_windows();
+ }
+ self.status = status;
+ }
+ Err(err) => {
+ self.status = format!("Unable to save bottom quote setting: {err:#}");
+ }
+ }
+ }
+
fn apply_terminal_font_size_to_open_windows(&self) {
let font_size = self
.native_settings
@@ -2108,6 +2216,58 @@ impl SettingsWindow {
}
}
}
+ SettingsAction::ToggleBottomQuote => {
+ self.ui.open_dropdown = None;
+ self.native_settings.terminal.bottom_quote_enabled =
+ !self.native_settings.terminal.bottom_quote_enabled;
+ let status = if self.native_settings.terminal.bottom_quote_enabled {
+ "Bottom quote enabled.".to_string()
+ } else {
+ "Bottom quote disabled.".to_string()
+ };
+ self.save_and_apply_bottom_quote_settings(status);
+ }
+ SettingsAction::CycleBottomQuoteMode => {
+ self.ui.open_dropdown = None;
+ self.native_settings.terminal.bottom_quote_mode =
+ self.native_settings.terminal.bottom_quote_mode.next();
+ self.save_and_apply_bottom_quote_settings(format!(
+ "Bottom quote rotation is now {}.",
+ self.native_settings.terminal.bottom_quote_mode.label()
+ ));
+ }
+ SettingsAction::DecreaseBottomQuoteFontSize => self.step_bottom_quote_font_size(-1.0),
+ SettingsAction::IncreaseBottomQuoteFontSize => self.step_bottom_quote_font_size(1.0),
+ SettingsAction::ResetBottomQuoteFontSize => self.reset_bottom_quote_font_size(),
+ SettingsAction::DecreaseBottomQuoteInterval => self.step_bottom_quote_interval(-5),
+ SettingsAction::IncreaseBottomQuoteInterval => self.step_bottom_quote_interval(5),
+ SettingsAction::ResetBottomQuoteInterval => self.reset_bottom_quote_interval(),
+ SettingsAction::OpenBottomQuotesJson => {
+ self.ui.open_dropdown = None;
+ match crate::bottom_quotes::ensure_quotes_file() {
+ Ok(path) => {
+ self.status = format!("Opening bottom quotes JSON {}", path.display());
+ Self::open_path(path);
+ }
+ Err(err) => {
+ self.status = format!("Unable to prepare bottom quotes JSON: {err:#}");
+ }
+ }
+ }
+ SettingsAction::ResetBottomQuotesJson => {
+ self.ui.open_dropdown = None;
+ match crate::bottom_quotes::reset_quotes_file() {
+ Ok(path) => {
+ if let Some(front_end) = crate::frontend::try_front_end() {
+ front_end.invalidate_all_windows();
+ }
+ self.status = format!("Reset bottom quotes JSON {}", path.display());
+ }
+ Err(err) => {
+ self.status = format!("Unable to reset bottom quotes JSON: {err:#}");
+ }
+ }
+ }
SettingsAction::ToggleDeveloperMode => {
self.ui.open_dropdown = None;
self.native_settings.developer.developer_mode =
@@ -2757,6 +2917,8 @@ impl SettingsWindow {
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
let section_y = CONTENT_SECTION_Y - scroll;
+ // Each settings card owns its row count because rows are painted manually.
+ // General currently paints six rows below; the count drives card height and scroll extent.
let row_count = 6;
let (card_y, first_row_y) = self.settings_card_geometry(section_y, row_count);
let card_height = self.settings_card_height(row_count);
@@ -2951,6 +3113,7 @@ impl SettingsWindow {
area.label(),
area.description(),
self.current_chrome_font_size_value(area),
+ None,
SettingsAction::ResetChromeFontSize(area),
SettingsAction::DecreaseChromeFontSize(area),
SettingsAction::IncreaseChromeFontSize(area),
@@ -2966,6 +3129,7 @@ impl SettingsWindow {
"Settings UI Font Weight",
"Controls the Settings window chrome and content text weight.",
self.current_settings_font_weight_value(),
+ None,
SettingsAction::ResetSettingsFontWeight,
SettingsAction::DecreaseSettingsFontWeight,
SettingsAction::IncreaseSettingsFontWeight,
@@ -2987,15 +3151,29 @@ impl SettingsWindow {
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
let section_y = CONTENT_SECTION_Y - scroll;
- let row_count = 4;
+ // Each settings card owns its row count because rows are painted manually.
+ // Terminal currently paints eight rows below; the count drives card height and scroll extent.
+ let row_count = 8;
let (card_y, first_row_y) = self.settings_card_geometry(section_y, row_count);
let card_height = self.settings_card_height(row_count);
+ let button_y = card_y + card_height + self.settings_section_card_gap();
+ let open_quotes_width = self.button_width_for_label("Open Quotes JSON", 260.0);
+ let reset_quotes_width = self.button_width_for_label("Reset Quotes JSON", 260.0);
+ let button_gap = 16.0;
+ let reset_button_x = x + open_quotes_width + button_gap;
+ let reset_button_y = if open_quotes_width + button_gap + reset_quotes_width <= max_width {
+ button_y
+ } else {
+ button_y + CONTROL_HEIGHT + 14.0
+ };
self.ui.content_scroll.set_extents(
self.content_bottom(),
- self.settings_content_extent(card_y + scroll + card_height),
+ self.settings_content_extent(reset_button_y + scroll + CONTROL_HEIGHT),
);
let font_size = format!("{:.1} pt", config.font_size);
let font_family = Self::effective_font_family(&config);
+ let quote_font_size_label = self.bottom_quote_font_size_label();
+ let quote_interval_label = self.bottom_quote_interval_label();
self.draw_text(
layers,
@@ -3040,6 +3218,7 @@ impl SettingsWindow {
"ThinkTerm Font Size",
"Saved locally and applied immediately to open terminal windows.",
self.current_terminal_font_size_value(),
+ None,
SettingsAction::ResetFontSize,
SettingsAction::DecreaseFontSize,
SettingsAction::IncreaseFontSize,
@@ -3058,6 +3237,76 @@ impl SettingsWindow {
SettingsAction::FontFamilyInput,
true,
)?;
+ self.paint_toggle_setting_row(
+ layers,
+ row_x,
+ first_row_y + row_step * 4.0,
+ row_width,
+ "Bottom Quote",
+ "Shows a small quote in the existing bottom gutter.",
+ self.native_settings.terminal.bottom_quote_enabled,
+ SettingsAction::ToggleBottomQuote,
+ true,
+ )?;
+ self.paint_font_size_stepper_row(
+ layers,
+ row_x,
+ first_row_y + row_step * 5.0,
+ row_width,
+ "Quote Font Size",
+ "Changes only the painted quote text; gutter height stays unchanged.",
+ self.current_bottom_quote_font_size(),
+ Some(&quote_font_size_label),
+ SettingsAction::ResetBottomQuoteFontSize,
+ SettingsAction::DecreaseBottomQuoteFontSize,
+ SettingsAction::IncreaseBottomQuoteFontSize,
+ true,
+ )?;
+ self.paint_action_setting_row(
+ layers,
+ row_x,
+ first_row_y + row_step * 6.0,
+ row_width,
+ "Quote Rotation",
+ "Timed rotates in order; pseudo-random picks a stable quote per interval.",
+ self.native_settings.terminal.bottom_quote_mode.label(),
+ SettingsAction::CycleBottomQuoteMode,
+ true,
+ )?;
+ self.paint_font_size_stepper_row(
+ layers,
+ row_x,
+ first_row_y + row_step * 7.0,
+ row_width,
+ "Quote Interval",
+ "Controls how often the bottom quote rotates.",
+ self.current_bottom_quote_interval_minutes() as f64,
+ Some(&quote_interval_label),
+ SettingsAction::ResetBottomQuoteInterval,
+ SettingsAction::DecreaseBottomQuoteInterval,
+ SettingsAction::IncreaseBottomQuoteInterval,
+ true,
+ )?;
+ self.draw_button(
+ layers,
+ x,
+ button_y,
+ open_quotes_width,
+ "Open Quotes JSON",
+ SettingsAction::OpenBottomQuotesJson,
+ )?;
+ self.draw_button(
+ layers,
+ if reset_button_y == button_y {
+ reset_button_x
+ } else {
+ x
+ },
+ reset_button_y,
+ reset_quotes_width,
+ "Reset Quotes JSON",
+ SettingsAction::ResetBottomQuotesJson,
+ )?;
Ok(())
}
@@ -4396,6 +4645,83 @@ impl SettingsWindow {
Ok(())
}
+ fn paint_action_setting_row(
+ &mut self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ x: f32,
+ y: f32,
+ width: f32,
+ label: &str,
+ description: &str,
+ value: &str,
+ action: SettingsAction,
+ draw_top_rule: bool,
+ ) -> anyhow::Result<()> {
+ let palette = self.palette();
+ let ui_font = Rc::clone(&self.ui_font);
+ if draw_top_rule {
+ self.paint_separator(layers, x, y - 28.0, width)?;
+ }
+ let control_width = if width >= 680.0 {
+ 280.0_f32.min(width * 0.36)
+ } else {
+ 220.0_f32.min(width * 0.44)
+ };
+ let control_x = x + width - control_width;
+ let control_y = y + 4.0;
+ let text_width = (control_x - x - 24.0).max(width * 0.45);
+ let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ self.ui_context
+ .push(control_rect, WidgetKind::Button, action);
+
+ let hovered = self.ui.interaction.hovered == Some(action);
+ let pressed = self.ui.interaction.pressed == Some(action);
+ let bg = if pressed {
+ palette.control_pressed_bg
+ } else if hovered {
+ palette.control_hover_bg
+ } else {
+ palette.control_bg
+ };
+ let border = if hovered || pressed {
+ palette.separator
+ } else {
+ palette.control_border
+ };
+
+ self.draw_text(layers, &ui_font, x, y, label, palette.text, text_width)?;
+ self.draw_text(
+ layers,
+ &ui_font,
+ x,
+ self.settings_row_description_y(y),
+ description,
+ palette.secondary_text,
+ text_width,
+ )?;
+ self.draw_rounded_frame(
+ layers,
+ 0,
+ control_x,
+ control_y,
+ control_width,
+ CONTROL_HEIGHT,
+ bg,
+ border,
+ CONTROL_RADIUS,
+ )?;
+ self.draw_text(
+ layers,
+ &ui_font,
+ control_x + 14.0,
+ self.control_text_y(control_y, CONTROL_HEIGHT),
+ value,
+ palette.text,
+ control_width - 26.0,
+ )?;
+ Ok(())
+ }
+
fn paint_import_field_row(
&mut self,
layers: &mut TripleLayerQuadAllocator<'_>,
@@ -4584,6 +4910,7 @@ impl SettingsWindow {
label: &str,
description: &str,
value: f64,
+ value_label: Option<&str>,
reset_action: SettingsAction,
decrease_action: SettingsAction,
increase_action: SettingsAction,
@@ -4681,11 +5008,13 @@ impl SettingsWindow {
)?;
}
- let value_label = if value >= 100.0 && value.fract().abs() < f64::EPSILON {
- format!("{value:.0}")
- } else {
- format!("{value:.1}")
- };
+ let value_label = value_label.map(str::to_string).unwrap_or_else(|| {
+ if value >= 100.0 && value.fract().abs() < f64::EPSILON {
+ format!("{value:.0}")
+ } else {
+ format!("{value:.1}")
+ }
+ });
let value_width = control_width - button_width * 2.0;
let value_x = control_x + button_width;
self.draw_text(
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index f8a24faf..3160504a 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -2,6 +2,7 @@ use crate::quad::TripleLayerQuadAllocator;
use crate::termwindow::{RenderFrame, TermWindowNotif};
use crate::ui::{DrawContext, UiPalette};
use ::window::bitmaps::atlas::OutOfTextureSpace;
+use ::window::color::LinearRgba;
use ::window::WindowOps;
use anyhow::Context;
use smol::Timer;
@@ -285,6 +286,101 @@ impl crate::TermWindow {
Ok(())
}
+ fn paint_bottom_quote(
+ &mut self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ ) -> anyhow::Result<()> {
+ let settings = crate::native_settings::load();
+ if !settings.terminal.bottom_quote_enabled {
+ return Ok(());
+ }
+
+ let interval_minutes = crate::native_settings::bottom_quote_interval_minutes(&settings);
+ let Some(quote) = crate::bottom_quotes::selected_quote(
+ settings.terminal.bottom_quote_mode,
+ interval_minutes,
+ ) else {
+ return Ok(());
+ };
+ let quote = quote.display_text();
+ if quote.is_empty() {
+ return Ok(());
+ }
+ self.update_next_frame_time(Some(
+ Instant::now() + crate::bottom_quotes::next_rotation_delay(interval_minutes),
+ ));
+
+ let (padding_left, padding_top) = self.padding_left_top();
+ let border = self.get_os_border();
+ let tab_bar_height = if self.show_tab_bar {
+ self.tab_bar_pixel_height().unwrap_or(0.0)
+ } else {
+ 0.0
+ };
+ let (top_tab_height, bottom_tab_height) = if self.config.tab_bar_at_bottom {
+ (0.0, tab_bar_height)
+ } else {
+ (tab_bar_height, 0.0)
+ };
+
+ let grid_left = padding_left + border.left.get() as f32;
+ let grid_top = border.top.get() as f32 + top_tab_height + padding_top;
+ let grid_bottom = grid_top + self.terminal_size.pixel_height as f32;
+ let content_bottom =
+ self.dimensions.pixel_height as f32 - border.bottom.get() as f32 - bottom_tab_height;
+ let gutter_height = (content_bottom - grid_bottom).floor();
+ if gutter_height < 10.0 {
+ return Ok(());
+ }
+
+ let quote_font_size = crate::native_settings::bottom_quote_font_size(&settings);
+ let quote_font = self
+ .fonts
+ .command_palette_font_with_size_and_weight(quote_font_size, 500)?;
+ let quote_metrics =
+ crate::utilsprites::RenderMetrics::with_font_metrics(&quote_font.metrics());
+ let quote_height = quote_metrics.cell_size.height as f32;
+
+ let inset = 10.0;
+ let max_width = (self.terminal_size.pixel_width as f32 - inset * 2.0).max(0.0);
+ if max_width <= 0.0 {
+ return Ok(());
+ }
+ let gl_state = self.render_state.as_ref().unwrap();
+ let ctx = DrawContext::new(gl_state, self.dimensions, &quote_metrics);
+ let display_text = ctx.text_with_ellipsis(&quote_font, &quote, max_width);
+ if display_text.is_empty() {
+ return Ok(());
+ }
+ let text_width = ctx
+ .measure_text_width(&quote_font, &display_text)
+ .min(max_width);
+ let x = (grid_left + self.terminal_size.pixel_width as f32 - inset - text_width).max(0.0);
+ let y = (grid_bottom + ((gutter_height - quote_height) / 2.0).max(0.0)).max(0.0);
+ let color = match crate::native_settings::effective_appearance() {
+ window::Appearance::Light | window::Appearance::LightHighContrast => {
+ LinearRgba::with_srgba(80, 80, 90, 255).mul_alpha(0.46)
+ }
+ window::Appearance::Dark | window::Appearance::DarkHighContrast => {
+ LinearRgba::with_srgba(210, 210, 220, 255).mul_alpha(0.38)
+ }
+ };
+
+ ctx.draw_text_on_layer(
+ layers,
+ 2,
+ &quote_font,
+ x,
+ y,
+ &display_text,
+ color,
+ max_width,
+ )
+ .context("paint_bottom_quote")?;
+
+ Ok(())
+ }
+
pub fn paint_pass(&mut self) -> anyhow::Result<()> {
{
let gl_state = self.render_state.as_ref().unwrap();
@@ -425,6 +521,11 @@ impl crate::TermWindow {
}
}
+ if !content_view_active {
+ self.paint_bottom_quote(&mut layers)
+ .context("paint_bottom_quote")?;
+ }
+
if content_view_active {
self.paint_content_view(&mut layers)
.context("paint_content_view")?;