Files
ghosttyconf/internal/schema/categories.go
T
mikeandClaude Opus 5.5 df261910c5 Support Ghostty 1.4, version 1.0.2
The built-in schema now describes Ghostty 1.4.0: 212 options, the new
choices of copy-on-select, window-padding-balance = equal, number limits
that also take "unlimited", and categories for the new options.

genschema reads Ghostty's compatibility table, so old names and values
Ghostty still accepts are no longer reported as errors: a renamed key
such as scrollback-limit is shown in yellow and renamed in place with
enter, a replaced option names its successors, and old values such as
copy-on-select = true are accepted with a note.

Theme previews expand ~/ like Ghostty 1.4 and only look where Ghostty
looks for user themes. Theme names with parentheses of their own keep
them. A live test checks every ghostty command against the installed
Ghostty. Docs and screenshots updated for 1.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 10:44:23 +01:00

176 lines
6.1 KiB
Go

package schema
import (
"regexp"
"strings"
)
// Ghostty itself has no option categories; these groupings exist only to
// make the editor easier to navigate.
const (
CatFonts = "Fonts"
CatFontMetrics = "Font Metrics"
CatColors = "Colors & Theme"
CatBackground = "Background"
CatCursor = "Cursor"
CatWindow = "Window"
CatTabsSplits = "Tabs & Splits"
CatMouse = "Mouse & Selection"
CatClipboard = "Clipboard"
CatKeyboard = "Keyboard"
CatShell = "Shell & Commands"
CatScrolling = "Scrolling"
CatNotifications = "Notifications & Bell"
CatQuickTerminal = "Quick Terminal"
CatShaders = "Shaders"
CatMacOS = "macOS"
CatLinux = "Linux & GTK"
CatConfigFiles = "Config Files"
CatAdvanced = "Advanced"
)
var categoryOrder = []string{
CatFonts, CatFontMetrics, CatColors, CatBackground, CatCursor, CatWindow,
CatTabsSplits, CatMouse, CatClipboard, CatKeyboard, CatShell, CatScrolling,
CatNotifications, CatQuickTerminal, CatShaders, CatMacOS, CatLinux,
CatConfigFiles, CatAdvanced,
}
// exact key assignments, checked before the prefix rules below.
var categoryByKey = map[string]string{
"keybind": CatKeyboard,
"key-remap": CatKeyboard,
"macos-option-as-alt": CatKeyboard,
"vt-kam-allowed": CatKeyboard,
"config-file": CatConfigFiles,
"config-default-files": CatConfigFiles,
"cursor-click-to-move": CatMouse,
"theme": CatColors,
"background": CatColors,
"foreground": CatColors,
"bold-color": CatColors,
"minimum-contrast": CatColors,
"faint-opacity": CatColors,
"alpha-blending": CatColors,
"osc-color-report-format": CatColors,
"window-colorspace": CatColors,
"selection-foreground": CatColors,
"selection-background": CatColors,
"window-title-font-family": CatWindow,
"freetype-load-flags": CatFonts,
"grapheme-width-method": CatFonts,
"window-new-tab-position": CatTabsSplits,
"window-show-tab-bar": CatTabsSplits,
"drag-handle": CatTabsSplits,
"window-inherit-working-directory": CatShell,
"tab-inherit-working-directory": CatShell,
"split-inherit-working-directory": CatShell,
"scrollbar": CatScrolling,
"scroll-to-bottom": CatScrolling,
"mouse-scroll-multiplier": CatScrolling,
"focus-follows-mouse": CatMouse,
"click-repeat-interval": CatMouse,
"right-click-action": CatMouse,
"middle-click-action": CatMouse,
"copy-on-select": CatClipboard,
"command": CatShell,
"initial-command": CatShell,
"env": CatShell,
"input": CatShell,
"working-directory": CatShell,
"wait-after-command": CatShell,
"abnormal-command-exit-runtime": CatShell,
"term": CatShell,
"enquiry-response": CatShell,
"command-palette-entry": CatShell,
"app-notifications": CatNotifications,
"desktop-notifications": CatNotifications,
"progress-style": CatNotifications,
"auto-update": CatMacOS,
"auto-update-channel": CatMacOS,
"class": CatLinux,
"async-backend": CatLinux,
"language": CatLinux,
"maximize": CatWindow,
"fullscreen": CatWindow,
"title": CatWindow,
"initial-window": CatWindow,
"confirm-close-surface": CatWindow,
"undo-timeout": CatWindow,
"vt-window-resize-allowed": CatWindow,
}
var categoryPrefixes = []struct {
prefix, cat string
}{
{"quick-terminal-", CatQuickTerminal},
{"scrollback-", CatScrolling},
{"gtk-quick-terminal-", CatQuickTerminal},
{"custom-shader", CatShaders},
{"adjust-cursor-", CatCursor},
{"adjust-", CatFontMetrics},
{"font-", CatFonts},
{"cursor-", CatCursor},
{"background-", CatBackground},
{"palette", CatColors},
{"search-", CatColors},
{"split-", CatTabsSplits},
{"unfocused-split-", CatTabsSplits},
{"mouse-", CatMouse},
{"selection-", CatMouse},
{"link", CatMouse},
{"clipboard-", CatClipboard},
{"shell-integration", CatShell},
{"bell-", CatNotifications},
{"notify-on-", CatNotifications},
{"macos-", CatMacOS},
{"gtk-", CatLinux},
{"linux-", CatLinux},
{"x11-", CatLinux},
{"window-", CatWindow},
{"resize-overlay", CatWindow},
{"quit-after-", CatWindow},
}
func categorize(key string) string {
if c, ok := categoryByKey[key]; ok {
return c
}
for _, p := range categoryPrefixes {
if strings.HasPrefix(key, p.prefix) {
return p.cat
}
}
return CatAdvanced
}
// platform reports which OS an option is limited to, based on its key
// prefix and on sentences like "This is only supported on macOS." in its
// documentation. Notes about individual values (e.g. "(macOS only)" in a
// list item) or about several platforms are ignored.
func platform(o *Option) string {
switch {
case strings.HasPrefix(o.Key, "macos-"):
return "macOS"
case strings.HasPrefix(o.Key, "gtk-"), strings.HasPrefix(o.Key, "linux-"),
strings.HasPrefix(o.Key, "x11-"):
return "Linux"
}
text := strings.Join(strings.Fields(o.Doc), " ")
for _, sentence := range strings.SplitAfter(text, ". ") {
m := rePlatformNote.FindStringSubmatch(strings.ToLower(strings.TrimSpace(sentence)))
if m == nil {
continue
}
if m[1] == "macos" || m[2] == "macos" {
return "macOS"
}
return "Linux"
}
return ""
}
var rePlatformNote = regexp.MustCompile(
`^(?:note: )?(?:(?:this|it)(?: \w+)? (?:is )?)?(?:currently )?only (?:supported|implemented|available) on (macos|linux|gtk)\b(?: \(gtk\))?[.,;]?$` +
`|^(macos|gtk|linux) only\.?$`)