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>
This commit is contained in:
mikeandClaude Opus 5.5 committed 2026-10-28 10:44:23 +01:00
1 parent fb5602452a
commit df261910c5
26 files changed
+920 -132

No files matched your search

+57 -8
View File
@@ -195,14 +195,62 @@ func (a *App) option(key string) *schema.Option {
Kind: schema.KindText,
Repeatable: len(a.file.GetAll(key)) > 1,
Category: catSet,
Doc: "This key is not a known Ghostty " + a.sch.GhosttyVersion + " option. " +
}
v := a.sch.GhosttyVersion
switch c := a.sch.OldKey(key); {
case c != nil && c.RenamedTo != "":
o.Doc = "This is the old name of `" + c.RenamedTo + "`. Ghostty " + v + " still reads it, " +
"so it keeps working, but it is no longer documented. " +
"Press enter to rename it to `" + c.RenamedTo + "`; the value stays as it is."
if n := a.sch.Lookup(c.RenamedTo); n != nil && n.Doc != "" {
o.Doc += "\n\n" + n.Doc
}
case c != nil:
o.Doc = "This is an old option that Ghostty " + v + " still reads for compatibility. " +
"It now sets `" + strings.Join(c.Sets, "`, `") + "` instead. " +
"Set those directly, then press r to remove this line."
default:
o.Doc = "This key is not a known Ghostty " + v + " option. " +
"It may be misspelled or belong to a different Ghostty version. " +
"Ghostty will report it as an error; press r to remove it.",
"Ghostty will report it as an error; press r to remove it."
}
a.unknown[key] = o
return o
}
// oldName returns the old key under which the file sets o, and its value.
func (a *App) oldName(o *schema.Option) (key, value string, ok bool) {
for _, old := range a.sch.OldNames(o.Key) {
if v, found := a.file.Get(old); found {
key, value, ok = old, v, true
}
}
return key, value, ok
}
// renameKey gives the entries of an old key their current name, keeping
// their values and their place in the file, and selects the result.
func (a *App) renameKey(old, new string) {
before := a.file.Clone()
a.file.Rename(old, new)
a.pushUndo(before, old)
a.setStatus("Renamed "+old+" to "+new+".", stChanged)
a.rebuild()
for i, o := range a.opts {
if o.Key == new {
a.optIdx = i
}
}
}
func (a *App) pushUndo(before *config.File, key string) {
a.rev++
a.undo = append(a.undo, undoEntry{file: before, key: key})
if len(a.undo) > 500 {
a.undo = a.undo[1:]
}
}
func (a *App) selected() *schema.Option {
if a.optIdx >= 0 && a.optIdx < len(a.opts) {
return a.opts[a.optIdx]
@@ -516,8 +564,13 @@ func (a *App) updateBrowse(km tea.KeyMsg) tea.Cmd {
return nil
}
// edit opens the editor for o. Booleans are toggled directly.
// edit opens the editor for o. Booleans are toggled directly, and the old
// name of an option is renamed to the current one.
func (a *App) edit(o *schema.Option) tea.Cmd {
if c := a.sch.OldKey(o.Key); c != nil && c.RenamedTo != "" {
a.renameKey(c.Key, c.RenamedTo)
return nil
}
if o.Kind == schema.KindBool && !o.Repeatable {
a.quickToggle(o)
return nil
@@ -693,11 +746,7 @@ func (a *App) apply(o *schema.Option, res *result) {
if a.file.Equal(before) {
return
}
a.rev++
a.undo = append(a.undo, undoEntry{file: before, key: o.Key})
if len(a.undo) > 500 {
a.undo = a.undo[1:]
}
a.pushUndo(before, o.Key)
switch {
case res.values == nil:
a.setStatus("Reset "+o.Key+" to its default.", stChanged)
+47
View File
@@ -243,3 +243,50 @@ func TestUpdateHintShown(t *testing.T) {
t.Errorf("header without an update: %q", h)
}
}
func TestOldNameIsRenamed(t *testing.T) {
a := newTestApp(t, "# big scrollback\nscrollback-limit = 100000000\n")
a.selectCategory(0)
old := a.selected()
if old == nil || old.Key != "scrollback-limit" {
t.Fatalf("selected = %v", old)
}
if doc := ansi.Strip(a.docContent(old, 100)); !strings.Contains(doc, "old name of") || strings.Contains(doc, "misspelled") {
t.Errorf("doc of the old name:\n%s", doc)
}
// The current option shows the value set under its old name.
doc := ansi.Strip(a.docContent(a.sch.Lookup("scrollback-limit-bytes"), 100))
if !strings.Contains(doc, "100000000 ● set as scrollback-limit") || !strings.Contains(doc, "also reads the old name") {
t.Errorf("doc of the new name:\n%s", doc)
}
press(a, "enter")
if got := string(a.file.Bytes()); got != "# big scrollback\nscrollback-limit-bytes = 100000000\n" {
t.Fatalf("after rename:\n%s", got)
}
if o := a.selected(); o == nil || o.Key != "scrollback-limit-bytes" {
t.Errorf("selected after rename = %v", o)
}
press(a, "u")
if !a.file.Has("scrollback-limit") || a.dirty() {
t.Error("undo did not restore the old name")
}
}
func TestOldValueAndReplacedOption(t *testing.T) {
a := newTestApp(t, "copy-on-select = true\nbold-is-bright = true\n")
doc := ansi.Strip(a.docContent(a.sch.Lookup("copy-on-select"), 100))
if strings.Contains(doc, "invalid") || !strings.Contains(doc, "an old value") || !strings.Contains(doc, "none, primary, clipboard, both") {
t.Errorf("doc of copy-on-select = true:\n%s", doc)
}
doc = ansi.Strip(a.docContent(a.option("bold-is-bright"), 100))
if !strings.Contains(doc, "now sets bold-color") || strings.Contains(doc, "misspelled") {
t.Errorf("doc of bold-is-bright:\n%s", doc)
}
// Not renamed: enter edits the line as text.
a.selectCategory(0)
press(a, "down", "enter")
if a.editor == nil {
t.Error("enter on a replaced option opens no editor")
}
}
+30 -2
View File
@@ -204,6 +204,8 @@ func (a *App) renderOpts(w, h int) string {
selected := i == a.optIdx
keySt := lipgloss.NewStyle()
switch {
case a.sch.OldKey(o.Key) != nil:
keySt = stChanged // still read by Ghostty, but no longer documented
case a.unknown[o.Key] == o:
keySt = stError
case o.Platform != "" && a.osName != "" && o.Platform != a.osName:
@@ -294,6 +296,8 @@ func (a *App) valueSegs(o *schema.Option, w int) []seg {
if o.Validate(v) != nil {
st = stError
}
} else if _, ov, ok := a.oldName(o); ok {
v, st = ov, stChanged // set under the option's old name
}
if v == "" {
return []seg{styled("—", stDim)}
@@ -370,6 +374,12 @@ func (a *App) docContent(o *schema.Option, w int) string {
row := func(label, value string) {
b.WriteString(stLabel.Render(label) + " " + ansi.Wrap(value, max(10, w-10), "") + "\n")
}
// note is an indented remark below the value, wrapped to the panel.
note := func(st lipgloss.Style, text string) {
for _, l := range strings.Split(ansi.Wrap(text, max(10, w-10), ""), "\n") {
b.WriteString(" " + st.Render(l) + "\n")
}
}
if a.editor == nil {
row("Type", o.TypeLabel())
vals := a.file.GetAll(o.Key)
@@ -401,9 +411,13 @@ func (a *App) docContent(o *schema.Option, w int) string {
def = sw + " " + def
}
row("Default", strings.ReplaceAll(def, "\t", "\\t"))
if len(vals) == 0 {
oldKey, oldVal, hasOld := a.oldName(o)
switch {
case len(vals) == 0 && hasOld:
row("Value", oldVal+" "+stChanged.Render("● set as "+oldKey))
case len(vals) == 0:
row("Value", stDim.Render("not set (uses default)"))
} else {
default:
v := vals[len(vals)-1]
if sw := swatch(v); sw != "" && o.Kind == schema.KindColor {
v = sw + " " + v
@@ -411,11 +425,25 @@ func (a *App) docContent(o *schema.Option, w int) string {
row("Value", v+" "+stSet.Render("● set in config"))
if err := o.Validate(vals[len(vals)-1]); err != nil {
b.WriteString(stError.Render(" ✗ invalid: "+err.Error()) + "\n")
} else if o.IsOldValue(vals[len(vals)-1]) {
text := "an old value; Ghostty " + a.sch.GhosttyVersion + " still reads it"
if len(o.Values) > 0 {
text += ", but the current values are " + strings.Join(o.Values, ", ")
}
note(stChanged, text)
}
if len(vals) > 1 {
b.WriteString(stChanged.Render(fmt.Sprintf(" set %d times; the last one wins", len(vals))) + "\n")
}
}
if hasOld {
text := "Ghostty also reads the old name " + oldKey + " as this option. " +
"Select it under " + catSet + " and press enter to rename it."
if len(vals) > 0 {
text += " As both are set, the line further down wins."
}
note(stChanged, text)
}
}
if o.Platform != "" {
row("Platform", o.Platform+" only")