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:
1 parent
fb5602452a
commit
df261910c5
26 files changed
+920
-132
No files matched your search
@@ -108,12 +108,18 @@ type zigType struct {
|
||||
type zigInfo struct {
|
||||
fields []zigField
|
||||
types map[string]*zigType
|
||||
compat []*schema.Compat
|
||||
}
|
||||
|
||||
var (
|
||||
reField = regexp.MustCompile(`^(?:@"([a-z0-9-]+)"|([a-z][a-z0-9_]*)): ([^=]+?)\s*=`)
|
||||
reType = regexp.MustCompile(`^pub const (\w+) = (enum|union|packed struct)\b`)
|
||||
reMember = regexp.MustCompile(`^ (@"[^"]+"|[a-z_][a-z0-9_]*)(\s*:\s*([^=,]+?))?(\s*=\s*([^,]+))?,\s*(//.*)?$`)
|
||||
|
||||
// Entries of the compatibility table: renamed keys, or a handler function.
|
||||
reCompat = regexp.MustCompile(`^\s*\.\{ "([a-z0-9-]+)", (?:cli\.compatibilityRenamed\(Config, "([a-z0-9-]+)"\)|(\w+)) \},`)
|
||||
reCompatValue = regexp.MustCompile(`std\.mem\.eql\(u8, value\w* orelse "", "([^"]+)"\)`)
|
||||
reCompatSets = regexp.MustCompile(`self\.@"([a-z0-9-]+)" =`)
|
||||
)
|
||||
|
||||
func parseZig(src string) *zigInfo {
|
||||
@@ -177,9 +183,75 @@ func parseZig(src string) *zigInfo {
|
||||
}
|
||||
doc = nil
|
||||
}
|
||||
info.compat = parseCompat(src)
|
||||
return info
|
||||
}
|
||||
|
||||
// parseCompat reads the `compatibility` table of Config.zig: keys and values
|
||||
// of older releases that Ghostty still accepts. A renamed key names its new
|
||||
// key; for a handler function, the values it compares against and the
|
||||
// options it assigns are taken from its body.
|
||||
func parseCompat(src string) []*schema.Compat {
|
||||
lines := strings.Split(src, "\n")
|
||||
var out []*schema.Compat
|
||||
inTable := false
|
||||
for _, line := range lines {
|
||||
switch {
|
||||
case strings.HasPrefix(line, "pub const compatibility = "):
|
||||
inTable = true
|
||||
case inTable && line == "});":
|
||||
inTable = false
|
||||
case inTable:
|
||||
m := reCompat.FindStringSubmatch(line)
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
c := &schema.Compat{Key: m[1], RenamedTo: m[2]}
|
||||
if m[3] != "" {
|
||||
body := funcBody(lines, m[3])
|
||||
if body == "" {
|
||||
log.Printf("warning: compatibility handler %s not found", m[3])
|
||||
}
|
||||
for _, v := range reCompatValue.FindAllStringSubmatch(body, -1) {
|
||||
c.Values = appendNew(c.Values, v[1])
|
||||
}
|
||||
for _, v := range reCompatSets.FindAllStringSubmatch(body, -1) {
|
||||
if v[1] != c.Key {
|
||||
c.Sets = appendNew(c.Sets, v[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
out = append(out, c)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// funcBody returns the top-level function name, from its signature to the
|
||||
// closing brace.
|
||||
func funcBody(lines []string, name string) string {
|
||||
for i, line := range lines {
|
||||
if !strings.HasPrefix(line, "fn "+name+"(") {
|
||||
continue
|
||||
}
|
||||
for j := i; j < len(lines); j++ {
|
||||
if lines[j] == "}" {
|
||||
return strings.Join(lines[i:j+1], "\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func appendNew(list []string, v string) []string {
|
||||
for _, s := range list {
|
||||
if s == v {
|
||||
return list
|
||||
}
|
||||
}
|
||||
return append(list, v)
|
||||
}
|
||||
|
||||
func ptr(f float64) *float64 { return &f }
|
||||
|
||||
// typeMap describes types that are not plain enums/unions/packed structs in
|
||||
@@ -224,6 +296,7 @@ var typeMap = map[string]schema.Option{
|
||||
"Keybinds": {Kind: schema.KindKeybind, Repeatable: true},
|
||||
"KeyRemapSet": {Kind: schema.KindText, Repeatable: true, Hint: "from=to, e.g. ctrl=super"},
|
||||
"WindowPadding": {Kind: schema.KindPadding},
|
||||
"WindowPaddingBalance": {Kind: schema.KindEnum, Values: []string{"false", "true", "equal"}}, // renderer/size.zig
|
||||
"QuickTerminalSize": {Kind: schema.KindText, Hint: "e.g. 50%, 400px or 50%,500px"},
|
||||
"RepeatableCommand": {Kind: schema.KindText, Repeatable: true, Hint: "title:NAME,action:ACTION[,description:TEXT]"},
|
||||
"?inputpkg.OptionAsAlt": {Kind: schema.KindEnum, Values: []string{"false", "true", "left", "right"}},
|
||||
@@ -298,6 +371,22 @@ func build(z *zigInfo, docs []schema.DocEntry, version string) *schema.Schema {
|
||||
doc := strings.TrimSpace(strings.Join(f.doc, "\n"))
|
||||
add(f.key, schema.DocEntry{Key: f.key, Doc: doc}, false)
|
||||
}
|
||||
|
||||
known := map[string]bool{}
|
||||
for _, o := range s.Options {
|
||||
known[o.Key] = true
|
||||
}
|
||||
for _, c := range z.compat {
|
||||
switch {
|
||||
case c.RenamedTo != "" && !known[c.RenamedTo]:
|
||||
log.Printf("warning: compatibility: %s is renamed to the unknown key %s", c.Key, c.RenamedTo)
|
||||
case known[c.Key] && len(c.Values) == 0:
|
||||
log.Printf("warning: compatibility: no old values found for %s", c.Key)
|
||||
case !known[c.Key] && c.RenamedTo == "" && len(c.Sets) == 0:
|
||||
log.Printf("warning: compatibility: no replacement found for %s", c.Key)
|
||||
}
|
||||
}
|
||||
s.Compat = z.compat
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -315,6 +404,10 @@ func optionForType(typ string, types map[string]*zigType) schema.Option {
|
||||
o.Values = append([]string(nil), o.Values...)
|
||||
return o
|
||||
}
|
||||
// Limit(usize, 50_000_000) from limit.zig: a number, or "unlimited".
|
||||
if strings.HasPrefix(typ, "Limit(") {
|
||||
return schema.Option{Kind: schema.KindInt, Min: ptr(0), Values: []string{"unlimited"}}
|
||||
}
|
||||
name := strings.TrimPrefix(typ, "?")
|
||||
t := types[name]
|
||||
if t == nil {
|
||||
|
||||
Reference in new issue
Block a user