Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ghostty #2

Closed
wants to merge 181 commits into from
Closed

update ghostty #2

wants to merge 181 commits into from

Conversation

rockorager
Copy link

  • Fix backslash comment in ghostty.h
  • gtk: hide titlebar if fullscreened
  • terminal: keep track of colon vs semicolon state in CSI params
  • Preserve full URL when pasting from clipboard
  • fix(window): ensure last_tab action on linux navigates to last tab
  • apprt/gtk: add toggle_maximize keybind and window-maximize config option
  • chore: rename config value to maximize and move startup logic to proper location
  • gtk: add config entry to hide titlebar when the window is maximized
  • fix(PageList): when cloning, explicitly set cols
  • Metal: blend in Display P3 color space, add option for linear blending
  • config: remove experimental linear and merge into text-blending
  • fix: Ensure file paths derived from pasteboard operations are properly escaped
  • gtk(wayland): implement server-side decorations
  • fix: building on systems with older adwaita
  • config: fix window-decoration enum parsing to allow client, none
  • fix(macos): prevent transparency leakage/flash in new/resized surfaces
  • fix(Metal): handle non-extended padding color transparency
  • gtk(wayland): respect compositor SSD preferences
  • bash: less intrusive automatic shell integration
  • bash: remove sed dependency for history processing
  • bash: improve prior_trap processing
  • macos: respect the "auto" window decoration setting
  • fix(Metal): fix incorrect premultiplication of colors
  • bash: revert automatic shell integration changes
  • deps: Update iTerm2 color schemes
  • termio: revise macOS-specific .hushlogin note
  • chore: update stb_image.h
  • gtk: don't toggle headerbar on (un)maximize while using SSDs
  • gtk: always set the title on the underlying window when using adwaita
  • Fix typo in binding comments
  • fix(wuffs): don't premul alpha when loading images
  • fix(flatpak): construct null-terminated array for arguments
  • Fix shell-integration-features being ignored when shell-integration is none
  • Add tests for setup shell integration features
  • Update the documentation to better explain that shell-integration-features
  • Ensure setup_features runs even when shell detection fails
  • Manually call orderOut on terminal close alert
  • Set alert to nil when modal interacted with
  • add and use flag for selecting empty lines in the selectLine function
  • use whitespace instead of new flag for selecting full line
  • render consecutive shaders to the fbo
  • fix: quick terminal hidden by macos menu bar
  • added exec permission back to dolphin action
  • fix(gtk): confirm tab close on close_tab action
  • unigen: Remove libc dependency, use ArenaAllocator
  • fix(renderer): clip terminal contents to expected grid size (Renderers (Metal and OpenGL) should clip terminal if terminal grid size mismatches physical window ghostty-org/ghostty#4523)
  • apprt/gtk: fundamentally rework input method handling
  • Switch default key bindings to include on and offscreen contents
  • apprt/gtk: ibus activation should not encode keys
  • apprt/gtk: when text is committed, end the preedit state
  • use main buffer and copy data to fbo texture (opengl) (use main buffer and copy data to fbo texture (opengl) ghostty-org/ghostty#5294)
  • macOS: prevent native window drag by top region when titlebar hidden
  • cli: allow renaming config fields to maintain backwards compatibility
  • fix: gtk titlebar being restored if it shouldn't be
  • fix: also respect gtk-titlebar value in fullscreened callback
  • apprt/gtk: we should only show the headerbar again if csd
  • gtk: request initial color scheme asynchronously
  • config: rename adw-toasts to app-notifications
  • nix: vms for testing ghostty
  • nix: fix dark mode setting
  • nix: disable geary
  • nix vm: more slimming
  • nix vm: maybe get vms working on darwin
  • nix vm: add documentation, add Gnome/X11 VM
  • fix typo
  • nix vm: add plasma and cinnamon vms
  • nix vm: simplify vm definition
  • nix vm: try and make vm creation more re-usable
  • nix vm: more reusability
  • nix vm: +fish +zsh -zig
  • nix: document how to create custom vms
  • nix: add x11 xfce vm
  • documentation: consistent format for actions help
  • docs: generate mdx file for cli actions
  • build: options to enable/disable terminfo & termcap install
  • Fix sudo fish shell integration
  • bash: handle additional command arguments
  • Prevent hyperlink hover state when mouse is outside viewport
  • fix(Metal): always render explicit background colors fully opaque
  • Revert "build: options to enable/disable terminfo & termcap install"
  • Prevent fd leaks to the running shell or command
  • termio/exec: if pty fd HUP, end read thread
  • Update libxev to fix zombie processes on macOS
  • build: options to enable/disable terminfo & termcap install (take 2)
  • only the cp step needs to depend on the mkdir step
  • fix missing check of emit_termcap build option
  • Ignore SIGPIPE
  • macos: autohide dock if quick terminal would conflict with it
  • Add chorded/sequenced keybinds to +list-keybinds output
  • Docs: improve doc structure for action bindings with args and examples
  • Docs: remove type from action arguments
  • macos: hide dock globally if the dock conflicts
  • fix(renderer/Metal): properly load cursor color
  • renderer/Metal: improve linear blending correction
  • cleanup: rename text-blending to alpha-blending
  • Fix older adwaita tab bars at top of window
  • Fix cmd+triple click not selecting full output
  • Change ifs to exhaustive switches
  • Remove if check that was left in after change to exhaustive switch
  • apprt/gtk: set key modifier flag if physical modifier key is pressed
  • macOS: add link to release notes on appcast
  • input: performable bindings aren't part of the reverse mapping
  • dist: remove cdata tags from appcast, we escape it all
  • ci: separate publish and release workflows
  • next version will be 1.1.0
  • nix: use --system build flag instead of relying on $ZIG_GLOBAL_CACHE_DIR
  • nix: fix Ghostty homepage in package
  • gtk(x11): update blur region upon syncAppearance
  • ci: update publish job
  • update version for development
  • Fix a typo in the docs for adjust-strikethrough-position and adjust-overline-position
  • fix errno handle
  • comment on why to not use posix.errno
  • deps: Update iTerm2 color schemes
  • linux: fix installation path of nautilus-python extension
  • gtk(wayland): respect window-decoration=none on GNOME
  • apprt/gtk: handle input methods that end preedit before commit
  • gtk(x11): support server-side decorations
  • config: mention X11 support in window-decoration docs
  • core: add explicit errors to src/pty.zig
  • core: fix up pty Zig error sets
  • core: add explicit errors to src/os/env.zig
  • core: handle src/os/env.zig errors on windows
  • core: fix puralization of src/os/env.zig Errors->Error
  • macOS: binding checks should never trigger preedit callbacks
  • linux: ensure that group dir fd is closed
  • Toggling visibility is now ignored when in fullscreen mode.
  • gtk: remove CSD styling when CSDs aren't used
  • Add a final newline to "No crash reports!"
  • Fix cursor character not visible when cursor color matches background
  • macos: update Sparkle to 2.6.4 to workaround security issue
  • Introduce subsystem maintainers via CODEOWNERS
  • Metal: use "Managed" resource storage mode on discrete GPUs
  • GTK: disable color management
  • move color-mgmt to config
  • expand comment + rename
  • remove config
  • add comments
  • update gtk version
  • fix(Metal): don't throw away glyphs when the fg and bg colors match
  • gtk: introduce Zig bindings for GTK/GObject
  • core: protect against crashes and hangs when themes are not files
  • fix(terminal): handle errors in Screen.adjustCapacity
  • fix(terminal): properly invalidate over-sized OSCs
  • test(terminal/osc): fix command longer than buffer test
  • test(terminal/screen): OOM handling in adjustCapacity
  • fix(terminal): properly lookup hyperlinks when cloning rows across pages
  • test(terminal/screen): cursorSetHyperlink OOM handling edge case
  • nix: use zig2nix to manage nix cache/deps
  • macos: toggle_visibility fullscreen check requires active app
  • macos: ensure previously key window regains key on toggle_visibility
  • fix(terminal): avoid Screen.reset causing use of undefined
  • Add keyboard navigation for Terminal IO window
  • Remember last focused window position for next startup
  • Add default documentation for undocumented keybind actions
  • Ensure last action's documentation is properly generated
  • Improve list-actions command documentation formatting
  • Extract keybind actions help generation into a dedicated module
  • Fix confirm-close-surface not working for hidden quick terminal
  • Revert "Fixed documentation generation in list-actions --docs command (Fixed documentation generation in list-actions --docs command ghostty-org/ghostty#4974)"
  • gtk(x11): set WINDOWID env var for subprocesses
  • macos: add a variety of artist-drawn alternate icons
  • Refactor keybinding actions reference generation
  • core: performAction now returns a bool
  • gtk: make goto_split a performable action
  • gtk: make previous_tab, next_tab, last_tab, and goto_tab performable
  • apprt/embedded: make performAction return the performable state
  • apprt/gtk: some stylistic changes
  • apprt/glfw: return false for unimplemented actions
  • gtk: Point right-click context menu exactly at cursor to improve behaviour at edges and closeness to cursor
  • Revert "gtk: Point right-click context menu exactly at cursor to improve behaviour at edges and closeness to cursor"
  • gtk: fix context menu computed location
  • macOS: fix iOS build breakage from Performable tab and split navigation ghostty-org/ghostty#5644
  • macOS: use Nix to get Zig deps
  • termio: free envmap when able, fix memory leak
  • gtk: use the standard path for including Adwaita header file
  • terminal: reflow the saved cursor if we have one

gabydd and others added 30 commits January 13, 2025 02:02
Fixes ghostty-org#5022

The CSI SGR sequence (CSI m) is unique in that its the only CSI sequence
that allows colons as delimiters between some parameters, and the colon
vs. semicolon changes the semantics of the parameters.

Previously, Ghostty assumed that an SGR sequence was either all colons
or all semicolons, and would change its behavior based on the first
delimiter it encountered.

This is incorrect. It is perfectly valid for an SGR sequence to have
both colons and semicolons as delimiters. For example, Kakoune sends
the following:

    ;4:3;38;2;175;175;215;58:2::190:80:70m

This is equivalent to:

  - unset (0)
  - curly underline (4:3)
  - foreground color (38;2;175;175;215)
  - underline color (58:2::190:80:70)

This commit changes the behavior of Ghostty to track the delimiter per
parameter, rather than per sequence. It also updates the SGR parser to
be more robust and handle the various edge cases that can occur. Tests
were added for the new cases.
Previously, the logic navigated to the second-to-last tab instead of the
last tab due to an off-by-one error. This updates the implementation so
that the index calculation to accurately target the last tab.
In the `gotoLastTab` method there was a decrement in the number of max
number of tabs and another increment in the `goToTab` method to get the
actual tab index.
Fixes ghostty-org#3381

Note that ghostty-org#4936 will need to be merged or you'll need to rely on Gnome's
default keybinding for unmaximizing a window (super+down).
Otherwise pages may have the wrong width if they were resized down with
a fast path that just chanes the size without adjusting capacity at all.
This commit is quite large because it's fairly interconnected and can't
be split up in a logical way. The main part of this commit is that alpha
blending is now always done in the Display P3 color space, and depending
on the configured `window-colorspace` colors will be converted from sRGB
or assumed to already be Display P3 colors. In addition, a config option
`text-blending` has been added which allows the user to configure linear
blending (AKA "gamma correction"). Linear alpha blending also applies to
images and makes custom shaders receive linear colors rather than sRGB.

In addition, an experimental option has been added which corrects linear
blending's tendency to make dark text look too thin and bright text look
too thick. Essentially it's a correction curve on the alpha channel that
depends on the luminance of the glyph being drawn.
By using the `CAMetalLayer`'s `backgroundColor` property instead of
drawing the background color in our shader, it is always stretched to
cover the full surface, even when live-resizing, and it doesn't require
us to draw a frame for it to be initialized so there's no transparent
flash when a new surface is created (as in a new split/tab).

This commit also allows for hot reload of `background-opacity`,
`window-vsync`, and `window-colorspace`.
We were returning bg colors when we shouldn't have since when we have
background color transparency we need to return any bg color cells as
fully transparent rather than their actual color.
Compositors can actually tell us whether they want to use CSD or SSD!
We now use a temporary function (__ghostty_bash_startup) to perform the
bash startup sequence. This gives us a local function scope in which to
store some temporary values (like rcfile). This way, they won't leak
into the sourced files' scopes.

Also, use `~/` instead of `$HOME` for home directory paths as a simpler
shorthand notation.
We post-process history 1's output to extract the current command. This
processing needs to strip the leading history number, an optional *
character indicating whether the entry was modified (or a space), and
then a space separating character.

We were previously using sed(1) for this, but we can implement an
equivalent transformation using bash's native parameter expansion
syntax.

This also results in ~4x reduction in per-prompt command overhead.
We use `trap` to bootstrap our installation function (__bp_install). We
remove our code upon first execution but need to restore any preexisting
trap calls. We previously used `sed` to process the trap string, but
that had two downsides:

1. `sed` is an external command dependency. It needs to exist on the
    system, and we need to invoke it in a subshell (which has some
    runtime cost).
2. The regular expression pattern was imperfect and didn't handle
    trickier cases like `'` characters in the trap string:

        $ (trap "echo 'hello'" DEBUG; trap -p DEBUG)
        hello
        trap -- 'echo '\''hello'\''' DEBUG

This change removes the dependency on `sed` by locally evaluating the
trap string and extracting any prior trap. This works reliably because
we control the format our trap string, which looks like this (with
newlines expanded):

    __bp_trap_string="$(trap -p DEBUG)"
    trap - DEBUG
    __bp_install
Also make sure to divide alpha out before applying gamma encoding back
to text color when not using linear blending.
The intention of ghostty-org#5075 was to create a less intrusive, more hermetic
environment in which to source the bash startup files. This caused
problems for multiple people, and I believe that's because the general
expectation is that these files are sourced at global (not function)
scope.

For example, when a file is sourced from within a function scope, any
variables that weren't explicitly exported into the global environment
won't be available outside of the scope of the function. Most system and
personal startup files aren't written with that constraint because it's
not how bash itself loads these files.

As a small improvement over the original code, `rcfile` has been renamed
to `__ghostty_rcfile`. Avoiding leaking this variable while sourcing
these files was a goal of ghostty-org#5075, and prefixing it make it much less of a
potential issue.

This change also reverts the $HOME to ~/ change. While the ~/ notation
is more concise, using $HOME is more common and easier to implement
safely with regard to quoting.
login(1)'s .hushlogin logic was "fixed" in macOS Sonoma 14.4, so this
comment (and our workaround) is only relevant for versions earlier than
that.

The relevant change to login/login.c is part of system_cmds-979.100.8.

> login.c: look for .hushlogin in home directory (112854361)

- apple-oss-distributions/system_cmds@1bca46e
- https://github.com/apple-oss-distributions/distribution-macOS/tree/macos-144
mitchellh and others added 27 commits February 12, 2025 16:16
Fixes ghostty-org#5690

When we hide the app and then show it again, the previously key window
is lost. This is because we are not using unhide and are manually
doing it (and we're not using unhide for good reasons commented in the
source already).

Modify our hidden state to include what the key window was (as a weak
ref) and restore it when we show the app again.
Fully reset the kitty image storage instead of using the delete handler,
previously this caused a memory corruption / likely segfault due to use
of undefined, since the delete handler tries to clear the tracked pins
for placements, which it gets from the terminal, for which `undefined`
was passed in before.
- Add J/K and arrow keys navigation in Terminal IO window
Previously, `ghostty +list-actions` would only show actions that had doc
comments, making it difficult for users to discover all available actions.
This change ensures all actions are listed with appropriate documentation.

For actions without doc comments, we now generate a default message
encouraging contribution.
The issue was caused by the documentation generation logic not writing the final buffered content.
This commit fixes two issues with the `list-actions` command:

1. Ensures all actions are listed, including those without individual
   documentation but sharing docs with related actions
2. Improves documentation formatting with proper indentation and grouping
`WINDOWID` is the conventional environment variable for scripts that
want to know the X11 window ID of the terminal, so that it may call
tools like `xprop` or `xdotool`. We already know the window ID for
window protocol handling, so we might as well throw this in for
convenience.
This is just a fun change to add a bunch of alternate icons. We don't
want to add too many since this increases the final bundle size but we
also want to have some fun. :)
This is to facilitate the `performable:` prefix on keybinds that are
implemented using app runtime actions.
…ove behaviour at edges and closeness to cursor"

This reverts commit bf5351e.
Caused by ghostty-org#5650

I actually don't understand how this didn't happen before or why we
didn't notice it but it seems like the envmap was never freed. In the
latest debug builds prior to this build GPA reports the leak.

We should free the envmap when the subprocess is deinitialized. But also
we can free the env map as soon as we start the subprocess which saves
some small amount of memory at runtime.

Additionally, we should only be freeing the envmap on error if we
created it.
As pointed out by @tristan957 the standard path for including the
Adwaita header file is simply "adwaita.h". While it may have been
necessary in the past to use a non-standard include path, that no longer
appears to be the case.
Fixes ghostty-org#5718

When a terminal is resized with text reflow (i.e. soft-wrapped text), the cursor
is generally reflowed with it.

For example, imagine a terminal window 5-columns wide and you type the
following without pressing enter. The cursor is on the X.

```
OOOOO
OOX
```

If you resize the window now to 8 or more columns, this happens, as expected:

```
OOOOOOOX
```

As expected, the cursor remains on the "X". This behaves like any other text
input...

Terminals also provide an escape sequence to
[save the cursor (ESC 7 aka DECSC)](https://ghostty.org/docs/vt/esc/decsc).
This includes, amongst other things, the cursor position. The cursor can be
restored with [DECRC](https://ghostty.org/docs/vt/esc/decrc).

The behavior of the position of the _saved cursor_ in the context of text
reflow is unspecified and varies wildly between terminals Ghostty does this
right now (as do many other terminals):

```
OOOOOOOO
   X
```

This commit changes the behavior so that we reflow the saved cursor.
@gabydd
Copy link
Owner

gabydd commented Feb 13, 2025

thanks, did this with a rebase instead

@gabydd gabydd closed this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.