2615 Commits

Author SHA1 Message Date
Raiden1411
7a239835d2 core: add config option to invert fg and bg of cell when selected 2023-11-18 01:04:14 +00:00
Tim Culverhouse
caf2252144 gtk: implement desktop notifications 2023-11-17 12:59:23 -06:00
Raiden1411
e3b83249d6 core: implement select all binding 2023-11-17 18:01:39 +00:00
Krzysztof Wolicki
44a48f62f1 change unmodified vars to consts in anticipation of zig changes 2023-11-17 15:46:46 +01:00
Gregory Anders
5290070be9 clipboard: add Clipboard variant for primary clipboard
In practice, the primary and selection clipboards are treated exactly
the same, but this allows OSC 52 sequences to use either 's' or 'p' as
the clipboard target.
2023-11-16 16:35:48 -06:00
Mitchell Hashimoto
b5bf7e9d3b Merge pull request #890 from mitchellh/faint-bg
renderer: faint should not be applied to bg alpha
2023-11-15 11:41:35 -08:00
Mitchell Hashimoto
ed3e3764d9 renderer: faint should not be applied to bg alpha
Fixes #889
2023-11-15 11:38:16 -08:00
Mitchell Hashimoto
df99c6e8e0 core: comment out log statements 2023-11-15 10:57:51 -08:00
Mitchell Hashimoto
ad24e5e687 renderer/opengl: use new preedit format 2023-11-15 09:59:08 -08:00
Mitchell Hashimoto
7457b40a45 renderer/metal: handle preedit wider than our screen 2023-11-15 09:53:51 -08:00
Mitchell Hashimoto
50f0aaf26b renderer/metal: support multi-codepoint preedit text 2023-11-15 09:49:28 -08:00
Gregory Anders
689199251a core: use arrays instead of WriteReq for desktop notifications 2023-11-15 11:21:30 -06:00
Mitchell Hashimoto
4cff8d972c input: do not encode enter with utf8 as pc style key
If the enter key has utf-8 attach, we assume its a dead key state being
committed so we don't process it.
2023-11-15 08:58:12 -08:00
Gregory Anders
3f4ea2f763 core: support OSC 9 and OSC 777 for showing desktop notifications 2023-11-15 10:25:02 -06:00
Mitchell Hashimoto
83eff4e330 config: clarify that command can only be a single binary 2023-11-14 17:03:47 -08:00
Mitchell Hashimoto
822c67b3e0 termio/exec: fall back to default command if specified command not found
Fixes #880

If a command is specified but it can't be found, then we try to fallback
to a default command like "sh" and log the issue. This prevents Ghostty
from simply exiting.
2023-11-14 16:58:27 -08:00
Mitchell Hashimoto
36c3b1b3d1 apprt/gtk: gtk-adwaita runtime config to configure libadwaita
Fixes #874
2023-11-14 08:33:55 -08:00
Mitchell Hashimoto
35e78939e5 macos: ignore alt key with other modifiers set
This enables shifted alt-prefixed keys, such as `shift+alt+.` on
US standard becoming `M->`. To do this, we needed to fix a few bugs:

  (1) translation mods should strip alt even if other mods are set
  (2) AppKit translation event needs to construct new characters with
      the translation mods.
  (3) Alt-prefix handling in KeyEncoder needs to allow ASCII utf8
      translations even for macOS.
2023-11-13 19:21:51 -08:00
Mitchell Hashimoto
63e106390f input: fix failing test on Linux 2023-11-13 13:58:41 -08:00
Mitchell Hashimoto
b4d393fdcf input: process alt-prefix even if utf8 text doesn't exist 2023-11-13 13:50:00 -08:00
Mitchell Hashimoto
5001e2c60c macos: filter option in AppKit when option-as-alt set
Fixes #872

In #867 we fixed macos-option-as-alt, but unfortunately AppKit ALSO does
some translation so some behaviors were not working correctly.
Specifically, when you had macos-option-as-alt set, option+e would
properly send `esc+e` to the pty but it would ALSO set the dead key
state for "`" since AppKit was still translating the option key.

This commit introduces a function to strip alt when necessary from the
translation modifiers used at the AppKit layer, preventing this
behavior.
2023-11-13 13:26:37 -08:00
Mitchell Hashimoto
a8e82b13ce Merge pull request #868 from der-teufel-programming/win-noxdg
os/xdg: Add `LOCALAPPDATA` as a fallback for `XDG_CONFIG_HOME` on Windows
2023-11-12 22:23:00 -08:00
Mitchell Hashimoto
3192b13546 terminal: our mode size changed 2023-11-12 22:20:28 -08:00
Mitchell Hashimoto
8783f6c925 xterm audit: slow scroll (DECSCLM) 2023-11-12 22:11:11 -08:00
Mitchell Hashimoto
f00c87e805 xterm audit: DECCOLM and 132COLS 2023-11-12 22:05:26 -08:00
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
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
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
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
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
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
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
dd1faf5e50 macos: handle preedit in AppKit, enables Korean input 2023-11-10 09:53:56 -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
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