10108 Commits

Author SHA1 Message Date
Mitchell Hashimoto
ba67c506f2 ci: extract translation check to script so we can run standalone 2025-04-22 08:55:03 -07:00
Tristan Partin
1c62ddffc4 apprt/gtk: add menu to new tab button to create splits
Closes: https://github.com/ghostty-org/ghostty/discussions/6828
Signed-off-by: Tristan Partin <tristan@partin.io>
2025-04-21 13:01:37 -05:00
Mitchell Hashimoto
40c3dbbb31 macOS: remove "r" & "c" from resize overlay (#7142)
as per [#6013](https://github.com/ghostty-org/ghostty/pull/6013) and
[#6040](https://github.com/ghostty-org/ghostty/pull/6040) but for macOS
2025-04-21 08:13:49 -07:00
Asadullah Shaikh
9709d934f0 remove "r" & "c" from resize overlay on macOS 2025-04-21 20:25:25 +05:30
Mitchell Hashimoto
8c02eea48b macOS: get proper unshifted codepoint with ctrl pressed (#7150)
Fixes a regression where `C-S-c` stopped working properly in both legacy
and Kitty modes (although the Kitty mode side only affected alternates
and not the key itself so it probably worked fine in most programs).

The issue is that `charactersIgnoringModifiers` changes behavior if
`control` is pressed, so it doesn't really ignore all modifiers. We have
to use `characters(byApplyingModifiers:)` to get the proper unshifted
codepoint when `control` is pressed.
2025-04-21 07:52:39 -07:00
Mitchell Hashimoto
643c882597 macOS: use KeyboardShortcut rather than homegrown KeyEquivalent (#7139)
This replaces the use of our custom `Ghostty.KeyEquivalent` with the
SwiftUI `KeyboardShortcut` type. This is a more standard way to
represent keyboard shortcuts and lets us more tightly integrate with
SwiftUI/AppKit when necessary over our custom type.

This PR should have no user impact. This is just some cleanup for future
work.

Note that not all Ghostty triggers can be represented as
KeyboardShortcut values because macOS itself does not support binding
keys such as function keys (e.g. F1-F12) to KeyboardShortcuts.

This isn't an issue since all input also passes through a lower level
libghostty API which can handle all key events, we just can't show these
keyboard shortcuts on things like the menu bar. This was already true
before this commit.
2025-04-21 07:26:34 -07:00
Mitchell Hashimoto
fe3b0e0ef6 Correct change_title_promptprompt_surface_title (#7149)
This was changed pretty late at
https://github.com/ghostty-org/ghostty/pull/4217#issuecomment-2660307923,
and I don't think anybody saw my comment at
https://github.com/ghostty-org/ghostty/pull/4217#discussion_r2045783050;
I have no idea if this change is correct and have no way to test it
either as I don't use macOS, but I'm quite suspicious of that line
having not been changed.
2025-04-21 07:25:09 -07:00
Mitchell Hashimoto
7e00f2fb7f macOS: get proper unshifted codepoint with ctrl pressed
Fixes a regression where `C-S-c` stopped working properly in both legacy
and Kitty modes (although the Kitty mode side only affected alternates
and not the key itself so it probably worked fine in most programs).

The issue is that `charactersIgnoringModifiers` changes behavior if
`control` is pressed, so it doesn't really ignore all modifiers. We have
to use `characters(byApplyingModifiers:)` to get the proper unshifted codepoint
when `control` is pressed.
2025-04-21 07:23:24 -07:00
Mitchell Hashimoto
7d4dddb94e Update iTerm2 colorschemes (#7140)
Upstream revision:
c5e4212e76
2025-04-21 07:11:58 -07:00
Leah Amelia Chen
b13b6465f2 Remove note about default from bell-features→system's description (#7148) 2025-04-21 11:53:48 +08:00
Kat
d4525f2c57 Correct remaining instances of change_title_prompt to prompt_surface_title. 2025-04-21 03:41:52 +00:00
Kat
160b26708c Remove note about default from bell-features→system's description. 2025-04-21 03:24:05 +00:00
mitchellh
48cba761b9 deps: Update iTerm2 color schemes 2025-04-20 00:14:26 +00:00
Mitchell Hashimoto
b05826ac9d macOS: use KeyboardShortcut rather than homegrown KeyEquivalent
This replaces the use of our custom `Ghostty.KeyEquivalent` with
the SwiftUI `KeyboardShortcut` type. This is a more standard way to
represent keyboard shortcuts and lets us more tightly integrate with
SwiftUI/AppKit when necessary over our custom type.

Note that not all Ghostty triggers can be represented as
KeyboardShortcut values because macOS itself does not support
binding keys such as function keys (e.g. F1-F12) to KeyboardShortcuts.

This isn't an issue since all input also passes through a lower level
libghostty API which can handle all key events, we just can't show these
keyboard shortcuts on things like the menu bar. This was already true
before this commit.
2025-04-19 14:39:48 -07:00
Mitchell Hashimoto
4e10f972df macOS: Do not send control characters as UTF8 keyboard text (#7136)
Fixes a regression where `ctrl+enter` was not encoding properly since
our input stack changes.
2025-04-19 07:06:39 -07:00
Mitchell Hashimoto
9beaed45f8 Revert "apprt/gtk: add menu to new tab button to create splits (#7127)"
This reverts commit 14134d61fb4b1bbf4ce80bb9b3ed849908bf9344, reversing
changes made to 6a876ef8ec3e2aeb3d15df0dfb0e07677e49ff03.

This causes translation failures, this should be reintroduced when the
CI check passes.
2025-04-19 07:05:38 -07:00
Mitchell Hashimoto
31b2ac4b79 macOS: Do not send control characters as UTF8 keyboard text
Fixes a regression where `ctrl+enter` was not encoding properly since
our input stack changes.
2025-04-19 06:54:36 -07:00
Tristan Partin
14134d61fb apprt/gtk: add menu to new tab button to create splits (#7127)
Closes: https://github.com/ghostty-org/ghostty/discussions/6828
2025-04-19 01:23:18 -05:00
Tristan Partin
410761d4e3 apprt/gtk: add menu to new tab button to create splits
Closes: https://github.com/ghostty-org/ghostty/discussions/6828
Co-authored-by: Leah Amelia Chen <github@acc.pluie.me>
Signed-off-by: Tristan Partin <tristan@partin.io>
2025-04-19 01:04:57 -05:00
Mitchell Hashimoto
6a876ef8ec macOS: A couple input regressions from 7121 (#7132)
Fixes #7131 

See individual commit messages.

I'm running them through the same tests as #7121 to verify manually that
behavior.
2025-04-18 15:35:12 -07:00
Mitchell Hashimoto
e4a37dd383 macOS: only set unshifted codepoint on keyDown/Up events
Other event types trigger an AppKit assertion that doesn't crash the app
but logs some nasty stuff.
2025-04-18 15:14:38 -07:00
Mitchell Hashimoto
18d6faf597 macOS: translation mods should never have "control"
This also lets us get rid of our `C-/` special handling to prevent a
system beep.
2025-04-18 15:10:57 -07:00
Mitchell Hashimoto
edb8616341 macos: translationMods should be used for consumed mods calculation
Fixes #7131
Regression from #7121

Our consumed mods should not include "alt" if `macos-option-as-alt` is
set. To do this, we need to calculate our consumed mods based on the
actual translation event mods (if available, only available during
keyDown).
2025-04-18 14:28:26 -07:00
Mitchell Hashimoto
65356c25da macOS/libghostty: rework keyboard input handling (#7121)
This is a large refactor of the keyboard input handling code in
libghostty and macOS. Previously, libghostty did a lot of things that
felt out of scope or was repeated work due to lacking context. For
example, libghostty would do full key translation from key event to
character (including unshifted translation) as well as managing dead key
states and setting the proper preedit text.

This is all information the apprt can and should have on its own.
NSEvent on macOS already provides us with all of this information,
there's no need to redo the work. The reason we did in the first place
is mostly historical: libghostty powered our initial macOS port years
ago when we didn't have an AppKit runtime yet.

This cruft has already practically been the source of numerous issues,
e.g.
https://github.com/ghostty-org/ghostty/issues/5558, but many other hacks
along the way, too.

This commit pushes all preedit (e.g. dead key) handling and key
translation
including unshifted keys up into the caller of libghostty.

Besides code cleanup, a practical benefit of this is that key event
handling on macOS is now about 10x faster on average. That's because
we're avoiding repeated key translations as well as other unnecessary
work. This should have a meaningful impact on input latency but I didn't
measure the full end-to-end latency.

A scarier part of this commit is that key handling is not well tested
since its a GUI component. I suspect we'll have some fallout for certain
keyboard layouts or input methods, but I did my best to run through
everything I could think of.

This also fixes one bug where preedit state didn't properly clear when
changing keyboard layouts. This now does and matches the behavior
of native apps like TextEdit and Terminal.app
2025-04-18 12:06:32 -07:00
Tristan Partin
85268d4f82 apprt/gtk: refactor action callbacks to reduce code duplication (#7126)
It was getting very monotonous reading the code.
2025-04-18 13:11:12 -05:00
Tristan Partin
793c727986 apprt/gtk: refactor action callbacks to reduce code duplication
It was getting very monotonous reading the code.

Signed-off-by: Tristan Partin <tristan@partin.io>
2025-04-18 12:54:36 -05:00
Leah Amelia Chen
773506fe82 Improve Chinese (zh_CN) Translations for Natural Phrasing (#7125) 2025-04-18 23:56:12 +08:00
Bryan Lee
34ddd3d9e5 Refine Chinese translations for daily usage consistency 2025-04-18 23:34:18 +08:00
Mitchell Hashimoto
03a1c04a6e i18n: fix spelling inconsistencies for Japanese Translations (#7122)
This pr fix spelling inconsistencies for Japanese Translations
2025-04-18 07:17:46 -07:00
Mitchell Hashimoto
b63fa7dfa1 vim: fix syntax highlight on scratch buffer (#7119)
Sometimes we need detect ghostty filetype on scratch buffer.
In this case `set iskeyword` in ftplugin is not loaded.

Screenshot:
https://github.com/ibhagwan/fzf-lua/pull/1913#issuecomment-2813289819.

e.g.
```sh
nvim +'0r ~/.config/ghostty/config' +'se syntax=ghostty'
```
2025-04-18 07:17:30 -07:00
phanium
9bab900c75 vim: fix syntax highlight on scratch buffer 2025-04-18 21:50:24 +08:00
ekusiadadus
bef0d5d88e fix: spelling inconsistencies for Japanese Translations 2025-04-18 07:22:40 +09:00
Mitchell Hashimoto
ded9be39c0 macOS: handle preedit text changes outside of key event 2025-04-17 14:24:12 -07:00
Mitchell Hashimoto
b3cb38c3fa macOS/libghostty: rework keyboard input handling
This is a large refactor of the keyboard input handling code in
libghostty and macOS. Previously, libghostty did a lot of things that
felt out of scope or was repeated work due to lacking context. For
example, libghostty would do full key translation from key event to
character (including unshifted translation) as well as managing dead key
states and setting the proper preedit text.

This is all information the apprt can and should have on its own.
NSEvent on macOS already provides us with all of this information,
there's no need to redo the work. The reason we did in the first place
is mostly historical: libghostty powered our initial macOS port years
ago when we didn't have an AppKit runtime yet.

This cruft has already practically been the source of numerous issues, e.g.
#5558, but many other hacks along the way, too.

This commit pushes all preedit (e.g. dead key) handling and key translation
including unshifted keys up into the caller of libghostty.

Besides code cleanup, a practical benefit of this is that key event
handling on macOS is now about 10x faster on average. That's because
we're avoiding repeated key translations as well as other unnecessary
work. This should have a meaningful impact on input latency but I didn't
measure the full end-to-end latency.

A scarier part of this commit is that key handling is not well tested
since its a GUI component. I suspect we'll have some fallout for certain
keyboard layouts or input methods, but I did my best to run through
everything I could think of.
2025-04-17 14:24:12 -07:00
Mitchell Hashimoto
2bcd76c3d9 macOS: Implement basic bell features (no sound) (#7101)
Fixes #7099

This adds basic bell features to macOS to conceptually match the GTK
implementation. When a bell is triggered, macOS will do the following:

  1. Bounce the dock icon once, if the app isn't already in focus.
2. Add a bell emoji (🔔) to the title of the surface that triggered the
bell. This emoji will be removed after the surface is focused or a
keyboard event if the surface is already focused. This behavior matches
iTerm2.

Note that neither of these respect the `system` `bell-features` config
because they're both unobtrusive (the dock icon bounces only once, the
title change is silent and similar to GTK tab attention) and unrelated
to system settings.

This doesn't add an icon badge because macOS's dockTitle.badgeLabel API
wasn't doing anything for me and I wasn't able to fully figure out
why...
2025-04-15 13:24:20 -07:00
Mitchell Hashimoto
cc690eddb5 macOS: Implement basic bell features (no sound)
Fixes #7099

This adds basic bell features to macOS to conceptually match the GTK
implementation. When a bell is triggered, macOS will do the following:

  1. Bounce the dock icon once, if the app isn't already in focus.
  2. Add a bell emoji (🔔) to the title of the surface that triggered
     the bell. This emoji will be removed after the surface is focused
     or a keyboard event if the surface is already focused. This
     behavior matches iTerm2.

This doesn't add an icon badge because macOS's dockTitle.badgeLabel API
wasn't doing anything for me and I wasn't able to fully figure out
why...
2025-04-15 10:41:15 -07:00
Mitchell Hashimoto
392aab2e4a macos: quick terminal uses padded notch mode if notch is visible (#7098)
Fixes #6612
2025-04-15 09:04:44 -07:00
Mitchell Hashimoto
b77c5634f0 macos: quick terminal uses padded notch mode if notch is visible
Fixes #6612
2025-04-15 08:52:20 -07:00
Mitchell Hashimoto
62af0c0ec0 terminal: clear correct row on index operation in certain edge cases (#7093)
Fixes #7066

This fixes an issue where under certain conditions (expanded below), we
would not clear the correct row, leading to the screen having duplicate
data.

This was triggered by a page state of the following:

```
      +----------+ = PAGE 0
  ... :          :
 4305 |1ABCD00000|
 4306 |2EFGH00000|
      :^         : = PIN 0
     +-------------+ ACTIVE
 4307 |3IJKL00000| | 0
      +----------+ :
      +----------+ : = PAGE 1
    0 |          | | 1
    1 |          | | 2
      +----------+ :
     +-------------+
```

Namely, the cursor had to NOT be on the last row of the first page, but
somewhere on the first page. Then, when an `index` (LF) operation was
performed the result would look like this:

```
      +----------+ = PAGE 0
  ... :          :
 4305 |1ABCD00000|
 4306 |2EFGH00000|
     +-------------+ ACTIVE
 4307 |3IJKL00000| | 0
      :^         : : = PIN 0
      +----------+ :
      +----------+ : = PAGE 1
    0 |3IJKL00000| | 1
    1 |          | | 2
      +----------+ :
     +-------------+
```

The `3IJKL` line was duplicated. What was happening here is that we
performed the index operation correctly but failed to clear the cursor
line as expected.

This is because we were always clearing the first row in the page
instead of the row of the cursor.

Test added.
2025-04-15 07:09:18 -07:00
Mitchell Hashimoto
4aa875bbf6 ci: add logging to localization-review script (#7094)
An example of the new output (this very PR as an example):

<img
src="https://github.com/user-attachments/assets/0136238c-75d1-4bc6-8a3f-cb4b80daa512"
width="80%">

I also performed a couple of small refactors.
2025-04-14 15:56:15 -07:00
Mitchell Hashimoto
da6b478fbe terminal: clear correct row on index operation in certain edge cases
Fixes #7066

This fixes an issue where under certain conditions (expanded below), we
would not clear the correct row, leading to the screen having duplicate
data.

This was triggered by a page state of the following:

```
      +----------+ = PAGE 0
  ... :          :
 4305 |1ABCD00000|
 4306 |2EFGH00000|
      :^         : = PIN 0
     +-------------+ ACTIVE
 4307 |3IJKL00000| | 0
      +----------+ :
      +----------+ : = PAGE 1
    0 |          | | 1
    1 |          | | 2
      +----------+ :
     +-------------+
```

Namely, the cursor had to NOT be on the last row of the first page,
but somewhere on the first page. Then, when an `index` (LF) operation
was performed the result would look like this:

```
      +----------+ = PAGE 0
  ... :          :
 4305 |1ABCD00000|
 4306 |2EFGH00000|
     +-------------+ ACTIVE
 4307 |3IJKL00000| | 0
      :^         : : = PIN 0
      +----------+ :
      +----------+ : = PAGE 1
    0 |3IJKL00000| | 1
    1 |          | | 2
      +----------+ :
     +-------------+
```

The `3IJKL` line was duplicated. What was happening here is that we
performed the index operation correctly but failed to clear the cursor
line as expected.

This is because we were always clearing the first row in the page
instead of the row of the cursor.

Test added.
2025-04-14 15:54:00 -07:00
trag1c
8bc91933cd ci: add logging to localization-review script 2025-04-14 23:58:29 +02:00
Mitchell Hashimoto
8bab8f7d64 macOS: fix quick terminal fullscreen issues (#7091)
Supersedes #7075 
Fixes #7070 

This fixes a few separate fullscreen issues with the quick terminal:

1. If we're on a fullscreen space, we can't reliably set the
`autoHideMenuBar` presentation option because macOS itself is managing
it. The fix is to use private APIs to detect we're on a fullscreen space
and avoid this.

2. If our quick terminal is fullscreen when we move spaces, we must exit
and re-enter fullscreen because the frame may change (e.g. due to
menubar changes).

3. If we aren't the frontmost app, we must avoid hiding the menu because
it has no effect and our fullscreen frame would be wrong.
2025-04-14 11:29:04 -07:00
Mitchell Hashimoto
21d09fe2e0 i18: fix minor Norwegian grammar issues (#7085)
Changes the translation of 'clipboard' to definite singular form, and
removes a misplaced verb.
2025-04-14 11:22:40 -07:00
Mitchell Hashimoto
c23b389cf1 gtk: implement bell (#7087)
This PR implements a more lightweight alternative to #5326 that contains
features that I personally think Just Make Sense for the bell.

No configs, no GStreamer stuff, just sane defaults to get us started.
2025-04-14 11:19:19 -07:00
Mitchell Hashimoto
d1c15dbf07 macOS: quick terminal should retain menu if not frontmost
This is a bug I noticed in the following scenario:

  1. Open Ghostty
  2. Fullscreen normal terminal window (native fullscreen)
  3. Open quick terminal
  4. Move spaces, QT follows
  5. Fullscreen the quick terminal

The result was that the menu bar would not disappear since our app is
not frontmost but we set the fullscreen frame such that we expected it.
2025-04-14 11:17:11 -07:00
Mitchell Hashimoto
453e6590e8 macOS: non-native fullscreen should not hide menu on fullscreen space
Fixes #7075

We have to use private APIs for this, I couldn't find a reliable way
otherwise.
2025-04-14 10:38:54 -07:00
Leah Amelia Chen
3a973c692a gtk(bell): add bell-features config option
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2025-04-15 00:18:05 +08:00
Leah Amelia Chen
abd7d9202b gtk(bell): mark tab as needing attention on bell 2025-04-14 23:44:13 +08:00
Leah Amelia Chen
10a591fba2 gtk(bell): use gdk.Surface.beep for bell
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2025-04-14 23:44:13 +08:00