252 Commits

Author SHA1 Message Date
Mitchell Hashimoto
c871140419 terminal: handle SCOSC/SCORC
Fixes #1401

SCOSC is ambiguous with regards to DECSLRM. This commit copies the logic
of xterm: if left/right mode is enabled, then CSI S is always DECSLRM.
But if left/right mode is disabled then CSI S empty always uses SCOSC.

SCORC always works.
2024-01-28 08:04:14 -08:00
Mitchell Hashimoto
33bc424d7e config: introduce wait-after-command 2024-01-17 08:40:21 -08:00
Mitchell Hashimoto
adb7958f61 remove tracy usage from all files 2024-01-13 15:06:08 -08:00
widberg
de71e992ec Use WINDIR instead of hardcoding C:\Windows 2024-01-11 11:57:40 -08:00
Mitchell Hashimoto
60b1b0a8de termio/exec: assign arena last so we capture allocations 2024-01-10 09:26:10 -08:00
Mitchell Hashimoto
4b6c2f86a7 termio/exec: remove a bunch of state that is duplicated on StreamHandler
A lot of the state that we put on Exec is just there to copy to
StreamHandler, but we already have it in DerivedConfig. I think this
whole copy copy copy is just legacy cruft since termio.Exec is one of
the older parts of the source code.

This rearchitects the Exec struct to act more like Surface and Renderer
where it stores its derived config. This lets us avoid a few extra
allocations and removes a LOT of struct member noise from termio.Exec.

For pointer lifetimes, the memory allocated is now owned by
DerivedConfig. When changeConfig is called, its the only time BOTH are
still alive, so we can safely swap pointers and deinit without having to
duplicate across threads. This is the same as renderer/surface.
2024-01-10 09:15:55 -08:00
Jeffrey C. Ollie
3c2dfd4a84 change name of config entry and variables, add lock for safety during config update 2024-01-09 10:07:32 -06:00
Jeffrey C. Ollie
342b5e9d06 implement enquiry 2024-01-07 23:50:58 -06:00
Mitchell Hashimoto
48f316ebd2 termio: support XDG data dirs greater than 4k for fish shell integration
Fixes #1228
2024-01-05 14:27:12 -08:00
Mitchell Hashimoto
38c5258d6e termio/exec: small change 2024-01-04 19:48:08 -08:00
widberg
2e79b5c63d Use cmd.exe instead of sh on Windows 2024-01-04 21:24:24 -05:00
Mitchell Hashimoto
797da2f737 termio/exec: avoid potential deadlock with surface message
Fixes #1198

This adds a fix similar to what we discovered with termio messages: we
attempt to send a surface message but if the queue is full we unlock the
terminal state and try again waiting forever.

In all cases, its safe to unlock the mutex while sending the message, no
scenario we send a surface message requires this lock to be held.
2024-01-02 15:34:20 -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
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
85c386f45d termio: remove old warning log statement used for debugging 2023-12-29 21:25:07 -08:00
Mitchell Hashimoto
a69ec2127e termio/exec: use bash instead of zsh for shell launching 2023-12-29 15:41:11 -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
Matthew Winter
5e3e76bcae Modify the way the login shell is launched on macOS to reduce nesting 2023-12-30 03:51:16 +11: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
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
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
Mitchell Hashimoto
30d3928e0f termio: allocate initial capacity more accurately 2023-12-16 14:04:58 -08:00
Mitchell Hashimoto
a8ef7d73d7 macos: do not load zsh config on the outer zsh launch
Related to #1102, #1074

Because we are now using the built-in zsh on macOS to launch the real
shell the user wants to use (see #1102 for why), this "outer zsh"
process was consuming our shell integration setup.

This commit adds flags so that this zsh instance doesn't load local
zshrc files and therefore doesn't consume our shell integration setup.
2023-12-16 07:54:10 -08:00
Mitchell Hashimoto
c534cd0b96 Merge pull request #1094 from gpanders/decrqss
termio: implement DECRQSS
2023-12-15 12:34:08 -08:00
Mitchell Hashimoto
ac3873401c termio/exec: only use sh login flag in flatpak 2023-12-15 10:00:53 -08:00
Mitchell Hashimoto
c345d3c941 termio/exec: use login(1) on macOS 2023-12-15 09:34:03 -08:00
Gregory Anders
47f8202334 termio: remove some code duplication in DECRQSS handler 2023-12-15 08:35:44 -06:00
Gregory Anders
bf06c05c09 termio: implement DECRQSS
Only SGR, DECSCUSR, DECSTBM, and DECSLRM are handled, as these are the
only ones that Ghostty supports (as far as I can tell) and are the only
ones that seem actually useful.
2023-12-14 17:26:53 -06:00
Tim Culverhouse
c9f2f806ec terminal: implement mode 1047 (alternate screen)
Implement handling of mode 1047, which enters the alternate screen. This
is not used often, typically applications will favor 1049 (enter alt
screen, save cursor, clear alt screen).
2023-12-05 10:37:11 -06:00
Mitchell Hashimoto
0d82b120da termio: set configured default cursor style on startup
Fixes #958
2023-12-01 19:39:16 -08:00
Mitchell Hashimoto
516edf1506 termio: only change mouse shape if it is changing
Fixes #976
2023-12-01 19:35:18 -08:00
Krzysztof Wolicki
0750698b62 Update to latest master,
update libxev dependency,
change mach_glfw to an updated fork until upstream updates
2023-11-30 21:41:33 +01:00
Mitchell Hashimoto
810242b472 termio: clear_screen binding does not trigger scrollback preservation
Fixes #970
2023-11-30 12:32:35 -08:00
Mitchell Hashimoto
ec3b570b3e terminal: know about autorepeat mode
Ignore it because xterm does
2023-11-21 18:48:05 -08:00
Mitchell Hashimoto
34cfe0abab xterm audit: DECOM (origin mode) 2023-11-21 18:32:00 -08:00
Tim Culverhouse
469c88c0c6 osc: fix OSC4 response
When reporting colors via OSC4, the index must also be reported.
2023-11-21 10:00:14 -06:00
Mitchell Hashimoto
f2513e0825 Merge pull request #876 from gpanders/notifications
Add support for desktop notifications
2023-11-17 21:57:09 -08:00