summaryrefslogtreecommitdiff
path: root/src/input
AgeCommit message (Collapse)Author
2025-10-05lib-vt: expose key encoding as a C APIMitchell Hashimoto
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-03Zig 0.15: zig build test Mitchell Hashimoto
2025-09-25Merge remote-tracking branch 'upstream/main' into jacob/uucodeJacob Sandlund
2025-09-23config: smarter parsing in autoParseStructJeffrey C. Ollie
Fixes #8849 Previously, the `parseAutoStruct` function that was used to parse generic structs for the config simply split the input value on commas without taking into account quoting or escapes. This led to problems because it was impossible to include a comma in the value of config entries that were parsed by `parseAutoStruct`. This is particularly problematic because `ghostty +show-config --default` would produce output like the following: ``` command-palette-entry = title:Focus Split: Next,description:Focus the next split, if any.,action:goto_split:next ``` Because the `description` contains a comma, Ghostty is unable to parse this correctly. The value would be split into four parts: ``` title:Focus Split: Next description:Focus the next split if any. action:goto_split:next ``` Instead of three parts: ``` title:Focus Split: Next description:Focus the next split, if any. action:goto_split:next ``` Because `parseAutoStruct` simply looked for commas to split on, no amount of quoting or escaping would allow that to be parsed correctly. This is fixed by (1) introducing a parser that will split the input to `parseAutoStruct` into fields while taking into account quotes and escaping. And (2) changing the `ghostty +show-config` output to put the values in `command-palette-entry` into quotes so that Ghostty can parse it's own output. `parseAutoStruct` will also now parse double quoted values as a Zig string literal. This makes it easier to embed control codes, whitespace, and commas in values.
2025-09-19pr feedback: `get`, remove todos for case_folding_simpleJacob Sandlund
2025-09-18fix up diff from benchmarks, and add tests against ziglyphJacob Sandlund
2025-09-18update uucode and cleanupsJacob Sandlund
2025-09-17Merge remote-tracking branch 'upstream/main' into jacob/uucodeJacob Sandlund
2025-09-16config: fix binding parsing to allow values containing `=`Mitchell Hashimoto
Fixes #8667 The binding `a=text:=` didn't parse properly. This is a band-aid solution. It works and we have test coverage for it thankfully. Longer term we should move the parser to a fully state-machine based parser that parses the trigger first then the action, to avoid these kind of things.
2025-09-15Docs: add undo-timeout configuration setting namedmunozv04
2025-09-06Merge remote-tracking branch 'upstream/main' into jacob/uucodeJacob Sandlund
2025-09-05gtk: the Future is NowLeah Amelia Chen
2025-09-05gtk: nuke the legacy apprt from orbitLeah Amelia Chen
We don't really have any large outstanding regressions on -ng to warrant keeping this alive anymore. ¡Adiós!
2025-09-01Merge remote-tracking branch 'upstream/main' into jacob/uucodeJacob Sandlund
2025-08-26gtk-ng: implement close_tab:other keybindJeffrey C. Ollie
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-21Merge remote-tracking branch 'upstream/main' into jacob/uucodeJacob Sandlund
2025-08-22gtk-ng: allow XKB remaps for non-writing-system keysLeah Amelia Chen
Compromise solution to #7356 XKB is naughty. It's really really naughty. I don't understand why we didn't just kill XKB with hammers during the Wayland migration and change it for something much better. I don't understand why we're content with what amounts to an OS-level software key remapper that completely jumbles information about original physical key codes in order to fake keyboard layouts, and not just let users who really want to remap keys use some sort of evdev or udev-based mapper program. In a sane system like macOS, the "c" key is always the "c" key, but it's understood to produce the Unicode character "ц" when using a Russian layout. XKB defies sanity, and just pretends that your "c" key is actually a "ц" key instead, and so when you ask for the keybind "Ctrl+C" it just shrugs in apathy (#7309). And so, we took matters into our own hands and interpreted hardware keycodes ourselves. But then, a *lot* of people have the ingrained muscle memory of swapping Escape with Caps Lock so that it is easier to hit. We respect that. In a sane system, they would use a remapper that actually makes the system think you've hit the Escape key when in reality you've hit the Caps Lock key, so in all intents and purposes to the OS and any app developer, these two just have their wires swapped. But not on Linux. Somehow this and the aforementioned case should be treated by the same key transform algorithm, which is completely diabolical. As a result, we have to settle for a compromise that truly satisfies neither party — by allowing XKB remaps for keys that don't really change depending on the layout. The Linux input stack besets all hopes and aspirations.
2025-08-17`array`Jacob Sandlund
2025-08-17Merge remote-tracking branch 'upstream/main' into jacob/uucodeJacob Sandlund
2025-08-14gtk-ng: add show_on_screen_keyboard bindingLeah Amelia Chen
2025-08-13case foldingJacob Sandlund
2025-08-12update after refactor (string field config, etc)Jacob Sandlund
2025-08-04apprt/gtk-ng: global shortcutsMitchell Hashimoto
2025-07-06keybind: don't clobber the clipboard if the title is emptyJeffrey C. Ollie
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-06-29Introduce action for copying into clipboardTroels Thomsen
2025-06-25config: add `command-palette-entry` config optionLeah Amelia Chen
2025-06-21Add FreeBSD support-k
Following https://github.com/cryptocode/ghostty/commit/7aeadb06ee5c38c440ac86b975d713a8ccfa3e0b
2025-06-08macOS: Undo/Redo for changes to windows, tabs, and splits (#7535)Mitchell Hashimoto
This PR implements the ability to undo/redo new and closed windows, tabs, and splits. ## Demo https://github.com/user-attachments/assets/98601810-71b8-4adb-bfa4-bdfaa2526dc6 ## Details ### Undo Timeout Running terminal sessions _remain running_ for a configurable period of time after close, during which time they're undoable. This is similar to "email unsend" (since email in the traditional sense can't be unsent, clients simply hold onto it for a period of time before sending). This behavior is not unique to Ghostty. The first and only place I've seen it is in iTerm2. And iTerm2 behaves similarly, although details of our behavior and our implementation vary greatly. The configurable period of time is done via the `undo-timeout` configuration. The default value is 5 seconds. This feels reasonable to be and is grounded in being the default for iTerm2 as well, so it's probably a safe choice. Undo can be disabled by setting `undo-timeout = 0`. ### Future The actions that can be potentially undone/redone can be easily expanded in the future. Some thoughts on things that make sense to me: - Any sort of split resizing, including equalization - Moving tabs or splits #### What about Linux? I'd love to support this on Linux. I don't think any other terminal on Linux has this kind of feature (definitely might be wrong, but I've never seen it and I've looked at a lot of terminal emulators 😄 ). But there's some work to be done to get there. ## TODO for the Draft PR This is still a draft. There are some items remaining (list will update as I go): - [x] Undoing a closed window is sometimes buggy still and I'm not sure why, I have to dig into this. - [x] New window should be undoable - [x] New tab should be undoable - [x] Close All Windows should be undoable - [x] I think I have to get rid of TerminalManager. Undone windows won't be in TerminalManager's list of controllers and I think that's going to break a lot of things. - [x] I haven't tested this with QuickTerminal at all. I expect bugs there but I want undo to work with splits there. - [x] Close window with the red traffic light button doesn't trigger undo - [x] Closing window with multiple tabs undoes them as separate windows
2025-06-07input: parse binds containing equal signs correctly (#7544)Mitchell Hashimoto
Since the W3C rewrite we're able to specify codepoints like `+` directly in the config format who otherwise have special meanings. Turns out we forgot to do the same for `=`.
2025-06-08input: parse binds containing equal signs correctlyLeah Amelia Chen
Since the W3C rewrite we're able to specify codepoints like `+` directly in the config format who otherwise have special meanings. Turns out we forgot to do the same for `=`.
2025-06-07Make undo/redo app-targeted so it works with no windowsMitchell Hashimoto
2025-06-07add undo/redo keybindings, default them on macOSMitchell Hashimoto
2025-06-05input: add focus split directional commands to command paletteMitchell Hashimoto
2025-06-04core: document keybind actions betterLeah Amelia Chen
The current documentation for actions are very sparse and would leave someone (even including contributors) as to what exactly they do. On top of that there are many stylistic and grammatical problems that are simply no longer in line with our current standards, and certainly not on par with our configuration options reference. Hence, I've taken it upon myself to add, clarify, supplement, edit and even rewrite the documentation for most of these actions, in a wider effort of trying to offer better, clearer documentation for our users.
2025-05-30GTK: add action to show the GTK inspector (#7468)Mitchell Hashimoto
The default keybinds for showing the GTK inspector (`ctrl+shift+i` and `ctrl+shift+d`) don't work reliably in Ghostty due to the way Ghostty handles input. You can show the GTK inspector by setting the environment variable `GTK_DEBUG` to `interactive` before starting Ghostty but that's not always convenient. This adds a keybind action that will show the GTK inspector. Due to API limitations toggling the GTK inspector using the keybind action is impractical because GTK does not provide a convenient API to determine if the GTK inspector is already showing. Thus we limit ourselves to strictly showing the GTK inspector. To close the GTK inspector the user must click the close button on the GTK inspector window. If the GTK inspector window is already visible but is hidden, calling the keybind action will not bring the GTK inspector window to the front.
2025-05-29input: "ignore" binding action are still be processed by the OS/GUIMitchell Hashimoto
Related to #7468 This changes the behavior of "ignore". Previously, Ghostty would consider "ignore" actions consumed but do nothing. They were like a black hole. Now, Ghostty returns `ignored` which lets the apprt forward the event to the OS/GUI. This enables keys that would otherwise be pty-encoded to be processed later, such as for GTK to show the GTK inspector.
2025-05-29GTK: add action to show the GTK inspectorJeffrey C. Ollie
The default keybinds for showing the GTK inspector (`ctrl+shift+i` and `ctrl+shift+d`) don't work reliably in Ghostty due to the way Ghostty handles input. You can show the GTK inspector by setting the environment variable `GTK_DEBUG` to `interactive` before starting Ghostty but that's not always convenient. This adds a keybind action that will show the GTK inspector. Due to API limitations toggling the GTK inspector using the keybind action is impractical because GTK does not provide a convenient API to determine if the GTK inspector is already showing. Thus we limit ourselves to strictly showing the GTK inspector. To close the GTK inspector the user must click the close button on the GTK inspector window. If the GTK inspector window is already visible but is hidden, calling the keybind action will not bring the GTK inspector window to the front.
2025-05-26style: use decl literalsQwerasd
This commit changes a LOT of areas of the code to use decl literals instead of redundantly referring to the type. These changes were mostly driven by some regex searches and then manual adjustment on a case-by-case basis. I almost certainly missed quite a few places where decl literals could be used, but this is a good first step in converting things, and other instances can be addressed when they're discovered. I tested GLFW+Metal and building the framework on macOS and tested a GTK build on Linux, so I'm 99% sure I didn't introduce any syntax errors or other problems with this. (fingers crossed)
2025-05-24add cut/copy/paste keysJörg Thalheim
The origin of these keys are old sun keyboards. They are getting picked up by the custom (progammable) keyboard scene (see https://github.com/manna-harbour/miryoku for a popular layout). Support in ghosty is quite handy because it allows to bind copy/paste in a way that doesn't overlap with ctrl-c/ctrl-v, which can have special bindings in some terminal applications.
2025-05-16gtk: implement command palette (#7167)Leah Amelia Chen
Closes #7156
2025-05-15gtk: implement command paletteLeah Amelia Chen
2025-05-15macos: add "Check for Updates" action, menu item & key-binding supportAaron Ruan
2025-05-12input: add backwards compatible alias for `plus` to `+`Mitchell Hashimoto
From #7320 Discussion #7340 There isn't a `physical` alias because there is no physical plus key defined for the W3C keycode spec.