summaryrefslogtreecommitdiff
path: root/src/Surface.zig
AgeCommit message (Collapse)Author
2025-10-10Set title as argv[0] for commands specified with `-e` (#9121)Bruno BELANYI
I want to see #7932 get merged, so applied the latest proposed patch. Will close if the original PR gets some traction, as I do _not_ know Zig nor this project. Co-authored-by: rhodes-b <59537185+rhodes-b@users.noreply.github.com>
2025-10-04input: use std.Io.Writer for key encoder, new API, expose via libghosttyMitchell Hashimoto
This modernizes `KeyEncoder` to a new `std.Io.Writer`-based API. Additionally, instead of a single struct, it is now an `encode` function that takes a series of more focused options. This is more idiomatic Zig while also making it easier to expose via libghostty-vt. libghostty-vt also gains access to key encoding APIs.
2025-10-04Move paste encoding to the input package, test, optimize away one allocMitchell Hashimoto
This moves our paste logic to `src/input` in preparation for exposing this as part of libghostty-vt. This yields an immediate benefit of unit tests for paste encoding. Additionally, we were able to remove one allocation on every unbracketed paste path unless the input specifically contains a newline. Unlikely to be noticable, but nice. NOTE: This also includes one change in behavior: we no longer encode `\r\n` and a single `\r`, but as a duplicate `\r\r`. This matches xterm behavior and I don't think will result in any issues since duplicate carriage returns should do nothing in well-behaved terminals.
2025-10-03flush output for our builddata executableMitchell Hashimoto
Fixes #9018 We were truncated our terminfo causing tmux to not respect some features.
2025-10-03fix up merge conflictsMitchell Hashimoto
2025-10-03Zig 0.15: zig build GTK exeMitchell Hashimoto
2025-10-02address review commentsJeffrey C. Ollie
2025-10-02core: add 'command finished' notificationsJeffrey C. Ollie
Fixes #8991 Uses OSC 133 esc sequences to keep track of how long commands take to execute. If the user chooses, commands that take longer than a user specified limit will trigger a notification. The user can choose between a bell notification or a desktop notification.
2025-09-29feat: enable separate scaling for precision and discrete mouse scrollingToufiq Shishir
2025-09-16selection scrolling should only depend on y valueMitchell Hashimoto
Fixes #8683 The selection scrolling logic should only depend on the y value of the cursor position, not the x value. This presents unwanted scroll behaviors, such as reversing the scroll direction which was just a side effect of attempting to scroll tick to begin with.
2025-09-16font-size reloads at runtime if the font wasn't manually setMitchell Hashimoto
This was a very common pitfall for users. The new logic will reload the font-size at runtime, but only if the font wasn't manually set by the user using actions such as `increase_font_size`, `decrease_font_size`, or `set_font_size`. The `reset_font_size` action will reset our state to assume the font-size wasn't manually set. I also updated a comment about `font-family` not reloading at runtime; this wasn't true even prior to this commit.
2025-09-11terminal: update parser to use new color parser and stream handlerMitchell Hashimoto
2025-09-02feat: add `selection-clear-on-copy` configurationToufiq Shishir
2025-09-02macOS: firstRect should return full rect width/heightMitchell Hashimoto
Fixes #2473 This commit changes `ghostty_surface_ime_point` to return a full rect with the width/height calculated for the preedit. The `firstRect` function, which calls `ghostty_surface_ime_point` was previously setting the width/height to zero. macOS didn't like this. We then changed it to just hardcode it to width/height of one cell. This worked but made it so the IME cursor didn't follow the preedit.
2025-08-26surface: store entire scroll-to-bottom structJeffrey C. Ollie
2025-08-26surface: implement scroll-to-bottom=keystrokeJeffrey C. Ollie
2025-08-26scroll: round up fractional mouse scroll ticksJohn Drouhard
Scrolling with a mouse on macos doesn't work very well when doing small, single tick scrolls. macos attempts to mimic precision scrolling by changing the magnitude of the scroll deltas based on scrolling speed. Slow scrolls only send deltas with a magnitude of 0.1, which isn't enough to send a single scroll event with the default scroll multiplier of 3. Changing the scroll multiplier to 10 as a workaround (so even single small scroll ticks are enough to register a scroll event) cause scrolling to be way too fast if the scroll speed is ramped up. This commit causes the yoffset delta to be rounded out to at least a magnitude of 1 in the appropriate direction. For small single scroll ticks, it's enough to register a scroll event, but as scroll speed is ramped up, the true delta reported to the surface is used again. Setting a scroll multiplier of 1 with the changes here makes mouse scrolling feel just as good as trackpad precision scrolling.
2025-08-25parameterize close_tabJeffrey C. Ollie
- Add mode (`this`/`other`) parameter to `close_tab` keybind/apprt action. - Keybinds will default to `this` if not specified, eliminating backward compatibility issues (`keybind=x=close_tab` === `keybind=x=close_tab:this`). - Remove `close_other_tabs` keybind and apprt action.
2025-08-24Close other tabs feature on Mac.jamylak
Supporting command line, file menu and keybindings. Default mac shortcut of `super + alt + o` (other) Not able to test on Linux so excluding `close_other_tabs` from `gtk` for now make a default short cut for close other tabs
2025-08-22core: avoid possible deadlock in right-click-action paste actionsMitchell Hashimoto
Fixes #8313 The clipboard request flow can result in the apprt immediately completing the request which itself grabs a lock. For pastes, we should yield the lock during the clipboard request. GTK is always async so this worked there, but we want to be resilient to any apprt behavior here.
2025-08-22removed boolean logic, reverted back to ctrlOrSuper callAlex
2025-08-22Removed boolean logic, reverted back to ctrlOrSuper callAlex
2025-08-22fix: make regular URLs work with either ctrl or super modifiersAlex Straight
2025-08-22fix: copy_url_to_clipboard copies full OSC8 URL instead of single characterAlex Straight
OSC8 links were only detected when exact platform-specific modifiers were held (Cmd on macOS, Ctrl on Linux), but copy_url_to_clipboard should work with either. Additionally, OSC8 links were using selectionString() which gets visible text instead of the actual URI. Now we use osc8URI() for OSC8 links and fall back to selectionString() for regex-detected links. Fixes #7491
2025-08-19macos: show copy menu item if selection start is outside viewportMitchell Hashimoto
Fixes #8187 This properly handles the scenario with our `read_text` C API when the selection start is outside the viewport. Previously we'd report null (no text) which would cascade into things like the right click menu not showing a copy option.
2025-08-19feat: add right-click action configurationLuzian Bieri
2025-08-15refactor: extract clipboard setting logic into `copySelectionToClipboards` ↵Luzian Bieri
function
2025-08-14gtk-ng: add show_on_screen_keyboard bindingLeah Amelia Chen
2025-07-21apprt/gtk-ng: mouse over link to show tooltipMitchell Hashimoto
2025-07-18apprt/gtk-ng: hook up surface initializationMitchell Hashimoto
2025-07-17core/gtk: add support for displaying a progress bar with OSC 9;4Jeffrey C. Ollie
Ghostty has had support for a while (since PR #3124) for parsing progress reports but never did anything with them. This PR adds the core infrastructure and an implementation for GTK. On GTK, the progress bar will show up as a thin bar along the top of the terminal. Under normal circumstances it will use whatever you have set as your accent color. If the progam sending the progress report indicates an error, it will change to a reddish color.
2025-07-17Surface: use rect selection state when setting selection on releaseChris Marchesi
Looks like 52354b8 missed noting the outgoing screen selection state's rectangle flag when setting the selection on mouse release, this was causing the selection that was actually set to be standard/wrap-selected. This corrects that by just shipping said flag when calling setSelection.
2025-07-11show child exited: return a boolean if native GUI is shownJeffrey C. Ollie
If a native GUI is shown by the runtime when a child exits, use the returned boolean to determine if text should be show in the terminal to avoid duplicating information.
2025-07-11core/gtk: add apprt action to show native GUI warning when child exitsJeffrey C. Ollie
Addresses #7649 for the core and GTK. macOS support will need to be added later. This adds an apprt action to show a native GUI warning of some kind when the child process of a terminal exits. Also adds a basic GTK implementation of this. In GTK it overlays an Adwaita banner at the bottom of the window (similar to the banner that shows up in at the top of windows in debug builds).
2025-07-06Fallback to cross-platform minimal open when apprt is not availableMitchell Hashimoto
2025-07-06core/gtk: open urls using an apprt action instead of doing it directlyJeffrey C. Ollie
Partial implementation of #5256 This implements the core changes necessary to open urls using an apprt action rather than doing it directly from the core. Implements the open_url action in the GTK and GLFW apprts. Note that this should not be merged until a macOS-savvy developer can add an implementation of the open_url action for the macOS apprt.
2025-07-06keybind: add copy_title_to_clipboard action (#7833)Jeffrey C. Ollie
Fixes #7829 This will copy the terminal title to the clipboard. If the terminal title is not set or the title is empty the action has no effect.
2025-07-06keybind: don't clobber the clipboard if the title is emptyJeffrey C. Ollie
2025-07-06Add link-previews option (#7831)Mitchell Hashimoto
Implement the `link-previews` option from https://github.com/ghostty-org/ghostty/discussions/7727. The feature request isn't accepted yet, but I had a bit of free time to write this up and it was pretty quick, so I figure there's no harm in proposing an implementation. Demo of `link-previews = osc8`: https://github.com/user-attachments/assets/17a72ab2-c727-4a85-9edd-9b6e7da05d98
2025-07-06keybind: rename copy_title to copy_title_to_clipboardJeffrey C. Ollie
Co-authored-by: Jon Parise <jon@indelible.org>
2025-07-06keybind: add copy_title actionJeffrey C. Ollie
Fixes #7829 This will copy the terminal title to the clipboard. If the terminal title is not set it has no effect.
2025-07-06keybind: add set_font_sizeJeffrey C. Ollie
Fixes #7795 This allows the font size to be set to an absolute value.
2025-07-06Add link-previews optionGregory Anders
2025-07-04On wait-after-command (or abnormal exit), only close on encoded keyMitchell Hashimoto
Fixes #7794 This commit also resets some terminal state to give us a better chance of getting an encoded key, such as ensuring keyboard input is enabled and disabling any Kitty protocols. This shouldn't ever be set but just in case!
2025-07-01Update src/Surface.zigMitchell Hashimoto
Co-authored-by: Gregory Anders <greg@gpanders.com>
2025-07-01Fix abnormal exit detection on macOSMitchell Hashimoto
I made an oopsie with #7705 and omitted the check entirely on macOS when the original logic only omitted the exit code check.
2025-06-30various cleanups around scroll timersMitchell Hashimoto
2025-06-30surface: add timer-based scrolling during selectionmoni-dz
2025-06-29Introduce action for copying into clipboardTroels Thomsen
2025-06-27Move child exit handling logic to apprt threadMitchell Hashimoto
Fixes #7500 Supersedes #7582 This commit moves the child exit handling logic from the IO thead to the apprt thread. The IO thread now only sends a `child_exited` message to the apprt thread with metadata about the exit conditions (exit code, runtime). From there, the apprt thread can handle the exit situation however is necessary. This commit doesn't change the behavior but it does fix the issue #7500. The behavior is: exit immediately, show abnormal exit message, wait for user input, etc. This also gets us closer to #7649.