3716 Commits

Author SHA1 Message Date
Chris Marchesi
fc4fdbb643 apprt/gtk: ensure modifier state matches current keypress under X11
This fixes an issue in that when running under X11, when a modifier key
is pressed, the modifier state will "lag" behind what should be current.
This is due to how X11 sends modifiers in events, i.e. it sends the
state from right before the key press, and does not include the effects
of the key press itself.

This is corrected by checking the X event queue directly for a pending
XkbStateNotify event (we mask this on modifiers), and setting the
modifiers off of that if we find one. If not, we fall back to the GDK
call.
2023-12-30 22:58:33 -08:00
Mitchell Hashimoto
0eee66f21b termio/exec: stylistic change on abnormal exit 2023-12-30 21:47:34 -08:00
Mitchell Hashimoto
134327c1a3 termio/exec: reorder member since we like alloc on top 2023-12-30 21:46:27 -08:00
Mitchell Hashimoto
aef93a5420 config: make abnormal runtime threshold a u32 2023-12-30 21:45:16 -08:00
Jeffrey C. Ollie
4ef8d099a7 Make the abnormal runtime threshold configurable. 2023-12-30 22:52:47 -06:00
Jeffrey C. Ollie
792284fb69 Add exit code and runtime to abnormal exit error message. 2023-12-30 22:24:25 -06:00
Mitchell Hashimoto
730343c600 termio/exec: pass code and runtime to error but don't show it yet 2023-12-30 19:37:38 -08:00
Mitchell Hashimoto
53dffc8e18 termio/exec: style the exec failure error better 2023-12-30 19:34:45 -08:00
Mitchell Hashimoto
f3aaa884c6 termio/exec: use message to writer thread so we can output failed cmd 2023-12-30 17:51:34 -08:00
Mitchell Hashimoto
aaded1f311 termio/exec: use arraylist to build up message for error 2023-12-30 15:52:26 -08:00
Mitchell Hashimoto
fc963064c6 termio/exec: abnormal exit can use exit code on linux 2023-12-30 15:43:50 -08:00
Mitchell Hashimoto
3ee842e1b7 config: remove command validation
Abnormal exit detection is more robust, and this validation always had
issues for example we didn't parse shell escapes and so on.
2023-12-30 15:36:13 -08:00
Mitchell Hashimoto
3fae05e2dc termio/exec: detect abnormally short runtime and show an error message 2023-12-30 15:35:35 -08:00
Mitchell Hashimoto
2ed75d47b5 termio/exec: detect exec failure and show an error message 2023-12-30 15:07:23 -08:00
Mitchell Hashimoto
8c5e8c504e config: skip command validation if it has a space
See comment
2023-12-30 14:46:05 -08:00
Mitchell Hashimoto
85c386f45d termio: remove old warning log statement used for debugging 2023-12-29 21:25:07 -08:00
Mitchell Hashimoto
a159eafc18 Merge pull request #1180 from mitchellh/change-macos-launch
Modify the way the login shell is launched on macOS to reduce nesting
2023-12-29 15:50:18 -08:00
Mitchell Hashimoto
a69ec2127e termio/exec: use bash instead of zsh for shell launching 2023-12-29 15:41:11 -08:00
Mitchell Hashimoto
3e9a4ea234 terminal: cub with reverse wrap consumes pending wrap state as one
Related to #1184

See the updated website page and associated test.
2023-12-29 12:45:57 -08:00
Mitchell Hashimoto
fdd519f73b terminal: cursor back should not reduce by one with pending wrap
Fixes #1183

I'm not sure why the original logic was there. When I translated the
original test cases to shell and ran them in xterm, they did NOT match
what Ghostty expected. This updates the tests to match xterm and removes
this case. We can add back in more tests if/when we figure out under
what scenario this original logic was correct (if it ever was).
2023-12-29 12:34:33 -08:00
Mitchell Hashimoto
4ec2f50c1d config: validate that command can be found on the path 2023-12-29 11:22:34 -08:00
Matthew Winter
992888d4bd Ensure the cwd is not changed, whilst remaining a logon shell 2023-12-30 05:40:07 +11:00
Matthew Winter
9989436beb Ensure the shell environment passes the Login Shell test 2023-12-30 04:32:13 +11:00
Mitchell Hashimoto
b50ce6bb6a Merge pull request #1176 from tristan957/libadwaita
Use adw_application_new() instead of adw_init()
2023-12-29 09:11:21 -08:00
Mitchell Hashimoto
e43919cb9e apprt/gtk: stylistic changes to adwaita init 2023-12-29 09:10:49 -08:00
Matthew Winter
5e3e76bcae Modify the way the login shell is launched on macOS to reduce nesting 2023-12-30 03:51:16 +11:00
Mitchell Hashimoto
5cef3ced18 Merge pull request #1179 from mitchellh/keypad-maybe
input: only send keypad events for keypad application mode
2023-12-28 20:02:15 -08:00
Tristan Partin
41aa9ac2ff Use adw_application_new() instead of adw_init()
This will enable further libadwaita improvements in the future, but will
have no effect today.
2023-12-28 21:50:56 -06:00
Mitchell Hashimoto
7fcd4233cd config: not that cursor-style with shell integration overwrites 2023-12-28 09:17:42 -08:00
Tim Culverhouse
eda76e105f termio: delay repeated waitpid syscalls when killing children
PR #1168 introduced a loop to kill all children. The `waitpid` call is
issued with the NOHANG flag, which means it returns immediately if no
child has exited. This has the effect that we can repeatedly run through
this loop making this syscall, flooding the system with calls and not
getting timely responses. On my system, this caused Ghostty to take ~30
seconds to close. In my attempts to debug, I added logging to the loop
which resolved the issue. To find out why, I added a loop counter and
found the loop would run > 70 million cycles while trying to close. By
adding logging, I introduced just enough delay in the loop cycle to
prevent whatever flooding of syscalls was happening. This reduced the
loop counter to ~2 cycles before closing.

Add a small delay to prevent syscall flooding.
2023-12-28 10:43:33 -06:00
Mitchell Hashimoto
e32c031588 termio: ensure we kill all the children without killing ourselves
Fixes #497

This commit resolves two bugs:

First, if a surface is created and destroyed too quickly, the child
process may not have called `setsid` yet (to set the process group). In
this case, `getpgid` returns Ghostty's process group and we were killing
ourselves. We now detect we're about to kill ourselves and wait for our
child to be ready to be killed.

Second, if the child calls setsid but is in the process of execve when
we send a killpg, then the child will be killed but any newly spawned
grandchildren will remain alive. To fix this, we moved the waitpid call
into a kill loop so we can repeatedly kill our child if we detect any
grandchildren are still alive.
2023-12-27 21:44:58 -08:00
Mitchell Hashimoto
21db51ff9d input: only send keypad events for keypad application mode
Fixes #1099
2023-12-27 08:10:01 -08:00
Mitchell Hashimoto
b573ff137a terminal: resize cols should treat old cursor pos as active point
Fixes #1159

The cursor position is an "active" coordinate (defined at the top of
Screen.zig), but our resize was treating it as a "viewport" coordinate.
2023-12-26 13:59:22 -08:00
Mitchell Hashimoto
8b3094465d config: grapheme-width-method, default to "unicode"
This adds a new configuration `grapheme-width-method` to change the
default behavior that Ghostty uses to calculate grapheme width. The
default value is `unicode` which is identical to setting mode 2027.

**IMPORTANT:** This changes the default Ghostty behavior to be fully
grapheme-aware including ZWJs, VS15, VS16. This may cause issues with
some legacy programs and shells.

I've changed my mind that this should become the default because enough
people use emojis now that I've found in the beta program there are more
issues reported about "incorrect emoji width" than any possibly desync
issues. We'll see.

For legacy programs, this can still be set to `grapheme-width-method =
wcswidth`.
2023-12-25 14:19:05 -08:00
Mitchell Hashimoto
0a1dfae2ef input: kitty keyboard modifier event changes from Kitty 0.32
> When the key event is related to an actual modifier key, the corresponding
> modifier's bit must be set to the modifier state including the effect for the
> current event. For example, when pressing the :kbd:`LEFT_CONTROL` key, the
> ``ctrl`` bit must be set and when releasing it, it must be reset. When both
> left and right control keys are pressed and one is released, the release event
> must have the ``ctrl`` bit set. See :iss:`6913` for discussion of this design.
2023-12-24 08:21:31 -08:00
Mitchell Hashimoto
f615a308e0 config: change window-save-state to default 2023-12-23 18:52:40 -08:00
Mitchell Hashimoto
243379c50f apprt/embedded: ghostty_surface_pwd 2023-12-23 16:59:09 -08:00
Mitchell Hashimoto
a5d249eb48 config: if window-save-state is never, never restore state 2023-12-22 22:00:25 -08:00
Mitchell Hashimoto
f0bf0fd888 config: window-save-state 2023-12-22 21:51:06 -08:00
Mitchell Hashimoto
69131af808 Merge pull request #1154 from vancluever/vancluever-macos-middle-click-paste
macos: middle click always pastes from clipboard
2023-12-22 19:02:25 -08:00
Chris Marchesi
ffb9ebf6d9 macos: middle click always pastes from clipboard
Following up on #1145, this changes middle-click behavior on MacOS to
always paste from the system clipboard. This does not alter any of the
selection behavior, i.e. default behavior is to allow paste, but you
still need to manually copy. MacOS users still need to enable
"copy-on-select = clipboard" for that respective functionality.
2023-12-22 17:51:51 -08:00
Mitchell Hashimoto
1f50406967 apprt/gtk: correct icon path now that our resources dir is in a subdir
From #1132, our resources dir is now someting like `/usr/share/ghostty`,
but GTK icons always go into `/usr/share/icons`. This does a basename on
the resources dir to set the correct directory.
2023-12-22 17:03:34 -08:00
Mitchell Hashimoto
86bd972d22 macos: do not change nofile rlimit max
Fixes #1146

I can't remember why we did this before. The comment in question makes
sense if we were trying to set cur to infinity but doesn't make sense to
me why we'd change max. Removing this doesn't seem to cause any issues
so lets give it a shot.
2023-12-22 08:58:31 -08:00
Mitchell Hashimoto
a94973c240 Merge pull request #1138 from gpanders/vim-plugin
build: build Vim plugin files for Ghostty config file
2023-12-22 08:50:34 -08:00
Mitchell Hashimoto
eb46161b5e config: generate vim configs at comptime 2023-12-22 08:19:17 -08:00
Mitchell Hashimoto
ede7ec9c63 input: kitty encoding should only report alt key if not equal to utf8 2023-12-21 20:43:42 -08:00
Gregory Anders
4f01aafdba build: move Vim plugin file generation into a separate Step 2023-12-21 21:49:38 -06:00
Gregory Anders
18f2fb3fbd macos: include ghostty subdirectory under Resources
This enables us to treat Ghostty's resources directory the same way
whether it is installed in a macOS app bundle or under e.g. /usr/share.
2023-12-21 17:56:57 -08:00
Gregory Anders
8751502878 core: look for resources in "ghostty" subdirectory for "share" paths
Installing resources directly under ${prefix}/share causes conflicts
with other packages. This will become more problematic whenever Ghostty
is opened and becomes packaged in distributions.

Instead, install all resources under a "ghostty" subdirectory (i.e.
${prefix}/share/ghostty). This includes themes, shell integration, and
terminfo files.

Only "/usr/share" style paths use the "ghostty" subdirectory. On macOS,
Ghostty is already isolated within its app bundle, and if
$GHOSTTY_RESOURCES_DIR is set then we assume that points to the actual
resources dir (without needing to append "ghostty" to it).
2023-12-21 17:56:17 -08:00
Tim Culverhouse
416950a447 terminfo: fix xr and rv
Commit 5e473ebd ("terminfo: add additional entries, fix smkx/rmkx")
added entries `xr` and `rv`, but without proper escaping of the
backslashes. This commit adds the extras. Output of `infocmp` now
matches foot, kitty, et al.
2023-12-21 13:36:00 -06:00