diff --git a/README.md b/README.md index dd9b05c..46e4cc8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@

Release Go 1.24+ - Ghostty 1.3 + Ghostty 1.4 macOS and Linux

@@ -26,12 +26,12 @@ stay intact, and after saving, Ghostty reloads the configuration right away. ## ✨ Highlights -- 📚 **All options, documented.** All 201 options of Ghostty 1.3, in 19 +- 📚 **All options, documented.** All 212 options of Ghostty 1.4, in 19 categories, with the documentation of *your* Ghostty version. - 🎛 **An editor for every type.** Toggles, choice lists, checklists for flags, number steppers, colors with live swatches, a list editor for repeatable options, the 256-color palette. -- 🎨 **Theme and font pickers.** Filter more than 460 themes with a live color +- 🎨 **Theme and font pickers.** Filter more than 800 themes with a live color preview, or pick from the font families Ghostty can find. - ⌨️ **Key binding editor.** See Ghostty's built-in bindings merged with yours, and change, unbind, restore or add bindings. Record shortcuts straight from @@ -57,7 +57,7 @@ but Ghostty. ```sh # macOS on Apple silicon; for other systems, replace darwin-arm64 with # darwin-amd64, linux-amd64 or linux-arm64 -curl -fLo ghosttyconf https://git.micw.org/mike/ghosttyconf/releases/download/1.0.1/ghosttyconf-darwin-arm64 +curl -fLo ghosttyconf https://git.micw.org/mike/ghosttyconf/releases/download/1.0.2/ghosttyconf-darwin-arm64 chmod +x ghosttyconf mv ghosttyconf ~/bin/ # or any other directory in your $PATH ``` @@ -237,6 +237,11 @@ your version. Themes, fonts, actions and validation also come from the `ghostty` command line. Without Ghostty (`--offline`), the built-in data is used. +Old option names and values that Ghostty still reads, such as +`scrollback-limit` (now `scrollback-limit-bytes`) or `copy-on-select = true`, +are recognized from Ghostty's compatibility table and explained instead of +being flagged as errors. `enter` on an old name renames it in place. + ## 📖 Documentation - [User guide](docs/guide.md): every editor, key bindings in depth, saving, diff --git a/docs/development.md b/docs/development.md index 918a97e..16beae8 100644 --- a/docs/development.md +++ b/docs/development.md @@ -104,7 +104,11 @@ from Ghostty's source. `tools/genschema` reads `src/config/Config.zig` and: - adds documentation and defaults from `+show-config`; - sorts every option into one of the categories in `internal/schema/categories.go`, and detects platform-specific options from - their names and documentation. + their names and documentation; +- reads the `compatibility` table into `compat`: renamed keys with their new + name, and for each handler function the old values it compares against and + the options it sets. The editor uses it to explain old keys and values + instead of reporting them as errors. The result is embedded in the binary. At startup, the documentation and defaults are refreshed from the installed Ghostty, so they always match the @@ -125,8 +129,17 @@ or for unreleased versions: go run ./tools/genschema -zig path/to/Config.zig -docs docs.txt -version 1.4.0 ``` -Afterwards, run `make test` and check the generator's warnings about unknown -types. Those types need an entry in `typeMap`. +Afterwards, run `make test` and check the generator's warnings. Unknown types +need an entry in `typeMap`. A compatibility warning means the table or its +handlers changed shape and `parseCompat` needs a look. Then check that every +`ghostty` command ghosttyconf runs is still understood: + +```sh +GHOSTTYCONF_LIVE_TEST=1 go test -run Live -v ./internal/ghostty +``` + +New options land in **Advanced** unless `internal/schema/categories.go` +places them. `git diff internal/schema/schema.json` shows what changed. ## The config file model diff --git a/docs/guide.md b/docs/guide.md index 6835ec8..79b0207 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -63,6 +63,19 @@ Keys in your file that Ghostty doesn't know (typos, options of a newer or older Ghostty version) appear under **Set in Config** with a red name and an explanation. They are kept as they are until you remove them with `r`. +Old names and values that Ghostty still reads for compatibility are not +errors, and ghosttyconf doesn't mark them as such: + +- **Renamed options**, such as `scrollback-limit` (since 1.4 + `scrollback-limit-bytes`) or `background-blur-radius`, have a yellow name. + `enter` renames the entry in place and keeps its value. The current option + shows the value too, with a note that it is set under the old name. +- **Replaced options**, such as `bold-is-bright`, also have a yellow name. The + documentation names the options that replace them. Set those, then remove + the old line with `r`. +- **Old values**, such as `copy-on-select = true` from before 1.4, are + accepted, and the documentation lists the current values. + `←`/`→` or `tab` switch between the category and option lists. `shift+↑`/`↓` (or `ctrl+u`/`ctrl+d`) scroll the documentation. Mouse clicks and the wheel work in every list. @@ -131,7 +144,9 @@ highlighted name. The preview below the list shows the highlighted theme's prompt, file listing, syntax colors and palette. If your config sets colors itself (`background`, `cursor-color`, `palette`, …), a note lists them, because they take precedence over any theme. You can also type a value the list doesn't -know, such as `light:Catppuccin Latte,dark:Catppuccin Mocha`. +know, such as `light:Catppuccin Latte,dark:Catppuccin Mocha`, or the path of a +theme file. Since Ghostty 1.4, a path may start with `~/`, and the preview +finds it there too. **Fonts.** `font-family`, `font-family-bold` and the other font options offer the families from `ghostty +list-fonts`. diff --git a/docs/images/changes.svg b/docs/images/changes.svg index 080d2a7..0db30ca 100644 --- a/docs/images/changes.svg +++ b/docs/images/changes.svg @@ -6,27 +6,27 @@ ghosttyconf - + - + Ghostty Config Editor ~/.config/ghostty/config.ghostty -Ghostty 1.3.1 · 201 options +Ghostty 1.4.0 · 212 options Categories -Set in Config (15) -▸ +Set in Config (15) +▸ Set in Config 15 ● theme Catppuccin Mocha All Options -201 +212 ● font-family JetBrains Mono @@ -57,24 +57,24 @@ 7 ● window-padding-x -Unsaved changes (3) +Unsaved changes (3) Window -29 +30 ● window-padding-y Tabs & Splits -6 +7 ● window-save-state font-size Mouse & Selection -12 +14 ● background-opacity - font-size = 14 Clipboard -7 -▸ +8 +▸ ● macos-titlebar-style + font-size = 14.5 @@ -89,7 +89,7 @@ copy-on-select - macos-titlebar-style = tabs Scrolling -4 +6 ● keybind + macos-titlebar-style = hidden @@ -102,23 +102,23 @@ - keybind = super+d=new_split:right Shaders 2 -macos-titlebar-style +macos-titlebar-style + keybind = super+d=unbind macOS 18 + keybind = super+\=new_split:right Linux & GTK -17 +19 Type one of native Config Files 2 Default transparent -esc +esc Close Advanced -2 +4 Value hidden ● set diff --git a/docs/images/keybinds.svg b/docs/images/keybinds.svg index 55f8ba9..31cfeb6 100644 --- a/docs/images/keybinds.svg +++ b/docs/images/keybinds.svg @@ -6,19 +6,19 @@ ghosttyconf - + - + Ghostty Config Editor ~/.config/ghostty/config.ghostty -Ghostty 1.3.1 · 201 options -Edit keybind +Ghostty 1.4.0 · 212 options +Edit keybind Documentation Type key binding (trigger=action) -new_split +new_split 93 active · 0 changed · @@ -27,13 +27,13 @@ 2 unbound showing all, sorted by action Create a new split in the specified direction. -/ +/ split Valid arguments: Key Action Source -super+w +super+w close_surface default • @@ -44,48 +44,48 @@ left , up -super+alt+w +super+alt+w close_tab:this default -super+shift+w +super+shift+w close_window default Creates a new split in the corresponding direction. -super+ctrl+= +super+ctrl+= equalize_splits default -super+alt+arrow_down +super+alt+arrow_down goto_split:down default • auto -super+alt+arrow_left +super+alt+arrow_left goto_split:left default -super+] +super+] goto_split:next default Creates a new split along the larger direction. -super+[ +super+[ goto_split:previous default For example, if the parent split is currently wider than i… -super+alt+arrow_right +super+alt+arrow_right goto_split:right default then a left-right split would be created, and vice versa. -super+alt+arrow_up +super+alt+arrow_up goto_split:up default -super+shift+d +super+shift+d new_split:down default Keys bound to new_split: -▸ -super+\ +▸ +super+\ new_split:right custom -super+d +super+d new_split:right                         unbound • @@ -93,7 +93,7 @@ → new_split:down (default) -super+ctrl+arrow_down +super+ctrl+arrow_down resize_split:down,10 default • @@ -101,20 +101,20 @@ → new_split:right (custom) -super+ctrl+arrow_left +super+ctrl+arrow_left resize_split:left,10 default -super+ctrl+arrow_right +super+ctrl+arrow_right resize_split:right,10 default -super+ctrl+arrow_up +super+ctrl+arrow_up resize_split:up,10 default -super+shift+enter +super+shift+enter toggle_split_zoom default Added in your config. -new_split +new_split Create a new split in the specified direction. enter change · a add · d unbind · r restore · / filter · c changes only · s sort · R raw · esc done · shift+↑↓ scroll docs diff --git a/docs/images/main.svg b/docs/images/main.svg index 62dd846..7e141bd 100644 --- a/docs/images/main.svg +++ b/docs/images/main.svg @@ -6,27 +6,27 @@ ghosttyconf - + - + Ghostty Config Editor ~/.config/ghostty/config.ghostty -Ghostty 1.3.1 · 201 options +Ghostty 1.4.0 · 212 options Categories -Set in Config (15) -▸ +Set in Config (15) +▸ Set in Config 15 -▸ +▸ ● theme Catppuccin Mocha All Options -201 +212 ● font-family JetBrains Mono @@ -59,22 +59,22 @@ window-padding-x 12 Window -29 +30 ● window-padding-y 8 Tabs & Splits -6 +7 ● window-save-state always Mouse & Selection -12 +14 ● background-opacity 0.95 Clipboard -7 +8 ● macos-titlebar-style tabs @@ -89,7 +89,7 @@ copy-on-select clipboard Scrolling -4 +6 ● keybind 1 custom @@ -102,11 +102,11 @@ Documentation · 0% · shift+↑↓ scroll Shaders 2 -theme +theme macOS 18 Linux & GTK -17 +19 Type theme name (or light:NAME,dark:NAME) Config Files @@ -114,7 +114,7 @@ Default (unset) Advanced -2 +4 Value Catppuccin Mocha ● set in config diff --git a/docs/images/picker.svg b/docs/images/picker.svg index 48b2969..2ea3813 100644 --- a/docs/images/picker.svg +++ b/docs/images/picker.svg @@ -6,7 +6,7 @@ ghosttyconf - + @@ -49,34 +49,34 @@ - + Ghostty Config Editor ~/.config/ghostty/config.ghostty -Ghostty 1.3.1 · 201 options -Edit theme +Ghostty 1.4.0 · 212 options +Edit theme Documentation · 0% · shift+↑↓ scroll Type theme name (or light:NAME,dark:NAME) -theme +theme Default (unset) Current Catppuccin Mocha A theme to use. This can be a built-in theme name, a custom theme name, or an absolute path to a custom theme file. -Search: +Search: tokyo Ghostty also supports specifying a different theme to use for Your config also sets cursor-color, selection-background, which take light and dark mode. Each option is documented below. precedence over the theme. -5 of 463 +5 of 819 If the theme is an absolute pathname, Ghostty will attempt to TokyoNight load that file as a theme. If that file does not exist or is -▸ +▸ TokyoNight Day inaccessible, an error will be logged and no other TokyoNight Moon diff --git a/docs/images/record.svg b/docs/images/record.svg index 30801fe..a516c76 100644 --- a/docs/images/record.svg +++ b/docs/images/record.svg @@ -6,20 +6,20 @@ ghosttyconf - + - + Ghostty Config Editor ~/.config/ghostty/config.ghostty -Ghostty 1.3.1 · 201 options -Edit keybind +Ghostty 1.4.0 · 212 options +Edit keybind Documentation · 0% · shift+↑↓ scroll Type key binding (trigger=action) -keybind +keybind Change super+d (built-in binding) Key bindings. The format is @@ -31,7 +31,7 @@ actions is available in the documentation or using the ghostty +list-actions command. -Trigger › +Trigger › super+\ Trigger: + diff --git a/internal/config/file.go b/internal/config/file.go index f1ae9b2..84116a0 100644 --- a/internal/config/file.go +++ b/internal/config/file.go @@ -340,6 +340,20 @@ func (f *File) Unset(key string) { f.Lines = kept } +// Rename gives every entry of key old the key new, in place. Only the key +// is replaced, so indentation and the formatting of the value stay as they +// were. +func (f *File) Rename(old, new string) { + for i, l := range f.Lines { + if l.Key != old { + continue + } + at := strings.Index(l.Raw, old) // the key is the first word of the line + f.Lines[i].Raw = l.Raw[:at] + new + l.Raw[at+len(old):] + f.Lines[i].Key = new + } +} + // Bytes renders the file. func (f *File) Bytes() []byte { var b bytes.Buffer diff --git a/internal/config/file_test.go b/internal/config/file_test.go index 056df77..a9cef5a 100644 --- a/internal/config/file_test.go +++ b/internal/config/file_test.go @@ -125,6 +125,18 @@ func TestUnset(t *testing.T) { } } +func TestRenameKeepsLayout(t *testing.T) { + f := parse(t, "# limits\n scrollback-limit=100000\nfont-size = 15\nscrollback-limit = \"2000\"\n") + f.Rename("scrollback-limit", "scrollback-limit-bytes") + want := "# limits\n scrollback-limit-bytes=100000\nfont-size = 15\nscrollback-limit-bytes = \"2000\"\n" + if got := string(f.Bytes()); got != want { + t.Fatalf("got\n%s\nwant\n%s", got, want) + } + if f.Has("scrollback-limit") || len(f.GetAll("scrollback-limit-bytes")) != 2 { + t.Fatal("keys not renamed") + } +} + func TestFormatLineQuoting(t *testing.T) { cases := map[string]string{ "bar": "k = bar", diff --git a/internal/ghostty/ghostty.go b/internal/ghostty/ghostty.go index e7e0e2d..b53d244 100644 --- a/internal/ghostty/ghostty.go +++ b/internal/ghostty/ghostty.go @@ -110,9 +110,11 @@ func (g *Ghostty) Themes() ([]string, error) { if line == "" { continue } - // Lines look like "Dracula (resources)" or "Mine (user)". - if i := strings.LastIndex(line, " ("); i > 0 && strings.HasSuffix(line, ")") { - line = line[:i] + // Lines look like "Dracula (resources)" or "Mine (user)". Only these + // two are cut off: names such as "Black Metal (Bathory)" have + // parentheses of their own. + for _, loc := range []string{" (resources)", " (user)"} { + line = strings.TrimSuffix(line, loc) } if !seen[line] { seen[line] = true diff --git a/internal/ghostty/live_test.go b/internal/ghostty/live_test.go new file mode 100644 index 0000000..8993516 --- /dev/null +++ b/internal/ghostty/live_test.go @@ -0,0 +1,88 @@ +package ghostty + +import ( + "os" + "path/filepath" + "slices" + "strings" + "testing" +) + +// TestLiveGhostty runs every command ghosttyconf uses against the installed +// Ghostty and checks that the output is still understood. It is meant for a +// new Ghostty release and only runs when asked for: +// +// GHOSTTYCONF_LIVE_TEST=1 go test -run Live -v ./internal/ghostty +func TestLiveGhostty(t *testing.T) { + if os.Getenv("GHOSTTYCONF_LIVE_TEST") == "" { + t.Skip("set GHOSTTYCONF_LIVE_TEST=1 to run against the installed Ghostty") + } + g, err := Find(os.Getenv("GHOSTTYCONF_GHOSTTY")) + if err != nil { + t.Fatal(err) + } + if g.Version == "" { + t.Fatal("+version: no version found") + } + t.Logf("Ghostty %s at %s", g.Version, g.Bin) + + docs, err := g.DefaultsWithDocs() + if err != nil { + t.Fatal(err) + } + for _, want := range []string{"\nfont-family = ", "\nkeybind = ", "\n# "} { + if !strings.Contains(docs, want) { + t.Errorf("+show-config --default --docs: no %q", want) + } + } + + themes, err := g.Themes() + if err != nil { + t.Fatal(err) + } + if len(themes) < 100 || !slices.Contains(themes, "Catppuccin Mocha") { + t.Errorf("+list-themes: %d themes, Catppuccin Mocha missing or too few", len(themes)) + } + for _, name := range themes { + if strings.HasSuffix(name, " (resources)") || strings.HasSuffix(name, " (user)") { + t.Errorf("+list-themes: location left on %q", name) + break + } + } + th, err := g.LoadTheme("Catppuccin Mocha") + if err != nil { + t.Fatalf("theme file: %v", err) + } + if th.Background == "" || th.Palette[15] == "" { + t.Errorf("theme file: %+v", th) + } + + fonts, err := g.Fonts() + if err != nil || len(fonts) == 0 { + t.Errorf("+list-fonts: %d fonts, %v", len(fonts), err) + } + + actions, err := g.Actions() + if err != nil { + t.Fatal(err) + } + byName := map[string]Action{} + for _, a := range actions { + byName[a.Name] = a + } + if a := byName["new_split"]; len(actions) < 50 || a.Summary == "" || !strings.Contains(a.Doc, "right") { + t.Errorf("+list-actions --docs: %d actions, new_split = %+v", len(actions), a) + } + + conf := filepath.Join(t.TempDir(), "config") + if err := os.WriteFile(conf, []byte("font-size = 14\nfont-size = abc\nbogus-key = 1\n"), 0o644); err != nil { + t.Fatal(err) + } + errs, err := g.Validate(conf) + if err != nil { + t.Fatal(err) + } + if len(errs) != 2 || errs[0].Line != 2 || errs[1].Line != 3 { + t.Errorf("+validate-config: %v", errs) + } +} diff --git a/internal/ghostty/paths.go b/internal/ghostty/paths.go index 952aea1..e63c3e9 100644 --- a/internal/ghostty/paths.go +++ b/internal/ghostty/paths.go @@ -68,21 +68,23 @@ type Theme struct { } // ThemeDirs returns the directories searched for themes, user dirs first. +// Like Ghostty, this is the XDG config directory even on macOS, where the +// config file itself usually lives under Application Support. func (g *Ghostty) ThemeDirs() []string { dirs := []string{filepath.Join(xdgConfigDir(), "themes")} - if runtime.GOOS == "darwin" { - dirs = append(dirs, filepath.Join(macConfigDir(), "themes")) - } if r := g.ResourcesDir(); r != "" { dirs = append(dirs, filepath.Join(r, "themes")) } return dirs } -// LoadTheme reads a theme by name (or absolute path) for previewing. +// LoadTheme reads a theme by name (or path) for previewing. A leading "~/" +// stands for the home directory, as in Ghostty 1.4 and later. func (g *Ghostty) LoadTheme(name string) (*Theme, error) { var path string - if filepath.IsAbs(name) { + if rest, ok := strings.CutPrefix(name, "~/"); ok { + path = filepath.Join(os.Getenv("HOME"), rest) + } else if filepath.IsAbs(name) { path = name } else { for _, d := range g.ThemeDirs() { diff --git a/internal/ghostty/paths_test.go b/internal/ghostty/paths_test.go new file mode 100644 index 0000000..cfeb2bc --- /dev/null +++ b/internal/ghostty/paths_test.go @@ -0,0 +1,42 @@ +package ghostty + +import ( + "os" + "path/filepath" + "slices" + "testing" +) + +func TestLoadThemeExpandsHome(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + dir := filepath.Join(home, "themes") + if err := os.MkdirAll(dir, 0o755); err != nil { + t.Fatal(err) + } + theme := "background = #252528\npalette = 1=#f38ba8\n" + if err := os.WriteFile(filepath.Join(dir, "mine"), []byte(theme), 0o644); err != nil { + t.Fatal(err) + } + th, err := (&Ghostty{}).LoadTheme("~/themes/mine") + if err != nil { + t.Fatal(err) + } + if th.Background != "#252528" || th.Palette[1] != "#f38ba8" { + t.Errorf("theme: %+v", th) + } +} + +// Ghostty looks for user themes in the XDG config directory only, also on +// macOS, where the config file usually lives under Application Support. +func TestThemeDirsFollowGhostty(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("XDG_CONFIG_HOME", "") + t.Setenv("GHOSTTY_RESOURCES_DIR", "") + got := (&Ghostty{}).ThemeDirs() + want := []string{filepath.Join(home, ".config", "ghostty", "themes")} + if !slices.Equal(got, want) { + t.Errorf("ThemeDirs = %v, want %v", got, want) + } +} diff --git a/internal/schema/categories.go b/internal/schema/categories.go index 452caf2..382c2d1 100644 --- a/internal/schema/categories.go +++ b/internal/schema/categories.go @@ -61,16 +61,17 @@ var categoryByKey = map[string]string{ "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, - "scrollback-limit": CatScrolling, "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, @@ -96,12 +97,14 @@ var categoryByKey = map[string]string{ "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}, diff --git a/internal/schema/schema.go b/internal/schema/schema.go index 39e7682..6d870be 100644 --- a/internal/schema/schema.go +++ b/internal/schema/schema.go @@ -59,6 +59,24 @@ type Option struct { Category string `json:"-"` Platform string `json:"-"` // "", "macOS" or "Linux" + // OldValues are values Ghostty no longer documents but still accepts + // (from Schema.Compat). + OldValues []string `json:"-"` +} + +// Compat is an entry of Ghostty's compatibility table: a key or value from +// an older release that Ghostty still reads although it is no longer +// documented. +type Compat struct { + Key string `json:"key"` + RenamedTo string `json:"renamedTo,omitempty"` // the key's current name + Values []string `json:"values,omitempty"` // old values of a current option + Sets []string `json:"sets,omitempty"` // options an old key sets instead +} + +// IsOldValue reports whether v is an old value Ghostty still accepts. +func (o *Option) IsOldValue(v string) bool { + return contains(o.OldValues, strings.TrimSpace(Unquote(v))) } // Default returns the default value for scalar options ("" when unset). @@ -100,6 +118,9 @@ func (o *Option) TypeLabel() string { } else if o.Min != nil { s += fmt.Sprintf(" (%s or more)", num(*o.Min)) } + if len(o.Values) > 0 { + s += " or " + strings.Join(o.Values, ", ") + } case KindFloat: s = "number" if o.Min != nil && o.Max != nil { @@ -143,10 +164,12 @@ func (o *Option) TypeLabel() string { type Schema struct { GhosttyVersion string `json:"ghosttyVersion"` Options []*Option `json:"options"` + Compat []*Compat `json:"compat,omitempty"` // Source describes where docs and defaults came from. Source string `json:"-"` - byKey map[string]*Option + byKey map[string]*Option + compatBy map[string]*Compat } //go:embed schema.json @@ -168,13 +191,41 @@ func (s *Schema) Lookup(key string) *Option { return s.byKey[key] } +// OldKey returns the compatibility entry for a key that is no longer an +// option of its own (renamed or replaced), or nil. +func (s *Schema) OldKey(key string) *Compat { + if c := s.compatBy[key]; c != nil && s.byKey[key] == nil { + return c + } + return nil +} + +// OldNames returns the old keys that Ghostty reads as key. +func (s *Schema) OldNames(key string) []string { + var out []string + for _, c := range s.Compat { + if c.RenamedTo == key && s.byKey[c.Key] == nil { + out = append(out, c.Key) + } + } + return out +} + func (s *Schema) finish() { s.byKey = make(map[string]*Option, len(s.Options)) for _, o := range s.Options { o.Category = categorize(o.Key) o.Platform = platform(o) + o.OldValues = nil s.byKey[o.Key] = o } + s.compatBy = make(map[string]*Compat, len(s.Compat)) + for _, c := range s.Compat { + s.compatBy[c.Key] = c + if o := s.byKey[c.Key]; o != nil { + o.OldValues = c.Values + } + } } // Refresh replaces docs and defaults with the output of diff --git a/internal/schema/schema.json b/internal/schema/schema.json index 268c423..e9daef4 100644 --- a/internal/schema/schema.json +++ b/internal/schema/schema.json @@ -1,5 +1,5 @@ { - "ghosttyVersion": "1.3.1", + "ghosttyVersion": "1.4.0", "options": [ { "key": "language", @@ -538,7 +538,7 @@ "key": "selection-word-chars", "zigType": "SelectionWordChars", "kind": "text", - "doc": "Characters that mark word boundaries during text selection operations such\nas double-clicking. When selecting a word, the selection will stop at any\nof these characters.\n\nThis is similar to the `WORDCHARS` environment variable in zsh, except this\nspecifies the boundary characters rather than the word characters. The\ndefault includes common delimiters and punctuation that typically separate\nwords in code and prose.\n\nEach character in this string becomes a word boundary. Multi-byte UTF-8\ncharacters are supported, but only single codepoints can be specified.\nMulti-codepoint sequences (e.g. emoji) are not supported.\n\nThe null character (U+0000) is always treated as a boundary and does not\nneed to be included in this configuration.\n\nDefault: `` \\t'\"│`|:;,()[]{}\u003c\u003e$ ``\n\nTo add or remove specific characters, you can set this to a custom value.\nFor example, to treat semicolons as part of words:\n\n selection-word-chars = \" \\t'\\\"│`|:,()[]{}\u003c\u003e$\"\n\nAvailable since: 1.3.0", + "doc": "Characters that mark word boundaries during text selection operations such\nas double-clicking. When selecting a word, the selection will stop at any\nof these characters.\n\nThis is similar to the `WORDCHARS` environment variable in zsh, except this\nspecifies the boundary characters rather than the word characters. The\ndefault includes common delimiters and punctuation that typically separate\nwords in code and prose.\n\nEach character in this string becomes a word boundary. Multi-byte UTF-8\ncharacters are supported, but only single codepoints can be specified.\nMulti-codepoint sequences (e.g. emoji) are not supported.\n\nThe null character (U+0000) is always treated as a boundary and does not\nneed to be included in this configuration.\n\nDefault: ``\\t '\"│`|:;,()[]{}\u003c\u003e$``\n\nTo add or remove specific characters, you can set this to a custom value.\nFor example, to treat semicolons as part of words:\n\n selection-word-chars = \"\\t '\\\"│`|:,()[]{}\u003c\u003e$\"\n\nAvailable since: 1.3.0", "defaults": [ " \t'\"│`|:;,()[]{}\u003c\u003e$" ] @@ -902,7 +902,7 @@ "key": "cursor-click-to-move", "zigType": "bool", "kind": "bool", - "doc": "Enables the ability to move the cursor at prompts by clicking on a\nlocation in the prompt text.\n\nThis feature requires shell integration, specifically prompt marking\nvia `OSC 133`. Some shells like Fish (v4) and Nu (0.111+) natively\nsupport this while others may require additional configuration or\nGhostty's shell integration features to be enabled.\n\nDepending on the shell, this works either by translating your click\nposition into a series of synthetic arrow key movements or by sending\na click event directly to the shell. In either case, some unexpected\nbehavior around edge cases is possible.", + "doc": "Enables the ability to move the cursor at prompts by clicking on a\nlocation in the prompt text.\n\nThis feature requires prompt marking via `OSC 133`. Some shells like Fish\n(v4.1+) and Nu (0.111+) natively support this while others may require\nadditional configuration or Ghostty's shell integration features to be\nenabled.\n\nDepending on the shell, this works either by translating your click\nposition into a series of synthetic arrow key movements or by sending\na click event directly to the shell. In either case, some unexpected\nbehavior around edge cases is possible.", "defaults": [ "true" ] @@ -994,7 +994,7 @@ "macos-glass-clear" ], "hint": "true, false, a blur radius (e.g. 20) or a macOS glass style", - "doc": "Whether to blur the background when `background-opacity` is less than 1.\n\nValid values are:\n\n * a nonnegative integer specifying the *blur intensity*\n * `false`, equivalent to a blur intensity of 0\n * `true`, equivalent to the default blur intensity of 20, which is\n reasonable for a good looking blur. Higher blur intensities may\n cause strange rendering and performance issues.\n\nOn macOS 26.0 and later, there are additional special values that\ncan be set to use the native macOS glass effects:\n\n * `macos-glass-regular` - Standard glass effect with some opacity\n * `macos-glass-clear` - Highly transparent glass effect\n\nIf the macOS values are set, then this implies `background-blur = true`\non non-macOS platforms.\n\nSupported on macOS and on some Linux desktop environments, including:\n\n * KDE Plasma (Wayland and X11)\n\nWarning: the exact blur intensity is _ignored_ under KDE Plasma, and setting\nthis setting to either `true` or any positive blur intensity value would\nachieve the same effect. The reason is that KWin, the window compositor\npowering Plasma, only has one global blur setting and does not allow\napplications to specify individual blur settings.\n\nTo configure KWin's global blur setting, open System Settings and go to\n\"Apps \u0026 Windows\" \u003e \"Window Management\" \u003e \"Desktop Effects\" and select the\n\"Blur\" plugin. If disabled, enable it by ticking the checkbox to the left.\nThen click on the \"Configure\" button and there will be two sliders that\nallow you to set background blur and noise intensities for all apps,\nincluding Ghostty.\n\nAll other Linux desktop environments are as of now unsupported. Users may\nneed to set environment-specific settings and/or install third-party plugins\nin order to support background blur, as there isn't a unified interface for\ndoing so.", + "doc": "Whether to blur the background when `background-opacity` is less than 1.\n\nValid values are:\n\n * a nonnegative integer specifying the *blur intensity*\n * `false`, equivalent to a blur intensity of 0\n * `true`, equivalent to the default blur intensity of 20, which is\n reasonable for a good looking blur. Higher blur intensities may\n cause strange rendering and performance issues.\n\nOn macOS 26.0 and later, there are additional special values that\ncan be set to use the native macOS glass effects:\n\n * `macos-glass-regular` - Standard glass effect with some opacity\n * `macos-glass-clear` - Highly transparent glass effect\n\nIf the macOS values are set, then this implies `background-blur = true`\non non-macOS platforms.\n\nOn Linux, the exact blur intensity is ignored and any positive integer\nor `true` value will enable background blur. On Wayland, Ghostty uses\nthe [`ext-background-effect-v1`](https://wayland.app/protocols/ext-background-effect-v1)\nprotocol to enable the blur effect, but this is not always supported\non all compositors. Check the documentation of your compositor or\ndesktop environment for blur support and how to configure it.\n\nOn X11, blur can only be enabled when using the KWin compositor\nas a part of KDE Plasma.", "defaults": [ "false" ] @@ -1191,13 +1191,38 @@ ] }, { - "key": "scrollback-limit", - "zigType": "usize", + "key": "scrollback-limit-bytes", + "zigType": "Limit(usize, 50_000_000)", "kind": "int", + "values": [ + "unlimited" + ], "min": 0, - "doc": "The size of the scrollback buffer in bytes. This also includes the active\nscreen. No matter what this is set to, enough memory will always be\nallocated for the visible screen and anything leftover is the limit for\nthe scrollback.\n\nWhen this limit is reached, the oldest lines are removed from the\nscrollback.\n\nScrollback currently exists completely in memory. This means that the\nlarger this value, the larger potential memory usage. Scrollback is\nallocated lazily up to this limit, so if you set this to a very large\nvalue, it will not immediately consume a lot of memory.\n\nThis size is per terminal surface, not for the entire application.\n\nIt is not currently possible to set an unlimited scrollback buffer.\nThis is a future planned feature.\n\nThis can be changed at runtime but will only affect new terminal surfaces.", + "doc": "The size of the scrollback buffer in bytes. This also includes the active\nscreen. No matter what this is set to, enough memory will always be\nallocated for the visible screen and anything leftover is the limit for\nthe scrollback.\n\nWhen this limit is reached, the oldest lines are removed from the\nscrollback.\n\nScrollback is stored in memory and allocated lazily up to this limit, so\nsetting a very large limit does not immediately consume that amount of\nmemory. On supported systems with scrollback compression enabled, Ghostty\nattempts to compress fully historical pages which are not currently visible\nwhile the terminal is idle. This can reduce physical memory usage, depending\non the contents of the scrollback.\n\nThis limit always measures the uncompressed logical size of the terminal\npages. Compression does not allow Ghostty to retain more history than the\nconfigured limit. Accessing compressed history restores it transparently\nand may increase the terminal's physical memory usage again.\n\nThis size is per terminal surface, not for the entire application.\n\nA separate maximum can be set with `scrollback-limit-lines`; if both limits\nare set, then the first one reached will determine when scrollback is\nremoved.\n\nThe default is 50 MB. Set this to `unlimited` to remove the byte limit.\n\nThis can be changed at runtime but will only affect new terminal surfaces.", "defaults": [ - "10000000" + "50000000" + ] + }, + { + "key": "scrollback-limit-lines", + "zigType": "Limit(usize, std.math.maxInt(usize))", + "kind": "int", + "values": [ + "unlimited" + ], + "min": 0, + "doc": "The maximum number of lines of scrollback to retain. This excludes\nthe active screen. Soft-wrapped lines count as multiple lines.\n\nThis limit is an estimate. Internally, Ghostty will only trim lines\nup to the minimum allocation unit that is used internally (called a\n\"page\"). The size of a page depends on how many styles, graphemes, etc.\ntake up the screen. In practice, this can be anywhere from a handful to\na couple hundred lines. Importantly, memory is capped either way.\nThis means that the actual limited lines will likely be slightly\nhigher in practice.\n\nThe default is `unlimited`. A separate maximum can be set with\n`scrollback-limit-bytes`; if both limits are set, then the first one reached\nwill determine when scrollback is removed.\n\nThis can be changed at runtime but will only affect new terminal surfaces.", + "defaults": [ + "unlimited" + ] + }, + { + "key": "scrollback-compression", + "zigType": "bool", + "kind": "bool", + "doc": "Whether to compress scrollback pages while the terminal is idle.\n\nGhostty does its best to only compress when idle and decompress\nas needed. This means that compression doesn't lower IO throughput.\nWe recommend you keep it on.\n\nThe scrollback limit remains an uncompressed logical limit regardless of\nthis setting, so disabling compression can increase physical memory usage\nbut does not change how much history is retained.\n\nText-heavy terminal history generally compresses to approximately 10% to\n30% of its uncompressed page memory, corresponding to a 70% to 90% reduction\nin physical memory for pages which are compressed. Compression savings are\ncontent-dependent.\n\nNote that the way Ghostty works is that we compress and discard the\nphysical/resident memory but we retain virtual mappings. You will not\nsee a decrease in virtual memory usage, but you will see a decrease\nin physical/memory usage.\n\nChanging this at runtime affects future compression work. Pages which are\nalready compressed remain compressed until their contents are accessed.", + "defaults": [ + "true" ] }, { @@ -1208,7 +1233,7 @@ "system", "never" ], - "doc": "Control when the scrollbar is shown to scroll the scrollback buffer.\n\nThe default value is `system`.\n\nValid values:\n\n * `system` - Respect the system settings for when to show scrollbars.\n For example, on macOS, this will respect the \"Scrollbar behavior\"\n system setting which by default usually only shows scrollbars while\n actively scrolling or hovering the gutter.\n\n * `never` - Never show a scrollbar. You can still scroll using the mouse,\n keybind actions, etc. but you will not have a visual UI widget showing\n a scrollbar.", + "doc": "Control when the scrollbar is shown to scroll the scrollback buffer.\n\nThe default value is `system`.\n\nValid values:\n\n * `system` - Respect the system settings for when to show scrollbars.\n On macOS, we only show scrollbars while actively scrolling or hovering\n the gutter. If the system setting is set to \"Always\", the scrollbar\n will be shown when the mouse is over the gutter area.\n\n * `never` - Never show a scrollbar. You can still scroll using the mouse,\n keybind actions, etc. but you will not have a visual UI widget showing\n a scrollbar.", "defaults": [ "system" ] @@ -1222,6 +1247,15 @@ "true" ] }, + { + "key": "link-osc8", + "zigType": "bool", + "kind": "bool", + "doc": "Enable hyperlinks created with the OSC 8 escape sequence. When disabled,\nOSC 8 hyperlinks are not highlighted, previewed, copied, or opened.\n\nThis does not affect URL matching controlled by `link-url`.\n\nAvailable since: 1.4.0", + "defaults": [ + "true" + ] + }, { "key": "link-previews", "zigType": "LinkPreviews", @@ -1307,10 +1341,10 @@ "zigType": "Keybinds", "kind": "keybind", "repeatable": true, - "doc": "Key bindings. The format is `trigger=action`. Duplicate triggers will\noverwrite previously set values. The list of actions is available in\nthe documentation or using the `ghostty +list-actions` command.\n\nTrigger: `+`-separated list of keys and modifiers. Example: `ctrl+a`,\n`ctrl+shift+b`, `up`.\n\nIf the key is a single Unicode codepoint, the trigger will match\nany presses that produce that codepoint. These are impacted by\nkeyboard layouts. For example, `a` will match the `a` key on a\nQWERTY keyboard, but will match the `q` key on a AZERTY keyboard\n(assuming US physical layout).\n\nFor Unicode codepoints, matching is done by comparing the set of\nmodifiers with the unmodified codepoint. The unmodified codepoint is\nsometimes called an \"unshifted character\" in other software, but all\nmodifiers are considered, not only shift. For example, `ctrl+a` will match\n`a` but not `ctrl+shift+a` (which is `A` on a US keyboard).\n\nFurther, codepoint matching is case-insensitive and the unmodified\ncodepoint is always case folded for comparison. As a result,\n`ctrl+A` configured will match when `ctrl+a` is pressed. Note that\nthis means some key combinations are impossible depending on keyboard\nlayout. For example, `ctrl+_` is impossible on a US keyboard because\n`_` is `shift+-` and `ctrl+shift+-` is not equal to `ctrl+_` (because\nthe modifiers don't match!). More details on impossible key combinations\ncan be found at this excellent source written by Qt developers:\nhttps://doc.qt.io/qt-6/qkeysequence.html#keyboard-layout-issues\n\nPhysical key codes can be specified by using any of the key codes\nas specified by the [W3C specification](https://www.w3.org/TR/uievents-code/).\nFor example, `KeyA` will match the physical `a` key on a US standard\nkeyboard regardless of the keyboard layout. These are case-sensitive.\n\nFor aesthetic reasons, the w3c codes also support snake case. For\nexample, `key_a` is equivalent to `KeyA`. The only exceptions are\nfunction keys, e.g. `F1` is `f1` (no underscore). This is a consequence\nof our internal code using snake case but is purposely supported\nand tested so it is safe to use. It allows an all-lowercase binding\nwhich I find more aesthetically pleasing.\n\nFunction keys such as `insert`, `up`, `f5`, etc. are also specified\nusing the keys as specified by the previously linked W3C specification.\n\nPhysical keys always match with a higher priority than Unicode codepoints,\nso if you specify both `a` and `KeyA`, the physical key will always be used\nregardless of what order they are configured.\n\nThe special key `catch_all` can be used to match any key that is not\notherwise bound. This can be combined with modifiers, for example\n`ctrl+catch_all` will match any key pressed with `ctrl` that is not\notherwise bound. When looking up a binding, Ghostty first tries to match\n`catch_all` with modifiers. If no match is found and the event has\nmodifiers, it falls back to `catch_all` without modifiers.\n\nValid modifiers are `shift`, `ctrl` (alias: `control`), `alt` (alias: `opt`,\n`option`), and `super` (alias: `cmd`, `command`). You may use the modifier\nor the alias. When debugging keybinds, the non-aliased modifier will always\nbe used in output.\n\nNote: The fn or \"globe\" key on keyboards are not supported as a\nmodifier. This is a limitation of the operating systems and GUI toolkits\nthat Ghostty uses.\n\nSome additional notes for triggers:\n\n * modifiers cannot repeat, `ctrl+ctrl+a` is invalid.\n\n * modifiers and keys can be in any order, `shift+a+ctrl` is *weird*,\n but valid.\n\n * only a single key input is allowed, `ctrl+a+b` is invalid.\n\nYou may also specify multiple triggers separated by `\u003e` to require a\nsequence of triggers to activate the action. For example,\n`ctrl+a\u003en=new_window` will only trigger the `new_window` action if the\nuser presses `ctrl+a` followed separately by `n`. In other software, this\nis sometimes called a leader key, a key chord, a key table, etc. There\nis no hardcoded limit on the number of parts in a sequence.\n\nWarning: If you define a sequence as a CLI argument to `ghostty`,\nyou probably have to quote the keybind since `\u003e` is a special character\nin most shells. Example: ghostty --keybind='ctrl+a\u003en=new_window'\n\nA trigger sequence has some special handling:\n\n * Ghostty will wait an indefinite amount of time for the next key in\n the sequence. There is no way to specify a timeout. The only way to\n force the output of a prefix key is to assign another keybind to\n specifically output that key (e.g. `ctrl+a\u003ectrl+a=text:foo`) or\n press an unbound key which will send both keys to the program.\n\n * If an unbound key is pressed during a sequence and a `catch_all`\n binding exists that would `ignore` the input, the entire sequence\n is dropped and nothing happens. Otherwise, the entire sequence is\n encoded and sent to the running program as if no keybind existed.\n\n * If a prefix in a sequence is previously bound, the sequence will\n override the previous binding. For example, if `ctrl+a` is bound to\n `new_window` and `ctrl+a\u003en` is bound to `new_tab`, pressing `ctrl+a`\n will do nothing.\n\n * Adding to the above, if a previously bound sequence prefix is\n used in a new, non-sequence binding, the entire previously bound\n sequence will be unbound. For example, if you bind `ctrl+a\u003en` and\n `ctrl+a\u003et`, and then bind `ctrl+a` directly, both `ctrl+a\u003en` and\n `ctrl+a\u003et` will become unbound.\n\n * Trigger sequences are not allowed for `global:` or `all:`-prefixed\n triggers. This is a limitation we could remove in the future.\n\nAction is the action to take when the trigger is satisfied. It takes the\nformat `action` or `action:param`. The latter form is only valid if the\naction requires a parameter.\n\n * `ignore` - Do nothing, ignore the key input. This can be used to\n black hole certain inputs to have no effect.\n\n * `unbind` - Remove the binding. This makes it so the previous action\n is removed, and the key will be sent through to the child command\n if it is printable. Unbind will remove any matching trigger,\n including `physical:`-prefixed triggers without specifying the\n prefix.\n\n * `csi:text` - Send a CSI sequence. e.g. `csi:A` sends \"cursor up\".\n\n * `esc:text` - Send an escape sequence. e.g. `esc:d` deletes to the\n end of the word to the right.\n\n * `text:text` - Send a string. Uses Zig string literal syntax.\n e.g. `text:\\x15` sends Ctrl-U.\n\n * All other actions can be found in the documentation or by using the\n `ghostty +list-actions` command.\n\nSome notes for the action:\n\n * The parameter is taken as-is after the `:`. Double quotes or\n other mechanisms are included and NOT parsed. If you want to\n send a string value that includes spaces, wrap the entire\n trigger/action in double quotes. Example: `--keybind=\"up=csi:A B\"`\n\nThere are some additional special values that can be specified for\nkeybind:\n\n * `keybind=clear` will clear all set keybindings. Warning: this\n removes ALL keybindings up to this point, including the default\n keybindings.\n\nThe keybind trigger can be prefixed with some special values to change\nthe behavior of the keybind. These are:\n\n * `all:`\n\n Make the keybind apply to all terminal surfaces. By default,\n keybinds only apply to the focused terminal surface. If this is true,\n then the keybind will be sent to all terminal surfaces. This only\n applies to actions that are surface-specific. For actions that\n are already global (e.g. `quit`), this prefix has no effect.\n\n Available since: 1.0.0\n\n * `global:`\n\n Make the keybind global. By default, keybinds only work within Ghostty\n and under the right conditions (application focused, sometimes terminal\n focused, etc.). If you want a keybind to work globally across your system\n (e.g. even when Ghostty is not focused), specify this prefix.\n This prefix implies `all:`.\n\n Note: this does not work in all environments; see the additional notes\n below for more information.\n\n Available since: 1.0.0 on macOS, 1.2.0 on GTK\n\n * `unconsumed:`\n\n Do not consume the input. By default, a keybind will consume the input,\n meaning that the associated encoding (if any) will not be sent to the\n running program in the terminal. If you wish to send the encoded value\n to the program, specify the `unconsumed:` prefix before the entire\n keybind. For example: `unconsumed:ctrl+a=reload_config`. `global:` and\n `all:`-prefixed keybinds will always consume the input regardless of\n this setting. Since they are not associated with a specific terminal\n surface, they're never encoded.\n\n Available since: 1.0.0\n\n * `performable:`\n\n Only consume the input if the action is able to be performed.\n For example, the `copy_to_clipboard` action will only consume the input\n if there is a selection to copy. If there is no selection, Ghostty\n behaves as if the keybind was not set. This has no effect with `global:`\n or `all:`-prefixed keybinds. For key sequences, this will reset the\n sequence if the action is not performable (acting identically to not\n having a keybind set at all).\n\n Performable keybinds will not appear as menu shortcuts in the\n application menu. This is because the menu shortcuts force the\n action to be performed regardless of the state of the terminal.\n Performable keybinds will still work, they just won't appear as\n a shortcut label in the menu.\n\n Available since: 1.1.0\n\nKeybind triggers are not unique per prefix combination. For example,\n`ctrl+a` and `global:ctrl+a` are not two separate keybinds. The keybind\nset later will overwrite the keybind set earlier. In this case, the\n`global:` keybind will be used.\n\nMultiple prefixes can be specified. For example,\n`global:unconsumed:ctrl+a=reload_config` will make the keybind global\nand not consume the input to reload the config.\n\nNote: `global:` is only supported on macOS and certain Linux platforms.\n\nOn macOS, this feature requires accessibility permissions to be granted\nto Ghostty. When a `global:` keybind is specified and Ghostty is launched\nor reloaded, Ghostty will attempt to request these permissions.\nIf the permissions are not granted, the keybind will not work. On macOS,\nyou can find these permissions in System Preferences -\u003e Privacy \u0026 Security\n-\u003e Accessibility.\n\nOn Linux, you need a desktop environment that implements the\n[Global Shortcuts](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.GlobalShortcuts.html)\nprotocol as a part of its XDG desktop protocol implementation.\nDesktop environments that are known to support (or not support)\nglobal shortcuts include:\n\n - Users using KDE Plasma (since [5.27](https://kde.org/announcements/plasma/5/5.27.0/#wayland))\n and GNOME (since [48](https://release.gnome.org/48/#and-thats-not-all)) should be able\n to use global shortcuts with little to no configuration.\n\n - Some manual configuration is required on Hyprland. Consult the steps\n outlined on the [Hyprland Wiki](https://wiki.hyprland.org/Configuring/Binds/#dbus-global-shortcuts)\n to set up global shortcuts correctly.\n (Important: [`xdg-desktop-portal-hyprland`](https://wiki.hyprland.org/Hypr-Ecosystem/xdg-desktop-portal-hyprland/)\n must also be installed!)\n\n - Notably, global shortcuts have not been implemented on wlroots-based\n compositors like Sway (see [upstream issue](https://github.com/emersion/xdg-desktop-portal-wlr/issues/240)).\n\n## Chained Actions\n\nA keybind can have multiple actions by using the `chain` keyword for\nsubsequent actions. When a keybind is activated, all chained actions are\nexecuted in order. The syntax is:\n\n```ini\nkeybind = ctrl+a=new_window\nkeybind = chain=goto_split:left\n```\n\nThis binds `ctrl+a` to first open a new window, then move focus to the\nleft split. Each `chain` entry appends an action to the most recently\ndefined keybind. You can chain as many actions as you want:\n\n```ini\nkeybind = ctrl+a=new_window\nkeybind = chain=goto_split:left\nkeybind = chain=toggle_fullscreen\n```\n\nChained actions cannot have prefixes like `global:` or `unconsumed:`.\nThe flags from the original keybind apply to the entire chain.\n\nChained actions work with key sequences as well. For example:\n\n```ini\nkeybind = ctrl+a\u003en=new_window\nkeybind = chain=goto_split:left\n````\n\nChains with key sequences apply to the most recent binding in the\nsequence.\n\nChained keybinds are available since Ghostty 1.3.0.\n\n## Key Tables\n\nYou may also create a named set of keybindings known as a \"key table.\"\nA key table must be explicitly activated for the bindings to become\navailable. This can be used to implement features such as a\n\"copy mode\", \"vim mode\", etc. Generically, this can implement modal\nkeyboard input.\n\nKey tables are defined using the syntax `\u003ctable\u003e/\u003cbinding\u003e`. The\n`\u003cbinding\u003e` value is everything documented above for keybinds. The\n`\u003ctable\u003e` value is the name of the key table. Table names can contain\nanything except `/`, `=`, `+`, and `\u003e`. The characters `+` and `\u003e` are\nreserved for keybind syntax (modifier combinations and key sequences).\nFor example `foo/ctrl+a=new_window` defines a binding within a table\nnamed `foo`.\n\nTables are activated and deactivated using the binding actions\n`activate_key_table:\u003cname\u003e` and `deactivate_key_table`. Other table\nrelated binding actions also exist; see the documentation for a full list.\nThese are the primary way to interact with key tables.\n\nBinding lookup proceeds from the innermost table outward, so keybinds in\nthe default table remain available unless explicitly unbound in an inner\ntable.\n\nA key table has some special syntax and handling:\n\n * `\u003cname\u003e/` (with no binding) defines and clears a table, resetting all\n of its keybinds and settings.\n\n * You cannot activate a table that is already the innermost table; such\n attempts are ignored. However, the same table can appear multiple times\n in the stack as long as it is not innermost (e.g., `A -\u003e B -\u003e A -\u003e B`\n is valid, but `A -\u003e B -\u003e B` is not).\n\n * A table can be activated in one-shot mode using\n `activate_key_table_once:\u003cname\u003e`. A one-shot table is automatically\n deactivated when any non-catch-all binding is invoked.\n\n * Key sequences work within tables: `foo/ctrl+a\u003ectrl+b=new_window`.\n If an invalid key is pressed, the sequence ends but the table remains\n active.\n\n * Chain actions work within tables, the `chain` keyword applies to\n the most recently defined binding in the table. e.g. if you set\n `table/ctrl+a=new_window` you can chain by using `chain=text:hello`.\n Important: chain itself doesn't get prefixed with the table name,\n since it applies to the most recent binding in any table.\n\n * Prefixes like `global:` work within tables:\n `foo/global:ctrl+a=new_window`.\n\nKey tables are available since Ghostty 1.3.0.", + "doc": "Key bindings. The format is `trigger=action`. Duplicate triggers will\noverwrite previously set values. The list of actions is available in\nthe documentation or using the `ghostty +list-actions` command.\n\nTrigger: `+`-separated list of keys and modifiers. Example: `ctrl+a`,\n`ctrl+shift+b`, `up`.\n\nIf the key is a single Unicode codepoint, the trigger will match\nany presses that produce that codepoint. These are impacted by\nkeyboard layouts. For example, `a` will match the `a` key on a\nQWERTY keyboard, but will match the `q` key on a AZERTY keyboard\n(assuming US physical layout).\n\nFor Unicode codepoints, matching is done by comparing the set of\nmodifiers with the unmodified codepoint. The unmodified codepoint is\nsometimes called an \"unshifted character\" in other software, but all\nmodifiers are considered, not only shift. For example, `ctrl+a` will match\n`a` but not `ctrl+shift+a` (which is `A` on a US keyboard).\n\nFurther, codepoint matching is case-insensitive and the unmodified\ncodepoint is always case folded for comparison. As a result,\n`ctrl+A` configured will match when `ctrl+a` is pressed. Note that\nthis means some key combinations are impossible depending on keyboard\nlayout. For example, `ctrl+_` is impossible on a US keyboard because\n`_` is `shift+-` and `ctrl+shift+-` is not equal to `ctrl+_` (because\nthe modifiers don't match!). More details on impossible key combinations\ncan be found at this excellent source written by Qt developers:\nhttps://doc.qt.io/qt-6/qkeysequence.html#keyboard-layout-issues\n\nPhysical key codes can be specified by using any of the key codes\nas specified by the [W3C specification](https://www.w3.org/TR/uievents-code/).\nFor example, `KeyA` will match the physical `a` key on a US standard\nkeyboard regardless of the keyboard layout. These are case-sensitive.\n\nFor aesthetic reasons, the w3c codes also support snake case. For\nexample, `key_a` is equivalent to `KeyA`. The only exceptions are\nfunction keys, e.g. `F1` is `f1` (no underscore). This is a consequence\nof our internal code using snake case but is purposely supported\nand tested so it is safe to use. It allows an all-lowercase binding\nwhich I find more aesthetically pleasing.\n\nFunction keys such as `insert`, `up`, `f5`, etc. are also specified\nusing the keys as specified by the previously linked W3C specification.\n\nPhysical keys always match with a higher priority than Unicode codepoints,\nso if you specify both `a` and `KeyA`, the physical key will always be used\nregardless of what order they are configured.\n\nThe special key `catch_all` can be used to match any key that is not\notherwise bound. This can be combined with modifiers, for example\n`ctrl+catch_all` will match any key pressed with `ctrl` that is not\notherwise bound. When looking up a binding, Ghostty first tries to match\n`catch_all` with modifiers. If no match is found and the event has\nmodifiers, it falls back to `catch_all` without modifiers.\n\nValid modifiers are `shift`, `ctrl` (alias: `control`), `alt` (alias: `opt`,\n`option`), and `super` (alias: `cmd`, `command`). You may use the modifier\nor the alias. When debugging keybinds, the non-aliased modifier will always\nbe used in output.\n\nNote: The fn or \"globe\" key on keyboards are not supported as a\nmodifier. This is a limitation of the operating systems and GUI toolkits\nthat Ghostty uses.\n\nSome additional notes for triggers:\n\n * modifiers cannot repeat, `ctrl+ctrl+a` is invalid.\n\n * modifiers and keys can be in any order, `shift+a+ctrl` is *weird*,\n but valid.\n\n * only a single key input is allowed, `ctrl+a+b` is invalid.\n\nYou may also specify multiple triggers separated by `\u003e` to require a\nsequence of triggers to activate the action. For example,\n`ctrl+a\u003en=new_window` will only trigger the `new_window` action if the\nuser presses `ctrl+a` followed separately by `n`. In other software, this\nis sometimes called a leader key, a key chord, a key table, etc. There\nis no hardcoded limit on the number of parts in a sequence.\n\nWarning: If you define a sequence as a CLI argument to `ghostty`,\nyou probably have to quote the keybind since `\u003e` is a special character\nin most shells. Example: ghostty --keybind='ctrl+a\u003en=new_window'\n\nA trigger sequence has some special handling:\n\n * Ghostty will wait an indefinite amount of time for the next key in\n the sequence. There is no way to specify a timeout. The only way to\n force the output of a prefix key is to assign another keybind to\n specifically output that key (e.g. `ctrl+a\u003ectrl+a=text:foo`) or\n press an unbound key which will send both keys to the program.\n\n * If an unbound key is pressed during a sequence and a `catch_all`\n binding exists that would `ignore` the input, the entire sequence\n is dropped and nothing happens. Otherwise, the entire sequence is\n encoded and sent to the running program as if no keybind existed.\n\n * If a prefix in a sequence is previously bound, the sequence will\n override the previous binding. For example, if `ctrl+a` is bound to\n `new_window` and `ctrl+a\u003en` is bound to `new_tab`, pressing `ctrl+a`\n will do nothing.\n\n * Adding to the above, if a previously bound sequence prefix is\n used in a new, non-sequence binding, the entire previously bound\n sequence will be unbound. For example, if you bind `ctrl+a\u003en` and\n `ctrl+a\u003et`, and then bind `ctrl+a` directly, both `ctrl+a\u003en` and\n `ctrl+a\u003et` will become unbound.\n\n * Trigger sequences are not allowed for `global:` or `all:`-prefixed\n triggers. This is a limitation we could remove in the future.\n\nAction is the action to take when the trigger is satisfied. It takes the\nformat `action` or `action:param`. The latter form is only valid if the\naction requires a parameter.\n\n * `ignore` - Do nothing, ignore the key input. This can be used to\n black hole certain inputs to have no effect.\n\n * `unbind` - Remove the binding. This makes it so the previous action\n is removed, and the key will be sent through to the child command\n if it is printable. Unbind will remove any matching trigger,\n including `physical:`-prefixed triggers without specifying the\n prefix.\n\n * `csi:text` - Send a CSI sequence. e.g. `csi:A` sends \"cursor up\".\n\n * `esc:text` - Send an escape sequence. e.g. `esc:d` deletes to the\n end of the word to the right.\n\n * `text:text` - Send a string. Uses Zig string literal syntax.\n e.g. `text:\\x15` sends Ctrl-U.\n\n * All other actions can be found in the documentation or by using the\n `ghostty +list-actions` command.\n\nSome notes for the action:\n\n * The parameter is taken as-is after the `:`. Double quotes or\n other mechanisms are included and NOT parsed. If you want to\n send a string value that includes spaces, wrap the entire\n trigger/action in double quotes. Example: `--keybind=\"up=csi:A B\"`\n\nThere are some additional special values that can be specified for\nkeybind:\n\n * `keybind=clear` will clear all set keybindings. Warning: this\n removes ALL keybindings up to this point, including the default\n keybindings.\n\nThe keybind trigger can be prefixed with some special values to change\nthe behavior of the keybind. These are:\n\n * `all:`\n\n Make the keybind apply to all terminal surfaces. By default,\n keybinds only apply to the focused terminal surface. If this is true,\n then the keybind will be sent to all terminal surfaces. This only\n applies to actions that are surface-specific. For actions that\n are already global (e.g. `quit`), this prefix has no effect.\n\n Available since: 1.0.0\n\n * `global:`\n\n Make the keybind global. By default, keybinds only work within Ghostty\n and under the right conditions (application focused, sometimes terminal\n focused, etc.). If you want a keybind to work globally across your system\n (e.g. even when Ghostty is not focused), specify this prefix.\n This prefix implies `all:`.\n\n Note: this does not work in all environments; see the additional notes\n below for more information.\n\n Available since: 1.0.0 on macOS, 1.2.0 on GTK\n\n * `unconsumed:`\n\n Do not consume the input. By default, a keybind will consume the input,\n meaning that the associated encoding (if any) will not be sent to the\n running program in the terminal. If you wish to send the encoded value\n to the program, specify the `unconsumed:` prefix before the entire\n keybind. For example: `unconsumed:ctrl+a=reload_config`. `global:` and\n `all:`-prefixed keybinds will always consume the input regardless of\n this setting. Since they are not associated with a specific terminal\n surface, they're never encoded.\n\n Available since: 1.0.0\n\n * `performable:`\n\n Only consume the input if the action is able to be performed.\n For example, the `copy_to_clipboard` action will only consume the input\n if there is a selection to copy. If there is no selection, Ghostty\n behaves as if the keybind was not set. This has no effect with `global:`\n or `all:`-prefixed keybinds. For key sequences, this will reset the\n sequence if the action is not performable (acting identically to not\n having a keybind set at all).\n\n Performable keybinds will not appear as menu shortcuts in the\n application menu. This is because the menu shortcuts force the\n action to be performed regardless of the state of the terminal.\n Performable keybinds will still work, they just won't appear as\n a shortcut label in the menu.\n\n Available since: 1.1.0\n\nKeybind triggers are not unique per prefix combination. For example,\n`ctrl+a` and `global:ctrl+a` are not two separate keybinds. The keybind\nset later will overwrite the keybind set earlier. In this case, the\n`global:` keybind will be used.\n\nMultiple prefixes can be specified. For example,\n`global:unconsumed:ctrl+a=reload_config` will make the keybind global\nand not consume the input to reload the config.\n\nOn macOS, this feature requires accessibility permissions to be granted\nto Ghostty. When a `global:` keybind is specified and Ghostty is launched\nor reloaded, Ghostty will attempt to request these permissions.\nIf the permissions are not granted, the keybind will not work. On macOS,\nyou can find these permissions in System Preferences -\u003e Privacy \u0026 Security\n-\u003e Accessibility.\n\nSince Ghostty 1.4.0, global shortcuts on Linux are primarily supported\nthrough the [`vicinae-hotkey-v1`](https://github.com/vicinaehq/vicinae-wayland-protocols/tree/main/staging/vicinae-hotkey)\nprotocol, available out-of-the-box with the following Wayland compositors\nand desktop environments:\n\n - Hyprland since version 0.56.0\n\nOn X11 or when your Wayland compositor/desktop environment does not\nsupport `vicinae-hotkey-v1`, the much more widely-used\n[XDG Global Shortcuts](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.GlobalShortcuts.html)\nprotocol is used instead.\n\nNote: XDG Global Shortcuts rely on a functional XDG Desktop Portal\nimplementation **that is designed to be used with your desktop environment\nor compositor**. Please make sure that you have the correct one installed.\n\nDesktop environments that are known to support the XDG Global Shortcuts\nprotocol include:\n\n - KDE Plasma since [5.27](https://kde.org/announcements/plasma/5/5.27.0/#wayland)\n with `xdg-desktop-portal-kde` installed\n\n - GNOME since [48](https://release.gnome.org/48/#and-thats-not-all) with\n `xdg-desktop-portal-gnome` installed\n\n - Hyprland before version 0.56.0, with `xdg-desktop-portal-hyprland`\n installed. **Some manual configuration is required.** Consult the steps\n outlined on the [Hyprland Wiki](https://wiki.hypr.land/Configuring/Basics/Binds/#dbus-global-shortcuts)\n to set up D-Bus-based global shortcuts correctly.\n\nDesktop environments and compositors that don't implement either protocol\ndo not support global shortcuts, like wlroots-based compositors e.g. Sway\n(see [upstream issue](https://github.com/emersion/xdg-desktop-portal-wlr/issues/240))\nand COSMIC.\n\n## Chained Actions\n\nA keybind can have multiple actions by using the `chain` keyword for\nsubsequent actions. When a keybind is activated, all chained actions are\nexecuted in order. The syntax is:\n\n```ini\nkeybind = ctrl+a=new_window\nkeybind = chain=goto_split:left\n```\n\nThis binds `ctrl+a` to first open a new window, then move focus to the\nleft split. Each `chain` entry appends an action to the most recently\ndefined keybind. You can chain as many actions as you want:\n\n```ini\nkeybind = ctrl+a=new_window\nkeybind = chain=goto_split:left\nkeybind = chain=toggle_fullscreen\n```\n\nChained actions cannot have prefixes like `global:` or `unconsumed:`.\nThe flags from the original keybind apply to the entire chain.\n\nChained actions work with key sequences as well. For example:\n\n```ini\nkeybind = ctrl+a\u003en=new_window\nkeybind = chain=goto_split:left\n````\n\nChains with key sequences apply to the most recent binding in the\nsequence.\n\nChained keybinds are available since Ghostty 1.3.0.\n\n## Key Tables\n\nYou may also create a named set of keybindings known as a \"key table.\"\nA key table must be explicitly activated for the bindings to become\navailable. This can be used to implement features such as a\n\"copy mode\", \"vim mode\", etc. Generically, this can implement modal\nkeyboard input.\n\nKey tables are defined using the syntax `\u003ctable\u003e/\u003cbinding\u003e`. The\n`\u003cbinding\u003e` value is everything documented above for keybinds. The\n`\u003ctable\u003e` value is the name of the key table. Table names can contain\nanything except `/`, `=`, `+`, and `\u003e`. The characters `+` and `\u003e` are\nreserved for keybind syntax (modifier combinations and key sequences).\nFor example `foo/ctrl+a=new_window` defines a binding within a table\nnamed `foo`.\n\nTables are activated and deactivated using the binding actions\n`activate_key_table:\u003cname\u003e` and `deactivate_key_table`. Other table\nrelated binding actions also exist; see the documentation for a full list.\nThese are the primary way to interact with key tables.\n\nBinding lookup proceeds from the innermost table outward, so keybinds in\nthe default table remain available unless explicitly unbound in an inner\ntable.\n\nA key table has some special syntax and handling:\n\n * `\u003cname\u003e/` (with no binding) defines and clears a table, resetting all\n of its keybinds and settings.\n\n * You cannot activate a table that is already the innermost table; such\n attempts are ignored. However, the same table can appear multiple times\n in the stack as long as it is not innermost (e.g., `A -\u003e B -\u003e A -\u003e B`\n is valid, but `A -\u003e B -\u003e B` is not).\n\n * A table can be activated in one-shot mode using\n `activate_key_table_once:\u003cname\u003e`. A one-shot table is automatically\n deactivated when any non-catch-all binding is invoked.\n\n * Key sequences work within tables: `foo/ctrl+a\u003ectrl+b=new_window`.\n If an invalid key is pressed, the sequence ends but the table remains\n active.\n\n * Chain actions work within tables, the `chain` keyword applies to\n the most recently defined binding in the table. e.g. if you set\n `table/ctrl+a=new_window` you can chain by using `chain=text:hello`.\n Important: chain itself doesn't get prefixed with the table name,\n since it applies to the most recent binding in any table.\n\n * Prefixes like `global:` work within tables:\n `foo/global:ctrl+a=new_window`.\n\nKey tables are available since Ghostty 1.3.0.", "defaults": [ "super+shift+,=reload_config", - "super+,=open_config", + "super+,=open_config:os_open", "copy=copy_to_clipboard:mixed", "paste=paste_from_clipboard", "super+c=copy_to_clipboard:mixed", @@ -1397,9 +1431,9 @@ "super+alt+i=inspector:toggle", "super+ctrl+f=toggle_fullscreen", "super+shift+v=paste_from_selection", - "super+arrow_right=text:\\\\x05", - "super+arrow_left=text:\\\\x01", - "super+backspace=text:\\\\x15", + "super+arrow_right=text:\\x05", + "super+arrow_left=text:\\x01", + "super+backspace=text:\\x15", "alt+arrow_left=esc:b", "alt+arrow_right=esc:f" ] @@ -1435,9 +1469,14 @@ }, { "key": "window-padding-balance", - "zigType": "bool", - "kind": "bool", - "doc": "The viewport dimensions are usually not perfectly divisible by the cell\nsize. In this case, some extra padding on the end of a column and the bottom\nof the final row may exist. If this is `true`, then this extra padding\nis automatically balanced between all four edges to minimize imbalance on\none side. If this is `false`, the top left grid cell will always hug the\nedge with zero padding other than what may be specified with the other\n`window-padding` options.\n\nIf other `window-padding` fields are set and this is `true`, this will still\napply. The other padding is applied first and may affect how many grid cells\nactually exist, and this is applied last in order to balance the padding\ngiven a certain viewport size and grid cell size.", + "zigType": "WindowPaddingBalance", + "kind": "enum", + "values": [ + "false", + "true", + "equal" + ], + "doc": "The viewport dimensions are usually not perfectly divisible by the cell\nsize. In this case, some extra padding on the end of a column and the bottom\nof the final row may exist. If this is `true`, then this extra padding\nis automatically balanced between all four edges to minimize imbalance on\none side. If this is `false`, the top left grid cell will always hug the\nedge with zero padding other than what may be specified with the other\n`window-padding` options.\n\nIf other `window-padding` fields are set and this is `true`, this will still\napply. The other padding is applied first and may affect how many grid cells\nactually exist, and this is applied last in order to balance the padding\ngiven a certain viewport size and grid cell size.\n\nValid values are:\n\n* `false` - No balancing is applied.\n* `true` - Balance the padding, but cap the top padding to avoid\n excessive space above the first row. Any excess is shifted to the\n bottom.\n* `equal` - Balance the padding equally on all sides without any\n top-padding cap. (Available since: 1.4.0)", "defaults": [ "false" ] @@ -1679,6 +1718,20 @@ "" ] }, + { + "key": "drag-handle", + "zigType": "DragHandle", + "kind": "enum", + "values": [ + "always", + "auto", + "never" + ], + "doc": "Controls when drag handles are shown over splits,\nallowing splits to be rearranged with mouse controls.\n\nValid values:\n\n - `always`\n\n Always display the drag handle, even when there's only one split.\n\n - `auto` *(default)*\n\n Automatically show and hide the drag handle.\n\n On Linux, the handle is only shown when there are two or\n more splits present.\n\n On macOS, the handle is only hidden when there's one split\n in **fullscreen** mode, otherwise it's shown when hovered.\n\n - `never`\n\n Never show the drag handle. Splits then cannot be rearranged with\n mouse controls.\n\nAvailable since: 1.4.0.", + "defaults": [ + "auto" + ] + }, { "key": "resize-overlay", "zigType": "ResizeOverlay", @@ -1757,6 +1810,19 @@ "allow" ] }, + { + "key": "clipboard-write-limit-bytes", + "zigType": "Limit(usize, 64 * 1024 * 1024)", + "kind": "int", + "values": [ + "unlimited" + ], + "min": 0, + "doc": "The maximum size in bytes of a single clipboard write by a program\nrunning in the terminal via the Kitty clipboard protocol (OSC 5522).\nThis doesn't apply to OSC 52, which is limited by the maximum length\nof an escape sequence hardcoded into Ghostty for now.\n\nData beyond the limit fails the entire write with an `EFBIG` status,\ndiscards the transaction, and leaves the clipboard untouched. Later\nwrite-related packets are ignored until a new write begins.\n\nThe data is buffered in memory while the write is in progress, so\nthis limit bounds how much memory a program can make Ghostty\nallocate per write. A future improvement will attempt to spool large\nwrites to disk.\n\nThe default is 64 MiB, the minimum a conforming implementation must\naccept. Set this to `unlimited` to remove the limit, allowing writes\nbounded only by available memory. A value of `0` rejects every non-empty\nwrite. To reject clipboard writes entirely, use `clipboard-write = deny`\ninstead.\n\nThis can be changed at runtime and applies to writes that begin\nafter the change.\n\nAvailable since: 1.4.0", + "defaults": [ + "67108864" + ] + }, { "key": "clipboard-trim-trailing-spaces", "zigType": "bool", @@ -1770,7 +1836,7 @@ "key": "clipboard-paste-protection", "zigType": "bool", "kind": "bool", - "doc": "Require confirmation before pasting text that appears unsafe. This helps\nprevent a \"copy/paste attack\" where a user may accidentally execute unsafe\ncommands by pasting text with newlines.", + "doc": "Require confirmation before pasting text that appears unsafe. This helps\nprevent a \"copy/paste attack\" where a user may accidentally execute unsafe\ncommands by pasting text with newlines or carriage returns.", "defaults": [ "true" ] @@ -1809,13 +1875,14 @@ "zigType": "CopyOnSelect", "kind": "enum", "values": [ - "false", - "true", - "clipboard" + "none", + "primary", + "clipboard", + "both" ], - "doc": "Whether to automatically copy selected text to the clipboard. `true`\nwill prefer to copy to the selection clipboard, otherwise it will copy to\nthe system clipboard.\n\nThe value `clipboard` will always copy text to the selection clipboard\nas well as the system clipboard.\n\nMiddle-click paste will always use the selection clipboard. Middle-click\npaste is always enabled even if this is `false`.\n\nThe default value is true on Linux and macOS.", + "doc": "Whether to automatically copy selected text to the clipboard.\n\nValid values:\n\n* `none` - Do not copy selected text automatically.\n\n* `primary` - On Linux, copy to the selection clipboard only. This has no\n effect on macOS. (Available since: 1.4.0)\n\n* `clipboard` - Copy text to the system clipboard only.\n\n* `both` - Copy to both clipboards on Linux, and only the system clipboard\n on macOS. (Available since: 1.4.0)\n\nFor backward compatibility and convenience, a value of `true` is the same as\n`primary` on Linux and `clipboard` on macOS, and `false` is an alias for\n`none`.\n\nThe default value is `primary` on Linux and `none` otherwise.", "defaults": [ - "true" + "none" ] }, { @@ -1834,6 +1901,20 @@ "context-menu" ] }, + { + "key": "middle-click-action", + "zigType": "MiddleClickAction", + "kind": "enum", + "values": [ + "primary-paste", + "clipboard-paste", + "ignore" + ], + "doc": "The action to take when the user middle-clicks on the terminal surface.\n\nValid values:\n * `primary-paste` - Paste from the selection clipboard on Linux.\n Does nothing on macOS.\n * `clipboard-paste` - Paste from the system clipboard.\n * `ignore` - Do nothing, ignore the middle click.\n\nThe default value is `primary-paste`.", + "defaults": [ + "primary-paste" + ] + }, { "key": "click-repeat-interval", "zigType": "u32", @@ -1964,7 +2045,7 @@ "mouse", "macos-menu-bar" ], - "doc": "The screen where the quick terminal should show up.\n\nValid values are:\n\n * `main` - The screen that the operating system recommends as the main\n screen. On macOS, this is the screen that is currently receiving\n keyboard input. This screen is defined by the operating system and\n not chosen by Ghostty.\n\n * `mouse` - The screen that the mouse is currently hovered over.\n\n * `macos-menu-bar` - The screen that contains the macOS menu bar as\n set in the display settings on macOS. This is a bit confusing because\n every screen on macOS has a menu bar, but this is the screen that\n contains the primary menu bar.\n\nThe default value is `main` because this is the recommended screen\nby the operating system.\n\nOnly implemented on macOS.", + "doc": "The screen where the quick terminal should show up.\n\nValid values are:\n\n * `main` - The screen that the operating system recommends as the main\n screen. On macOS, this is the screen that is currently receiving\n keyboard input. This screen is defined by the operating system and\n not chosen by Ghostty.\n\n * `mouse` - The screen that the mouse is currently hovered over.\n\n * `macos-menu-bar` - The screen that contains the macOS menu bar as\n set in the display settings on macOS. This is a bit confusing because\n every screen on macOS has a menu bar, but this is the screen that\n contains the primary menu bar.\n\nThe default value is `main` because this is the recommended screen\nby the operating system.\n\nOn macOS, `macos-menu-bar` uses the screen containing the menu bar.\nOn Linux/Wayland, `macos-menu-bar` is treated as equivalent to `main`.\n\nNote: On Linux, there is no universal concept of a \"primary\" monitor.\nGhostty uses the compositor-reported primary output when available and\nfalls back to the first monitor reported by GDK if no primary output can\nbe resolved.", "defaults": [ "main" ] @@ -2044,7 +2125,7 @@ "ssh-terminfo", "path" ], - "doc": "Shell integration features to enable. These require our shell integration\nto be loaded, either automatically via shell-integration or manually.\n\nThe format of this is a list of features to enable separated by commas. If\nyou prefix a feature with `no-` then it is disabled. If you omit a feature,\nits default value is used, so you must explicitly disable features you don't\nwant. You can also use `true` or `false` to turn all features on or off.\n\nExample: `cursor`, `no-cursor`, `sudo`, `no-sudo`, `title`, `no-title`\n\nAvailable features:\n\n * `cursor` - Set the cursor to a bar at the prompt.\n\n * `sudo` - Set sudo wrapper to preserve terminfo.\n\n * `title` - Set the window title via shell integration.\n\n * `ssh-env` - Enable SSH environment variable compatibility. Automatically\n converts TERM from `xterm-ghostty` to `xterm-256color` when connecting to\n remote hosts and propagates COLORTERM, TERM_PROGRAM, and TERM_PROGRAM_VERSION.\n Whether or not these variables will be accepted by the remote host(s) will\n depend on whether or not the variables are allowed in their sshd_config.\n (Available since: 1.2.0)\n\n * `ssh-terminfo` - Enable automatic terminfo installation on remote hosts.\n Attempts to install Ghostty's terminfo entry using `infocmp` and `tic` when\n connecting to hosts that lack it. Requires `infocmp` to be available locally\n and `tic` to be available on remote hosts. Once terminfo is installed on a\n remote host, it will be automatically \"cached\" to avoid repeat installations.\n If desired, the `+ssh-cache` CLI action can be used to manage the installation\n cache manually using various arguments.\n (Available since: 1.2.0)\n\n * `path` - Add Ghostty's binary directory to PATH. This ensures the `ghostty`\n command is available in the shell even if shell init scripts reset PATH.\n This is particularly useful on macOS where PATH is often overridden by\n system scripts. The directory is only added if not already present.\n\nSSH features work independently and can be combined for optimal experience:\nwhen both `ssh-env` and `ssh-terminfo` are enabled, Ghostty will install its\nterminfo on remote hosts and use `xterm-ghostty` as TERM, falling back to\n`xterm-256color` with environment variables if terminfo installation fails.", + "doc": "Shell integration features to enable. These require our shell integration\nto be loaded, either automatically via shell-integration or manually.\n\nThe format of this is a list of features to enable separated by commas. If\nyou prefix a feature with `no-` then it is disabled. If you omit a feature,\nits default value is used, so you must explicitly disable features you don't\nwant. You can also use `true` or `false` to turn all features on or off.\n\nExample: `cursor`, `no-cursor`, `sudo`, `no-sudo`, `title`, `no-title`\n\nAvailable features:\n\n * `cursor` - Set the cursor to a bar at the prompt.\n\n * `sudo` - Set sudo wrapper to preserve terminfo.\n\n * `title` - Set the window title via shell integration.\n\n * `ssh-env` - Enable SSH environment variable compatibility. Automatically\n converts TERM from `xterm-ghostty` to `xterm-256color` when connecting to\n remote hosts and propagates COLORTERM, TERM_PROGRAM, and TERM_PROGRAM_VERSION.\n Whether or not these variables will be accepted by the remote host(s) will\n depend on whether or not the variables are allowed in their sshd_config.\n (Available since: 1.2.0)\n\n * `ssh-terminfo` - Enable automatic terminfo installation on remote hosts.\n Attempts to install Ghostty's embedded terminfo entry using `tic` on local\n cache misses. Requires `tic` to be available on remote hosts. Successful\n installations are cached locally to avoid repeat installations.\n If desired, the `+ssh-cache` CLI action can be used to manage the installation\n cache manually using various arguments.\n (Available since: 1.2.0)\n\n * `path` - Add Ghostty's binary directory to PATH. This ensures the `ghostty`\n command is available in the shell even if shell init scripts reset PATH.\n This is particularly useful on macOS where PATH is often overridden by\n system scripts. The directory is only added if not already present.\n\nSSH features work independently and can be combined for optimal experience:\nwhen both `ssh-env` and `ssh-terminfo` are enabled, Ghostty will install its\nterminfo on remote hosts and use `xterm-ghostty` as TERM, falling back to\n`xterm-256color` with environment variables if terminfo installation fails.", "defaults": [ "cursor,no-sudo,title,no-ssh-env,no-ssh-terminfo,path" ] @@ -2055,10 +2136,11 @@ "kind": "text", "repeatable": true, "hint": "title:NAME,action:ACTION[,description:TEXT]", - "doc": "Custom entries into the command palette.\n\nEach entry requires the title, the corresponding action, and an optional\ndescription. Each field should be prefixed with the field name, a colon\n(`:`), and then the specified value. The syntax for actions is identical\nto the one for keybind actions. Whitespace in between fields is ignored.\n\nIf you need to embed commas or any other special characters in the values,\nenclose the value in double quotes and it will be interpreted as a Zig\nstring literal. This is also useful for including whitespace at the\nbeginning or the end of a value. See the\n[Zig documentation](https://ziglang.org/documentation/master/#Escape-Sequences)\nfor more information on string literals. Note that multiline string literals\nare not supported.\n\nDouble quotes can not be used around the field names.\n\n```ini\ncommand-palette-entry = title:Reset Font Style, action:csi:0m\ncommand-palette-entry = title:Crash on Main Thread,description:Causes a crash on the main (UI) thread.,action:crash:main\ncommand-palette-entry = title:Focus Split: Right,description:\"Focus the split to the right, if it exists.\",action:goto_split:right\ncommand-palette-entry = title:\"Ghostty\",description:\"Add a little Ghostty to your terminal.\",action:\"text:\\xf0\\x9f\\x91\\xbb\"\n```\n\nBy default, the command palette is preloaded with most actions that might\nbe useful in an interactive setting yet do not have easily accessible or\nmemorizable shortcuts. The default entries can be cleared by setting this\nsetting to an empty value:\n\n```ini\ncommand-palette-entry =\n```\n\nAvailable since: 1.2.0", + "doc": "Custom entries into the command palette.\n\nEach entry requires the title, the corresponding action, and an optional\ndescription. Each field should be prefixed with the field name, a colon\n(`:`), and then the specified value. The syntax for actions is identical\nto the one for keybind actions. Whitespace in between fields is ignored.\n\nIf you need to embed commas or any other special characters in the values,\nenclose the value in double quotes and it will be interpreted as a Zig\nstring literal. This is also useful for including whitespace at the\nbeginning or the end of a value. See the\n[Zig documentation](https://ziglang.org/documentation/master/#Escape-Sequences)\nfor more information on string literals. Note that multiline string literals\nare not supported.\n\nDouble quotes can not be used around the field names.\n\n```ini\ncommand-palette-entry = title:Reset Font Style, action:csi:0m\ncommand-palette-entry = title:Crash on Main Thread,description:Causes a crash on the main (UI) thread.,action:crash:main\ncommand-palette-entry = title:Focus Split: Right,description:\"Focus the split to the right, if it exists.\",action:goto_split:right\ncommand-palette-entry = title:\"Ghostty\",description:\"Add a little Ghostty to your terminal.\",action:\"text:\\xf0\\x9f\\x91\\xbb\"\n```\n\nThere are some additional special values that can be specified for\ncommand-palette-entry:\n\n * `command-palette-entry=clear` will clear all command entries. Warning: this\n removes ALL entries up to this point, including the default\n entries. Available since: 1.4.0\n\nBy default, the command palette is preloaded with most actions that might\nbe useful in an interactive setting yet do not have easily accessible or\nmemorizable shortcuts. The default entries can be restored by setting this\nsetting to an empty value:\n\n```ini\ncommand-palette-entry =\n```\n\nAvailable since: 1.2.0", "defaults": [ - "title:\"Change Tab Title\\xe2\\x80\\xa6\",description:\"Prompt for a new title for the current tab.\",action:\"prompt_tab_title\"", - "title:\"Change Terminal Title\\xe2\\x80\\xa6\",description:\"Prompt for a new title for the current terminal.\",action:\"prompt_surface_title\"", + "title:\"Change Tab Title…\",description:\"Prompt for a new title for the current tab.\",action:\"prompt_tab_title\"", + "title:\"Change Terminal Title…\",description:\"Prompt for a new title for the current terminal.\",action:\"prompt_surface_title\"", + "title:\"Change Window Title…\",description:\"Prompt for a new title for the current window.\",action:\"prompt_window_title\"", "title:\"Check for Updates\",description:\"Check for updates to the application.\",action:\"check_for_updates\"", "title:\"Clear Screen\",description:\"Clear the screen and scrollback.\",action:\"clear_screen\"", "title:\"Close All Windows\",description:\"Close all windows.\",action:\"close_all_windows\"", @@ -2102,14 +2184,16 @@ "title:\"Focus Split: Up\",description:\"Focus the split above, if it exists.\",action:\"goto_split:up\"", "title:\"Focus Window: Next\",description:\"Focus the next window, if any.\",action:\"goto_window:next\"", "title:\"Focus Window: Previous\",description:\"Focus the previous window, if any.\",action:\"goto_window:previous\"", - "title:\"Ghostty\",description:\"Put a little Ghostty in your terminal.\",action:\"text:\\xf0\\x9f\\x91\\xbb\"", + "title:\"Ghostty\",description:\"Put a little Ghostty in your terminal.\",action:\"text:👻\"", "title:\"Increase Font Size\",description:\"Increase the font size by 1 point.\",action:\"increase_font_size:1\"", "title:\"Move Tab Left\",description:\"Move the current tab to the left.\",action:\"move_tab:-1\"", "title:\"Move Tab Right\",description:\"Move the current tab to the right.\",action:\"move_tab:1\"", + "title:\"Move Tab to New Window\",description:\"Move the current tab to a new window.\",action:\"move_tab_to_new_window\"", "title:\"New Tab\",description:\"Open a new tab.\",action:\"new_tab\"", "title:\"New Window\",description:\"Open a new window.\",action:\"new_window\"", "title:\"Next Search Result\",description:\"Navigate to the next search result, if any.\",action:\"navigate_search:next\"", - "title:\"Open Config\",description:\"Open the config file.\",action:\"open_config\"", + "title:\"Open Config in New Terminal Window\",description:\"Open the config file in a new window using $EDITOR or $VISUAL.\",action:\"open_config:new_window\"", + "title:\"Open Config Using OS editor\",description:\"Open the config file with the OS's default editor.\",action:\"open_config:os_open\"", "title:\"Paste from Clipboard\",description:\"Paste the contents of the main clipboard.\",action:\"paste_from_clipboard\"", "title:\"Paste from Selection\",description:\"Paste the contents of the selection clipboard.\",action:\"paste_from_selection\"", "title:\"Previous Search Result\",description:\"Navigate to the previous search result, if any.\",action:\"navigate_search:previous\"", @@ -2170,6 +2254,40 @@ "false" ] }, + { + "key": "vt-window-resize-allowed", + "zigType": "bool", + "kind": "bool", + "doc": "If true, allows the running program to resize the window using the\nxterm `CSI 8 ; rows ; columns t` escape sequence. If a parameter is zero\nor omitted, the current size of that dimension is kept. Sizes smaller\nthan 40 columns by 10 rows are raised to that size so that a program\ncan't shrink the window to hide its output.\n\nThe request is ignored if the terminal is in a split, in a window with\nmultiple tabs, or the quick terminal, or if the window manager controls\nthe window size, such as when it is fullscreen, maximized, or tiled.\nSizes larger than the screen are clamped to the screen.\n\nThis is disabled by default because it lets any program, including one\nrunning on a remote machine, change the size of your window.\n\nAvailable since: 1.4.0", + "defaults": [ + "false" + ] + }, + { + "key": "vt-xt-checksum-report", + "zigType": "bool", + "kind": "bool", + "doc": "Enables or disables checksum reporting (DECRQCRA, `CSI Pi ; Pg ; Pt ;\nPl ; Pb ; Pr * y`). This escape sequence allows the running program to\nask for a checksum of an area of the screen. Terminal test suites use it\nto check what is on the screen.\n\nThis is disabled by default because a program can ask for the checksum of\none cell at a time and so read back everything on the screen, including\nthe output of other programs.\n\nWhile this is disabled, XTCHECKSUM (`CSI Ps # y`), which changes how the\nchecksum is calculated, is ignored as well.\n\nAvailable since: 1.4.0", + "defaults": [ + "false" + ] + }, + { + "key": "vt-xt-checksum-extension", + "zigType": "XtChecksumExtension", + "kind": "flags", + "flags": [ + "negate", + "attributes", + "trim", + "undrawn", + "full" + ], + "doc": "How the checksum reported for DECRQCRA (see `vt-xt-checksum-report`) is\ncalculated. This is the calculation used after a reset, like xterm's\n`checksumExtension` resource. A running program can change it with\nXTCHECKSUM (`CSI Ps # y`) until the next reset. The default is the\ncalculation of a real DEC terminal.\n\nValid values are:\n\n * `negate` - Report the negated sum, as DEC terminals do.\n\n * `attributes` - Add bold, underline, blink, inverse, invisible, and\n protected attributes to the value of each cell.\n\n * `trim` - Omit plain spaces other than the first cell of the area.\n\n * `undrawn` - Count cells that were never written to as spaces\n instead of skipping them.\n\n * `full` - Use the full codepoint of each cell instead of the DEC\n 8-bit value.\n\nPrefix a value with `no-` to disable it. For example, esctest expects\n`no-negate,no-attributes,no-trim,full` when run with `--xterm-checksum`,\nwhich is xterm's `checksumExtension: 23`.\n\nThe bits of xterm's resource are described in its\n[man page](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411/xterm.man#L2870-L2896)\nand its [control sequence documentation](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411/ctlseqs.ms#L2562-L2569),\nbut where those disagree with xterm's\n[implementation](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411/screen.c#L3162-L3290),\nGhostty follows the implementation. The documentation describes bit 3\nas omitting cells that were never written to, but xterm skips those\ncells by default and counts them as spaces with the bit set, which is\n`undrawn` here. It also lists a bit 5 that xterm doesn't implement.\n\nAvailable since: 1.4.0", + "defaults": [ + "negate,attributes,trim,no-undrawn,no-full" + ] + }, { "key": "custom-shader", "zigType": "RepeatablePath", @@ -2543,6 +2661,15 @@ "top" ] }, + { + "key": "gtk-tabs-inverted", + "zigType": "bool", + "kind": "bool", + "doc": "If true, the close button of each tab is shown at the start of the tab\n(the left, in left-to-right languages) and the tab's icon at the end.\nThis applies to both the tab bar and the tab overview. GTK only.\n\nAvailable since: 1.4.0", + "defaults": [ + "false" + ] + }, { "key": "gtk-titlebar-hide-when-maximized", "zigType": "bool", @@ -2588,6 +2715,15 @@ "true" ] }, + { + "key": "gtk-horizontal-tab-scroll", + "zigType": "bool", + "kind": "bool", + "doc": "If `true` (default), then two-finger horizontal scrolling on a touchpad\nwill switch between tabs. Scrolling left goes to the next tab and\nscrolling right goes to the previous tab. Set this to `false` to\ndisable this behavior.\n\nAvailable since 1.4.0.", + "defaults": [ + "true" + ] + }, { "key": "gtk-custom-css", "zigType": "RepeatablePath", @@ -2707,5 +2843,67 @@ "doc": "The size of the quick terminal.\n\nThe size can be specified either as a percentage of the screen dimensions\n(height/width), or as an absolute size in pixels. Percentage values are\nsuffixed with `%` (e.g. `20%`) while pixel values are suffixed with `px`\n(e.g. `300px`). A bare value without a suffix is a config error.\n\nWhen only one size is specified, the size parameter affects the size of\nthe quick terminal on its *primary axis*, which depends on its position:\nheight for quick terminals placed on the top or bottom, and width for left\nor right. The primary axis of a centered quick terminal depends on the\nmonitor's orientation: height when on a landscape monitor, and width when\non a portrait monitor.\n\nThe *secondary axis* would be maximized for non-center positioned\nquick terminals unless another size parameter is specified, separated\nfrom the first by a comma (`,`). Percentage and pixel sizes can be mixed\ntogether: for instance, a size of `50%,500px` for a top-positioned quick\nterminal would be half a screen tall, and 500 pixels wide.\n\nAvailable since: 1.2.0", "notListed": true } + ], + "compat": [ + { + "key": "background-blur-radius", + "renamedTo": "background-blur" + }, + { + "key": "adw-toolbar-style", + "renamedTo": "gtk-toolbar-style" + }, + { + "key": "gtk-tabs-location", + "values": [ + "hidden" + ], + "sets": [ + "window-show-tab-bar" + ] + }, + { + "key": "cursor-invert-fg-bg", + "sets": [ + "cursor-color", + "cursor-text" + ] + }, + { + "key": "selection-invert-fg-bg", + "sets": [ + "selection-foreground", + "selection-background" + ] + }, + { + "key": "bold-is-bright", + "sets": [ + "bold-color" + ] + }, + { + "key": "gtk-single-instance", + "values": [ + "desktop" + ] + }, + { + "key": "macos-dock-drop-behavior", + "values": [ + "window" + ] + }, + { + "key": "scrollback-limit", + "renamedTo": "scrollback-limit-bytes" + }, + { + "key": "copy-on-select", + "values": [ + "true", + "false" + ] + } ] } diff --git a/internal/schema/schema_test.go b/internal/schema/schema_test.go index 4d1d882..c2251b4 100644 --- a/internal/schema/schema_test.go +++ b/internal/schema/schema_test.go @@ -113,6 +113,60 @@ func TestValidate(t *testing.T) { } } +// Types and compatibility entries that arrived with Ghostty 1.4. +func TestGhostty14Options(t *testing.T) { + s, err := Embedded() + if err != nil { + t.Fatal(err) + } + cases := []struct { + key, value string + ok bool + }{ + {"scrollback-limit-lines", "unlimited", true}, + {"scrollback-limit-bytes", "100000000", true}, + {"scrollback-limit-bytes", "-1", false}, + {"clipboard-write-limit-bytes", "lots", false}, + {"window-padding-balance", "equal", true}, + {"window-padding-balance", "maybe", false}, + {"copy-on-select", "both", true}, + {"copy-on-select", "true", true}, // old value, still read + {"copy-on-select", "yes", false}, + {"gtk-single-instance", "desktop", true}, + } + for _, c := range cases { + o := s.Lookup(c.key) + if o == nil { + t.Fatalf("%s missing", c.key) + } + if err := o.Validate(c.value); (err == nil) != c.ok { + t.Errorf("%s = %q: err = %v, want ok=%v", c.key, c.value, err, c.ok) + } + } + if !s.Lookup("copy-on-select").IsOldValue("true") || s.Lookup("copy-on-select").IsOldValue("both") { + t.Error("copy-on-select: old values wrong") + } + + if c := s.OldKey("scrollback-limit"); c == nil || c.RenamedTo != "scrollback-limit-bytes" { + t.Errorf("OldKey(scrollback-limit) = %+v", c) + } + if c := s.OldKey("bold-is-bright"); c == nil || c.RenamedTo != "" || len(c.Sets) != 1 || c.Sets[0] != "bold-color" { + t.Errorf("OldKey(bold-is-bright) = %+v", c) + } + if s.OldKey("copy-on-select") != nil { + t.Error("a current option is not an old key") + } + if got := s.OldNames("scrollback-limit-bytes"); len(got) != 1 || got[0] != "scrollback-limit" { + t.Errorf("OldNames(scrollback-limit-bytes) = %v", got) + } + + // Refreshing from the installed Ghostty keeps the old values. + s.Refresh("# Copy\ncopy-on-select = none\n", "1.4.0") + if !s.Lookup("copy-on-select").IsOldValue("false") { + t.Error("old values lost on refresh") + } +} + func TestFlags(t *testing.T) { o := &Option{Kind: KindFlags, Flags: []string{"cursor", "sudo", "title"}, Defaults: []string{"cursor,no-sudo,title"}} st := o.ParseFlags("no-cursor") diff --git a/internal/schema/validate.go b/internal/schema/validate.go index 63e6a17..566d1d5 100644 --- a/internal/schema/validate.go +++ b/internal/schema/validate.go @@ -35,6 +35,9 @@ func (o *Option) Validate(raw string) error { // An empty value resets the option to its default; always allowed. return nil } + if contains(o.OldValues, v) { + return nil + } switch o.Kind { case KindBool: if v != "true" && v != "false" { @@ -47,6 +50,9 @@ func (o *Option) Validate(raw string) error { case KindFlags: return o.validateFlags(v) case KindInt: + if contains(o.Values, v) { // e.g. "unlimited" + return nil + } n, err := strconv.ParseInt(v, 10, 64) if err != nil { return errors.New("expected a whole number") diff --git a/internal/ui/app.go b/internal/ui/app.go index be5bf60..3d91d83 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -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) diff --git a/internal/ui/app_test.go b/internal/ui/app_test.go index 97d64c5..93d6029 100644 --- a/internal/ui/app_test.go +++ b/internal/ui/app_test.go @@ -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") + } +} diff --git a/internal/ui/view.go b/internal/ui/view.go index 0b2c55e..6d15a39 100644 --- a/internal/ui/view.go +++ b/internal/ui/view.go @@ -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") diff --git a/tools/genschema/main.go b/tools/genschema/main.go index ce8a913..ce5d799 100644 --- a/tools/genschema/main.go +++ b/tools/genschema/main.go @@ -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 { diff --git a/tools/genschema/main_test.go b/tools/genschema/main_test.go new file mode 100644 index 0000000..a22bddb --- /dev/null +++ b/tools/genschema/main_test.go @@ -0,0 +1,66 @@ +package main + +import ( + "slices" + "testing" +) + +// The shape of the compatibility table and its handlers in Config.zig 1.4. +const compatZig = `pub const compatibility = std.StaticStringMap( + cli.CompatibilityHandler(Config), +).initComptime(&.{ + // Ghostty 1.4 renamed ` + "`scrollback-limit`" + `. + .{ "scrollback-limit", cli.compatibilityRenamed(Config, "scrollback-limit-bytes") }, + .{ "bold-is-bright", compatBoldIsBright }, + .{ "copy-on-select", compatCopyOnSelect }, +}); + +fn compatBoldIsBright( + self: *Config, + value_: ?[]const u8, +) bool { + const isset = cli.args.parseBool(value_ orelse "t") catch return false; + if (isset) { + self.@"bold-color" = .bright; + } + return true; +} + +fn compatCopyOnSelect( + self: *Config, + value: ?[]const u8, +) bool { + if (std.mem.eql(u8, value orelse "", "true")) { + self.@"copy-on-select" = .clipboard; + return true; + } + if (std.mem.eql(u8, value orelse "", "false")) { + self.@"copy-on-select" = .none; + return true; + } + return false; +} +` + +func TestParseCompat(t *testing.T) { + got := parseCompat(compatZig) + if len(got) != 3 { + t.Fatalf("%d entries, want 3: %+v", len(got), got) + } + if c := got[0]; c.Key != "scrollback-limit" || c.RenamedTo != "scrollback-limit-bytes" { + t.Errorf("renamed: %+v", c) + } + if c := got[1]; c.Key != "bold-is-bright" || !slices.Equal(c.Sets, []string{"bold-color"}) || len(c.Values) != 0 { + t.Errorf("replaced: %+v", c) + } + if c := got[2]; !slices.Equal(c.Values, []string{"true", "false"}) || len(c.Sets) != 0 { + t.Errorf("old values: %+v", c) + } +} + +func TestLimitType(t *testing.T) { + o := optionForType("Limit(usize, 64 * 1024 * 1024)", nil) + if o.Kind != "int" || !slices.Equal(o.Values, []string{"unlimited"}) || o.Min == nil || *o.Min != 0 { + t.Errorf("Limit: %+v", o) + } +} diff --git a/version.go b/version.go index b6776c1..df70cbb 100644 --- a/version.go +++ b/version.go @@ -3,4 +3,4 @@ package main // Version is a var, not a const, so build.sh can put the built number in via // -ldflags "-X main.Version=…". The value here only ever shows up in a bare // `go build`; the version actually built is the one in version.txt. -var Version = "1.0.1" +var Version = "1.0.2" diff --git a/version.txt b/version.txt index 7dea76e..6d7de6e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.1 +1.0.2