3686 Commits

Author SHA1 Message Date
Krzysztof Wolicki
0822e99a56 os/xdg: Add LOCALAPPDATA as a fallback for XDG_CONFIG_HOME on Windows 2023-11-13 02:05:29 +01:00
Mitchell Hashimoto
8d0404066f Merge pull request #867 from mitchellh/option-as-alt
macos-option-as-alt works again
2023-11-12 15:31:28 -08:00
Mitchell Hashimoto
86fbc6a85b macos-option-as-alt works again
This regressed sometime -- I can't find the exact commit -- but in any
case I've moved this handling directly into the KeyEncoder so we can
unit test it and prevent future regressions.
2023-11-12 15:26:55 -08:00
Mitchell Hashimoto
cfdd99691f Merge pull request #866 from mitchellh/termio-deadlock
termio: Fix deadlock when writer mailbox is full
2023-11-12 09:11:58 -08:00
Mitchell Hashimoto
c8ffc903be termio: Fix deadlock when writer mailbox is full
Fixes #865
Related to #861

In #861, we fixed a deadlock that could happen if the writer mailbox was
full from the reader thread by waking up the writer thread for
processing.

Unfortunately, the writer thread ALSO handles messages that require the
terminal lock (i.e. resizing, focus state, etc.). If the mailbox
contains these messages, it cannot make forward progress on the writes
(which do not require a lock). This makes it possible still under heavy
write scenarios to fully deadlock the read/write threads.

This commit modifies the behavior so that while we are attempting to
queue a writer message after it fails, we release the lock. This is a
very slow path since we are releasing/acquiring locks under heavy
contention. We can improve it in the future but for now its okay because
this is also a rare situation that only happens under the heaviest loads
that also produce heavy writes.
2023-11-12 09:09:39 -08:00
Mitchell Hashimoto
b3dd07a496 Merge pull request #864 from mitchellh/select-word
core: Fix various double-click word selection bugs
2023-11-11 23:04:14 -08:00
Mitchell Hashimoto
af6cc66369 core: Fix various double-click word selection bugs
Fixes #741

This completely reimplements double-click-and-drag logic for selecting
by word. The previous implementation was horribly broken. See #741 for
all the details.

The implemented logic now is:

* A double-click initiates a select-by-word selection mechanism.
  - A double-click may start on a word or whitespace
  - If the initial double-click is on a word, that word is immediately selected.
  - If the initial double-click is on whitespace, the whitespace is not selected.
* A "word" is determined by a non-boundary character meeting a boundary character.
  - A boundary character is `NUL` ` ` (space) `\t` `'` `"`
  - This list is somewhat arbitrary to make the terminal "feel" good.
  - Cell SGR states (fg/bg, bold, italic, etc.) have no effect on boundary determination or selection logic.
* As the user drags _on the same line_:
  - No selection change occurs until the cursor is over a new word. Whitespace change does nothing.
  - When selection is over a new word, that entire word added to the selection.
* When the user drags _up_ one or more lines:
  - If the cursor is over whitespace, all lines from the selection point up to but not including the cursor line are selected.
    * This selection is done in accordance to the previous rules.
  - If the cursor is over a word, the word becomes the beginning of the selection.
  - The end of the selection in all cases is the first word at or before the initial double-click point.
* When the user drags _down_ one or more lines:
  - The same logic as _up_ but swap the "beginning" and "end" of selection terminology.
* With this logic, the behavior of Ghostty has the following invariants:
  - Whitespace is never selected unless it is between two selected words
  - Selection implies at least one word is highlighted
  - The initial double-click point marks the beginning or end of a selection, never the middle.
2023-11-11 22:45:31 -08:00
Mitchell Hashimoto
d0a5faf57d Merge pull request #857 from gpanders/osc52-prompt
Implement user prompts for accessing clipboard via OSC 52
2023-11-11 15:16:12 -08:00
Mitchell Hashimoto
2489ef4c13 stylistic tweaks 2023-11-11 15:15:52 -08:00
Gregory Anders
e7bc9958da Prefer explicit type syntax over @as 2023-11-11 17:26:59 -05:00
Gregory Anders
06cdbc1a96 config: export ClipboardAccess 2023-11-11 17:25:48 -05:00
Gregory Anders
593cfa256c glfw: fix compile error 2023-11-11 17:21:10 -05:00
Mitchell Hashimoto
eab35d0164 Merge pull request #862 from mitchellh/mrn/macos-menubar-non-native
macOS: only unhide menu in non-native FS if focus lost to Ghostty
2023-11-11 09:48:13 -08:00
Thorsten Ball
ae9d7fc76a macOS: only unhide manu in non-native FS if focus lost to Ghostty
This fixes #786 by adding a check to the callback that unhides the menu
bar to only unhide the menu bar if focus was lost to another Ghostty
window.

That's the desired behaviour: when focus is lost to another app's
window, we want the non-native-fullscreen window to stay unchanged in
background, but when changing focus to another Ghostty window, we want
to unhide the menu bar.

Why did this problem even show up?

It started to show up with the introduction of the Xib-file based
approach, in 3018377.

Before that, in 27ddc90, for example, the app would receive the same
notifications, but the `.autoHideMenuBar` didn't have an effect on the
window. Only after adding the Xib-file did it start to have an effect.

So I figured there's two ways we could fix it:

1. Figure out why the `.autoHideMenuBar` now works with Xib-files and
   suppress it, or
2. Encode in the code the behaviour that we actually want: we only want
   to show the menu bar when focus shifts to another one of Ghostty's
   windows, but we want to leave it untouched when focus is lost to
   another app's window.

I went with (2) but I think (1) is also valid and happy to close PR if
that's what we want to do.
2023-11-11 07:41:12 +01:00
Mitchell Hashimoto
9a45bde44e Merge pull request #861 from mitchellh/writer-block
termio: wake up writer thread if the writer mailbox is full
2023-11-10 22:06:35 -08:00
Mitchell Hashimoto
8fcdd56496 Merge pull request #860 from mitchellh/ct-leading
font/coretext: ignore typographic leading when calculating cell height
2023-11-10 22:04:17 -08:00
Mitchell Hashimoto
bde9b02db3 termio: wake up writer thread if the writer mailbox is full
Normally, we queue all the writes we need from a single `read()` syscall
and only wake up the writer thread at the end of processing that batch
of data.

But under very heavy load or large batches of data, it is possible for the
terminal sequences to generate enough writes to the pty to fill the
writer thread queue while we're still processing the data from `read()`.

This modifies our queuer to attempt to queue, but if the queue is full
we wake up the writer thread immediately then queue again (which should
succeed in every case -- eventually).
2023-11-10 22:01:07 -08:00
Mitchell Hashimoto
947ebc0697 font/coretext: split typographic leading equally when calculating cell height
This maybe is a robust way to get Monaspace fonts working.

Previously, we used leading as part of the calculation in cell height. I
don't remember why. It appears most popular monospace fonts (Fira Code,
Berkeley Mono, JetBrains Mono, Monaco are the few I tested) have a value
of 0 for leading, so this has no effect. But some fonts like Monaspace
have a non-zero (positive) value, resulting in overly large cell
heights.

The issue is that we simply add leading to the height, without modifying
ascent. Normally this is what you want (normal typesetting) but for
terminals, we're trying to set text centered vertically in equally
spaced grid cells. For this, we want to split the leading between the
top and bottom.
2023-11-10 21:41:49 -08:00
Gregory Anders
98b43007a0 core: use ClipboardRequestType instead of ClipboardPromptReason
Instead of making a separate enum that must be translated from the
ClipboardRequest type, simply re-use ClipboardRequest to determine the
clipboard confirmation reason.
2023-11-10 23:12:39 -05:00
Gregory Anders
2a64180ebd config: rename ClipboardRequest to ClipboardAccess 2023-11-10 23:12:39 -05:00
Gregory Anders
9d3385703d gtk: fix memory leak in GTK clipboard confirmation window 2023-11-10 23:12:39 -05:00
Gregory Anders
960a1bb091 gtk: implement OSC 52 prompts 2023-11-10 23:12:39 -05:00
Gregory Anders
86245ff0cf macos: add option to prompt user for confirmation on OSC 52 commands 2023-11-10 23:12:39 -05:00
Mitchell Hashimoto
ace5693957 Merge pull request #859 from mitchellh/physical-tab
config: default goto_tab bindings on darwin based on physical key
2023-11-10 17:37:44 -08:00
Mitchell Hashimoto
e32b955c65 Merge pull request #858 from mitchellh/wide-preedit
core, renderer: handle wide preedit chars
2023-11-10 17:37:35 -08:00
Mitchell Hashimoto
725e017234 config: default goto_tab bindings on darwin based on physical key
Fixes #817
2023-11-10 17:36:39 -08:00
Mitchell Hashimoto
5c8c4bb06e renderer/opengl: handle wide preedit 2023-11-10 17:30:14 -08:00
Mitchell Hashimoto
ce4541dd61 core, renderer: handle wide preedit chars
Fixes #855
2023-11-10 17:26:36 -08:00
Mitchell Hashimoto
a8614815d6 Merge pull request #856 from mitchellh/asian-input
macos: handle preedit in AppKit, enables Korean input
2023-11-10 10:08:34 -08:00
Mitchell Hashimoto
dd1faf5e50 macos: handle preedit in AppKit, enables Korean input 2023-11-10 09:53:56 -08:00
Mitchell Hashimoto
9be9f11586 Merge pull request #854 from rockorager/palette-fix
terminal: initialize active palette with configured palette
2023-11-10 06:42:22 -08:00
Tim Culverhouse
2525382b27 terminal: initialize active palette with configured palette
PR #850 introduced several color palette OSC setting and querying
sequencing. In doing so, an active palette was introduced to enable
resetting back to the default (configured) palette. The active palette
was not initialized with the configured palette, thus any configured
theme by the terminal was not set at launch.

This behavior can be confirmed thanks to PR #852, which resets the
active palette on configuration reload. To observe the behavior:

1. Set the configured palette to something other than the default
2. Open ghostty. Observe the color palette
3. Reload the configuration
4. Press enter for a new shell prompt. Note the palette has changed

This patch sets the configured palette as the active palette at
initialization.
2023-11-10 08:08:49 -06:00
Mitchell Hashimoto
5514d0a0c2 Merge pull request #852 from gpanders/palette-reset
core: update active palette on config reload
2023-11-09 17:18:58 -08:00
Gregory Anders
998d7668e9 core: update active palette on config reload
When the config is changed, update the active palette in addition to the
default palette, but only those colors which have not been changed with
OSC 4.
2023-11-09 19:06:58 -06:00
Mitchell Hashimoto
db868df50c Merge pull request #841 from pjz/cfgpath
config: make config-file names resolve relative to the config dir
2023-11-09 16:55:37 -08:00
Mitchell Hashimoto
a9761728e9 config: comments 2023-11-09 16:52:57 -08:00
Mitchell Hashimoto
85fea9d5ee config: resolve file paths relative to their loaded file 2023-11-09 15:53:15 -08:00
Mitchell Hashimoto
61f37e5049 Merge pull request #850 from gpanders/osc4
Fully implement OSC 4, 10, 11, 12, 104, 110, 111, and 112
2023-11-09 15:16:08 -08:00
Mitchell Hashimoto
53a5734d09 terminal: change mask from u256 to StaticBitSet 2023-11-09 15:14:33 -08:00
Mitchell Hashimoto
64eb8c0d0f Merge pull request #835 from Raiden1411/feat/glfw
glfw: add `fullscreen` and `toggleFullscreen` support
2023-11-09 15:00:33 -08:00
Mitchell Hashimoto
126f02187a apprt/glfw: minor stylistic things 2023-11-09 15:00:16 -08:00
Gregory Anders
171292a063 core: implement OSC 12 and OSC 112 to query/set/reset cursor color 2023-11-09 16:21:07 -06:00
Gregory Anders
33753f59c8 core: implement OSC 104, 110, and 111 to reset colors 2023-11-09 16:17:21 -06:00
Gregory Anders
1c0b79c40f core: separate default colors from modifiable colors
Default colors are those set by the user in the config file, or an
actual default value if unset. The actual colors are modifiable and can
be changed using the OSC 4, 10, and 11 sequences.
2023-11-09 14:08:14 -06:00
Gregory Anders
49feaedef6 core: move color parsing functions into RGB namespace 2023-11-09 14:06:06 -06:00
Mitchell Hashimoto
c2086c4d18 Merge pull request #851 from mitchellh/gtk-tab-width
apprt/gtk: ensure equal tab width, truncate with ellipses
2023-11-09 11:16:04 -08:00
Mitchell Hashimoto
8c59d1176e apprt/gtk: ensure equal tab width, truncate with ellipses
Fixes #607
2023-11-09 11:12:55 -08:00
Mitchell Hashimoto
a4ca581219 font: load valid union field for loaded deferred fonts 2023-11-09 11:06:58 -08:00
Gregory Anders
006e93bd08 core: implement setting colors with OSC 4, 10, and 11 2023-11-09 11:59:20 -06:00
Gregory Anders
3b7e21df26 termio: update foreground and background color on config change 2023-11-09 11:49:16 -06:00