2094 Commits

Author SHA1 Message Date
Mitchell Hashimoto
c0f5c0ef41 termio/exec: poll() needs a negative timeout to block 🤡 2023-08-08 09:14:08 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
aff64d9951 Merge pull request #247 from mitchellh/gtk-single-instance
GTK single instance, fix UB in termio read thread termination
2023-08-07 21:43:08 -07:00
Mitchell Hashimoto
6d32d74996 apprt/gtk: remove useless calls 2023-08-07 21:15:42 -07:00
Mitchell Hashimoto
e2e876bfa1 termio/exec: make sure that process is dead before killing read thread 2023-08-07 21:13:33 -07:00
Mitchell Hashimoto
b5bb3b3739 termio/exec: if read thread gets 0 bytes then break the tight loop 2023-08-07 21:10:11 -07:00
Mitchell Hashimoto
816cad07b9 termio/exec: set pty fd to non-blocking, try to read as long as possible 2023-08-07 20:55:01 -07:00
Mitchell Hashimoto
f40a90e7aa termio: use a pipe to notify the reader thread to quit
Simultaneously reading and closing a fd is UB. We need to ensure that we
quit, then close.
2023-08-07 20:41:34 -07:00
Mitchell Hashimoto
2e98d43a58 apprt/glfw: launch window on startup 2023-08-07 19:28:48 -07:00
Mitchell Hashimoto
60a36ca5cc apprt/gtk: enable single instance mode 2023-08-07 19:26:57 -07:00
Mitchell Hashimoto
22296b377a Revert "Merge pull request #244 from mitchellh/alt-as-esc"
This reverts commit c139279d479682c17f63d9b57c2d56608d09d16a, reversing
changes made to 4ed21047a734d7c586debe0026e3b6ea90ed1622.

We do want to do this but this broke bindings.
2023-08-07 17:06:40 -07:00
Mitchell Hashimoto
23935c3563 change sentinel value for resources dir, its different on Linux 2023-08-07 16:16:44 -07:00
Mitchell Hashimoto
ebbf42eec6 search for resources dir relative to executing binary on Linux (#245)
* search for resources dir relative to executing binary on Linux

From Andrew in #241:

This works in all 3 of the possible scenarios I can think of on Linux:
 * `zig build` with default prefix into `zig-out`
 * `zig build -p ~/local` (my choice when compiling from source)
 * ghostty packaged for a linux distribution into /usr/bin and /share

* update README
2023-08-07 16:08:27 -07:00
Mitchell Hashimoto
274f934e88 key: fix wrong comment 2023-08-07 15:39:08 -07:00
Mitchell Hashimoto
32eb226fa3 non-macos doesn't support directional bindings 2023-08-07 14:52:20 -07:00
Mitchell Hashimoto
47bed51177 bindings can contain directional modifiers: left_shift+a 2023-08-07 14:43:44 -07:00
Mitchell Hashimoto
eca5955e65 apprt/gtk: new input mods format 2023-08-07 14:35:52 -07:00
Mitchell Hashimoto
67cbabd605 make keyboard modifiers left/right-aware throughout core 2023-08-07 14:33:56 -07:00
Mitchell Hashimoto
5e100a3b6b CSI r for top/bot margin must have no intermediates
We were incorrectly interpreting the restore mode CSI (`ESC [ ? r`) as
set top and bottom margin. We need to verify that there are no
intermediates.
2023-08-07 09:45:44 -07:00
Mitchell Hashimoto
24ef5d1b1c tests for insert mode (4) 2023-08-07 08:07:14 -07:00
Mitchell Hashimoto
5c6d3c7df2 terminal: implement insert mode (mode = 4) 2023-08-07 07:44:13 -07:00
Mitchell Hashimoto
85e32f9a15 renderer: hide cursor is state explicit asks for invisible cursor
This was a regression. The previous logic would always show the cursor
if we were using a non-blinking cursor. But, if the terminal state is
explicitly requesting an invisible cursor (mode 25) then we need to hide
the cursor.
2023-08-06 09:55:13 -07:00
Mitchell Hashimoto
2065dd77d7 renderer/opengl: need to release OpenGL context with glfw 2023-08-05 22:33:55 -07:00
Mitchell Hashimoto
321be2d5ad termio: respect GHOSTTY_RESOURCES_DIR 2023-08-05 21:38:32 -07:00
Mitchell Hashimoto
2840062ad5 bind shift+<page-up/down> to jump_to_prompt back/forward, respectively 2023-08-05 21:32:30 -07:00
Mitchell Hashimoto
ef5d75e328 input: support assigning integer binding action values
This enables jump_to_prompt
2023-08-05 21:31:34 -07:00
Mitchell Hashimoto
0bb286eeb2 C API for invoking bindings 2023-08-05 14:46:47 -07:00
Mitchell Hashimoto
2e55b87e51 Merge pull request #222 from mitchellh/size
only send resize messages to renderer/io thread if changes happen
2023-08-04 19:58:40 -07:00
Mitchell Hashimoto
437c1ca261 only send resize messages to renderer/io thread if changes happen
Previously, we'd send renderer screen size updates and termio sigwnch
updates on every single resize event even if the screen size or grid
sizes didn't change. This is super noisy and given how many resize
events macOS sends, its also very expensive.

This commit makes it so that we only update the renderer if the screen
changed. If the screen size didn't change, the grid size couldn't have
changed either.

If the screen size did change, its still possible the grid size didn't
change since Ghostty supports fluid pixel-level resizing. We have to
send the screen size event to the renderer so all the GPU shader vars
are right but we do not have to send a termio event.

So, only if the grid size changed do we then notify the pty that the
terminal dimensions changed. Note that the resize event for ptys does
have a pixel-level x/y but I don't think the granularity is useful
beyond grid changes.
2023-08-04 19:50:21 -07:00
Mitchell Hashimoto
8ff81de30f apprt/gtk: fix build for macos non-native fullscreen changes 2023-08-04 18:19:48 -07:00
Thorsten Ball
b56ffa6285 Add config setting to turn non-native fullscreen on or off 2023-08-04 14:12:33 -07:00
Mitchell Hashimoto
363e911f77 shell-integration/zsh: enable title changes 2023-08-04 11:14:45 -07:00
Mitchell Hashimoto
fb2f635c91 termio/exec: default window title to the pwd if not reported
We rely on the shell to report the window title. If the shell doesn't
report the window title then we default to the pwd.
2023-08-04 11:07:59 -07:00
Thorsten Ball
3ab96f266b gtk: add missing space in close dialog and add newline
See before/after screenshots. Before, without the space, it's wrong. I
fixed that and added a newline, since a big paragraph like that looks a
bit wrong in a dialog popup.
2023-08-01 07:03:57 +02:00
Mitchell Hashimoto
b459c6e002 Merge pull request #214 from mitchellh/mrn/gtk-default-keybinding-split
config: change default keybind for goto-split on non-Darwin
2023-07-23 15:59:45 -07:00
Thorsten Ball
920b90ba1a config: change default keybind for goto-split on non-Darwin
Feel free to ignore or close this, because this is personal and if I
could figure out the syntax, I'm sure I could overwrite the keybindings
in the config myself.

But here's my case: `Ctrl+[` sends escape and I use that instead of
`Esc` because it's easier to reach (capslock is remapped to `ctrl`, so
`ctrl+[` is homerow only).

Kitty uses it's own "kittymod" combo for a lot of keybindings and for
the equivalent of these two, it uses `Ctrl+shift`. That's already taken
by other keybindings, so I added `.super` here.

Again: feel free to ignore. Personal preference. If you close this PR,
I'll have to tweak my config on Linux.
2023-07-23 14:02:39 +02:00
Thorsten Ball
a01a3fdcde gtk: remove thin, white border
The GTK app has a really thin, white border around the terminal
contents. It's really distracting when in fullscreen.

At first I thought it's the window that has a border, but turns out
that's not it. It's the GTK Notebook widget. Luckily for us, GTK4 has a
single API call that allows us to turn off the border.
2023-07-23 13:05:02 +02:00
Mitchell Hashimoto
e45c8d97d7 CSI for SGR only if there are no intermediates
Fixes #210

We were previously taking any `CSI <symbol> <data> m` as SGR. But SGR is
only if "symbol" is empty. There are other forms of `CSI m` that set the
intermediate symbol to `?` or `>` and we don't implement those. We
shouldn't treat that as a SGR attribute either.
2023-07-20 19:23:01 -07:00
Thorsten Ball
5472d03832 locale: remove default value for local dev env
I commented this out to test something locally and it compiles & runs
fine on macOS with Xcode. Looks like it's not needed anymore.
2023-07-19 06:46:01 +02:00
Thorsten Ball
4b48d42a07 locale: set LANG to the fallback value if we have invalid locale
See #201 for more information.

Problem is that while we fall back to a default value to pass to
`setlocale`, we don't set a `LANG` and instead reset it to `""`.

What this does here is it changes the resetting to `""` and instead sets
it to the default value.
2023-07-19 06:44:35 +02:00
Mitchell Hashimoto
4137c6cf69 font/shaper: do not break on merged emoji if cursor is directly on it 2023-07-18 16:38:02 -07:00
Mitchell Hashimoto
4b062dc45c font/shaper: text runs should split around block cursors
Fixes #206
2023-07-18 16:20:30 -07:00
Mitchell Hashimoto
6ae3c4b20e Merge pull request #205 from mitchellh/locale2
reset LANG env var if we set it and it is invalid
2023-07-18 10:55:06 -07:00
Mitchell Hashimoto
4176c6bdbf reset LANG env var if we set it and it is invalid
This was breaking downstream programs, see #201
2023-07-18 10:49:43 -07:00
Mitchell Hashimoto
3d48432daf renderer: change padding to integers
Screen size is always an integer, it makes sense for padding to also be
rounded to some integer.
2023-07-18 10:44:33 -07:00
Thorsten Ball
ead997b5ec Fix blurry fonts by flooring padding of surface
This fixes #99 for me.

Without this fix I end up with paddings of `3.333333` because my DPI is
`125.0` on Linux. If I set it to `144.0` manually so that the `/ 72`
gives me a clean `2.0`, the blurry fonts are gone.

I do think the calculation here is correct (even though I'm not sure
whether we should use 72? Why not 96? Or another system value?), so
let's use `std.math.floor` to get us to a "clean" padding of `3.0`.

That also solves blurry fonts for me.
2023-07-18 07:02:33 +02:00
Thorsten Ball
de5780a771 gtk: change default window size to 1000x600
The previous 200x200 looks ... weird :) But it was also quite unhandy
because I constantly have to resize new builds when I want to check
something.
2023-07-17 06:54:47 +02:00
Mitchell Hashimoto
0849aa8f20 validate locale prior to setting, fallback to en_US.UTF-8
Fixes #201

I don't fully understand locales, but it appears that the locale
returned from NSLocale can be "valid" in general but invalid according
to libc's locale API. If you attempt to `setlocale` with this bad
locale, it defaults everything to "C", which ends up breaking a lot of
things.

This commit validates the locale, and if it is invalid, we default to
"en_US.UTF-8" so things tend to work. This behavior can be overridden
using standard environment variables (LANG, LC_ALL, etc.).

This also doesn't touch env vars so further subprocesses from the shell
see original locale env vars.
2023-07-11 11:50:12 -07:00
Mitchell Hashimoto
bf25bf0a6a move a bunch of files to src/os 2023-07-10 16:48:22 -07:00
Mitchell Hashimoto
9300404603 font: block cursor was not taking full cell width 2023-07-10 11:45:35 -07:00