4361 Commits

Author SHA1 Message Date
Mitchell Hashimoto
1fae17d1ef input: CSIu should send full codepoint
Related to #1802

CSIu format sends a unicode codepoint but we were just sending the first
byte of the utf8 sequence, which is very much not right. This fixes that
by parsing the utf-8.

It isn't defined what to do if the utf-8 sequence is invalid or has
multiple codepoints so we just skip CSIu encoding in that case.
2024-06-02 14:38:13 -07:00
Mitchell Hashimoto
1551c27578 input: Kitty alternate should be reported even if no shifted text (#1817)
Reproduction: HU layout Ctrl+ő

On release, we were previously not sending an alt text (we were sending
it properly on press). Kitty sends it also on release and the spec makes
it clear we should send it on release. This was just due to some faulty
logic; added a test and fixed that.
2024-06-02 14:36:08 -07:00
Mitchell Hashimoto
14417d2592 Allow keybinding arbitrary unicode codepoints (#1814)
Fixes #1802 

This allows `keybind` configurations to map to any Unicode codepoint. This enables keybindings for which we don't have a registered keycode or for custom keyboard firmwares that may produce arbitrary text (but the Ghostty support is limited to a single codepoint).

The `keybind` syntax is unchanged. If a bound character doesn't map to a known logical key that Ghostty knows about, we map it to a Unicode codepoint. The unicode codepoint is compared against the _unshifted codepoint_ from the apprt key event. 

Note that this binding is to a single _codepoint_. We don't support arbitrary sequences of characters or multi-code point graphemes for keybindings due to the complexity in memory management that would introduce.

This also provides a good fallback for scenarios where it might make sense to educate Ghostty about a key code or fix a bug in our keyboard input system, but the unicode data is correct. In that scenario, unicode key binds should allow key binds to still work while we investigate the input issues.

Example:

```
shift+ö=text:hello
```

This now works as expected on a US hardware keyboard with the Hungarian keyboard layout.
2024-06-02 10:53:36 -07:00
Jon Parise
2a66d37e48 Update functional URLs for ghostty-org 2024-06-01 16:44:09 -04:00
Gregory Anders
695bc307ba os/open: do not wait for commands which do not terminate
Some opener commands (like macOS's open) finish immediately after
running, while others (xdg-open) do not, staying alive until the
application that was opened itself terminates.

For now, we explicitly state whether or not we should wait for a
command. Eventually we may want to do something more generic (e.g. wait
for some predetermined amount of time and if the process does not
complete, give up without collecting stderr).
2024-05-31 12:25:17 -05:00
ilk
e5411284dd fix(elvish-integration): fix mistakes
fix some missing imports and (shamefully) faulty logic.
2024-05-31 12:20:12 +03:00
Mitchell Hashimoto
80c0ba8758 font: when presentation isn't found, always fallback to any
Fixes #1808

When resolving a codepoint, we first attempt to find the default
presentation (if an explicit one is not given), but we were not falling
back to "any" in case that presentation was not found.
2024-05-30 14:22:42 -07:00
Mitchell Hashimoto
523f9e32cc Merge pull request #1803 from mitchellh/mixed-font
Handle mixed-color fonts
2024-05-29 08:11:33 -07:00
cryptocode
0b6081d427 scrollback: Include active area when writing scrollback to file
Writing scrollback to file is, among other usecases, an interrim solution for searching.
Status quo is to only write history pages, and not the active area. This PR proposes that
the scrollback write includes the active area, which I think is more useful. For example,
you can then do less +G <super+shift+j> if you have long log output and then page and
reverse-search through all of it. It's a bit surprising if the active area is missing.
2024-05-29 15:19:45 +02:00
Mitchell Hashimoto
d978d05d7e font/coretext: glyphIndex must return u32 for noop shaper 2024-05-28 21:05:32 -07:00
Mitchell Hashimoto
f6e708c0fb font/coretext: cleanup unused comments 2024-05-28 20:58:06 -07:00
Mitchell Hashimoto
9a628d8a8e font: remove unused structs 2024-05-28 20:56:47 -07:00
Mitchell Hashimoto
6a8dc12ae1 font: remove deferred face todo, note why 2024-05-28 20:54:05 -07:00
Mitchell Hashimoto
adaeffb2b5 font/freetype: CBDT/CBLC tables imply color 2024-05-28 20:40:46 -07:00
Mitchell Hashimoto
4daa49fe27 font/freetype: update to new presentation APIs 2024-05-28 20:25:49 -07:00
Mitchell Hashimoto
326659c522 font: handle presentation at glyph layer 2024-05-28 20:09:05 -07:00
Mitchell Hashimoto
dc6b1b0b7a font/coretext: hasColor/isColored 2024-05-28 13:20:37 -07:00
Mitchell Hashimoto
d22c645a02 font/coretext: determine glyph colorization 2024-05-28 13:04:55 -07:00
Mitchell Hashimoto
8920f45fd8 font/freetype: API to load font table 2024-05-28 09:48:01 -07:00
Mitchell Hashimoto
9f885ff64f font/opentype: add SVG table parser, membership check 2024-05-27 21:35:33 -07:00
Mitchell Hashimoto
1a7cde9e3e font/coretext: can read font tables 2024-05-27 20:23:10 -07:00
Mitchell Hashimoto
66a9b1b99f rename env var 2024-05-27 16:18:51 -07:00
Mitchell Hashimoto
982e4c9570 prettier 2024-05-27 16:16:43 -07:00
ilk
2863d2c148 refactor(shell-integration): refactor to make cases alphabetical
also fix: build errors
also fix: name mismatch (GHOSTTY_FISH_XDG_DIR -> GHOSTTY_INTEGRATION_DIR)
also refactor elvish file to evade unobvious returns
2024-05-27 16:15:13 -07:00
ilk
7377ca8917 refactor(shell-integration): refactor to make cases alphabetical
also refactors elvish file to evade unobvious returns
and tries to fix some build errors
2024-05-27 16:15:12 -07:00
ilk
1fa830cc73 feat(shell-integration): add automatic integration for Elvish
Fish automatic integration taken as an example.
Just like fish, Elvish checks `XDG_DATA_DIRS` for its modules.
Thus, Fish integration in zig is reused, and integration in
Elvish now removes `GHOSTTY_FISH_XDG_DIR` environment variable
on launch.
2024-05-27 16:15:01 -07:00
Mitchell Hashimoto
1032cdb68f Merge pull request #1772 from il-k/elvish-integration
feat(shell-integration): add integration for Elvish
2024-05-27 16:11:23 -07:00
Mitchell Hashimoto
17e7ff1de3 shell-integration: add README about Elvish 2024-05-27 16:11:08 -07:00
Mitchell Hashimoto
ded7c0abac Merge pull request #1760 from jcollie/notification-suppression
Rate limit desktop notifications
2024-05-26 20:50:19 -07:00
Mitchell Hashimoto
98b05ffd09 core: nitpick some var names 2024-05-26 20:49:00 -07:00
Mitchell Hashimoto
9f4d4d3c61 font: treated fonts with mixed color/non-color glyphs as text
Related to #1768 but doesn't fix it properly.

This is a temporary hack to avoid some issues with fonts that have mixed
color/non-color glyphs. If there are mixed presentations and the font
does not have emoji codepoints, then we assume it is text. This fixes
the typical scenarios.

This is not a long term solution. A proper long term solution is to
detect this scenario and on a per-glyph basis handle colorization (or
the lack thereof) correctly. It looks like to do this we'll have to
parse some font tables which is considerably more work so I wanted to do
this first.
2024-05-26 10:17:20 -07:00
Mitchell Hashimoto
e427312282 modify var name 2024-05-26 09:28:16 -07:00
Peter Cardenas
e56acef775 🧹 make strikethrough calculation slightly clearer
followup to https://github.com/mitchellh/ghostty/pull/1796
the sources of the strikethrough calculation are made more explicit
here: the ascent and the subtraction of the leading
2024-05-26 01:44:26 -07:00
Mitchell Hashimoto
bc99082242 font/coretext: adjust strikethrough position for fonts with leading
Fixes #1795

This only affected CoreText. When testing with Freetype the
strikethroughs looked correct for fonts with and without leading
metrics.

This commit adjusts our strikethrough position for fonts that have a
leading metric set to better center it. Previously, we centered the
position _including_ the leading value. The leading value is blank, so
we must center it excluding that value.
2024-05-25 15:20:16 -07:00
Mitchell Hashimoto
41afb62903 very minor nitpicks 2024-05-25 14:19:23 -07:00
Jan200101
94a7166028 terminal: support using the bright palette for bold text 2024-05-25 16:58:19 +02:00
Mitchell Hashimoto
06bcbe868f renderer: kitty image with y offset should stretch image
Fixes #1784

This was just a misunderstanding of the "spec." When both a y offset
into the image is specified and a height, the image should be stretched.
I mistakingly thought that the image should be offset (even with this
misunderstanding there was a data corruption bug).

This resolves the issue and output matches Kitty.
2024-05-22 15:40:31 -04:00
Mitchell Hashimoto
1e60f7186c os: some stylistic changes, comments for stderr logging 2024-05-20 19:11:30 -04:00
Gregory Anders
e710a59a43 os: log stderr from open command 2024-05-19 09:00:53 -05:00
Mitchell Hashimoto
d7c64f57b1 font/shaper: periodically reset LRU in cache to avoid slowdown
See: https://github.com/ziglang/zig/issues/17851

Users were noticing that frame render times got slower over time. I
believe (thanks to community for pointing it out) that this is the
culprit.

This works around this issue by clearing and reinitializing the LRU
after a certain number of evictions. When the Zig issue has a better
resolution (either rehash() as a workaround or a better hash
implementation overall) we can change this.
2024-05-18 10:06:41 -04:00
Jeffrey C. Ollie
7c893881c3 Address review comments
1. Switch to using Wyhash instead of a cryptographic hash.
2. Move global variables to App struct.
2024-05-17 17:13:43 -05:00
Mitchell Hashimoto
bc29076f07 Merge pull request #1765 from jparise/bash-command-option
shell-integration: handle 'bash -c command'
2024-05-17 17:08:44 -04:00
Mitchell Hashimoto
add8c9b2c6 Merge pull request #1761 from qwerasd205/fix-link-highlight
fix(renderer/Metal): dirty track link highlights
2024-05-17 16:47:09 -04:00
Mitchell Hashimoto
6307162e49 small comment changes 2024-05-17 16:46:30 -04:00
ilk
a1a97913d3 refactor(shell-integration:elvish): refactor to improve readability 2024-05-17 18:11:00 +03:00
ilk
597328432c feat(shell-integration): add integration for Elvish
- contains `.elv` file that implements the core of Elvish integration.
- does not contain routines needed for automatic integration.
- stored in `./elvish/lib/...` in preparation for automatic integration:
  Elvish imports `.../elvish/lib/*.elv`.

checklist:
- no confirmation on close where the cursor is at prompt:
  works, only occasionally doesn't, I'm not yet sure when.
- new terminals start in pwd of previously focused terminal: works
- prompts resize correctly: works
- triple-click while holding `ctrl` selects output of a command:
  works (when mouse is over the output)
- cursor at the prompt is turned into a bar: works
- ghostty:`jump_to_prompt` scrolls through prompts: works
- `opt`-click moves cursor at the prompt: works
- `sudo` preserves ghostty terminfo:
   untested - not sure when this is needed exactly, but did not encounter
   any errors after sudo, either
2024-05-16 20:45:14 +03:00
Mitchell Hashimoto
cbcb4b27bc Merge pull request #1766 from jparise/bash-readme
shell-integration: update Bash integration details
2024-05-14 18:22:16 -04:00
Jon Parise
d5414d50ea shell-integration: update Bash integration details 2024-05-14 15:06:05 -07:00
Jon Parise
016c58cfe4 shell-integration: handle 'bash -c command'
When the -c option is present, then commands are read from the first
non-option argument command string. Our simple implementation assumes
that if we see at least the '-c' option, a command string was given, and
the shell is always considered to be non-interactive - even if the '-i'
(interactive) option is also given.
2024-05-14 11:01:49 -07:00
Jon Parise
11f3400e49 shell-integration: suppress shellcheck issues 2024-05-14 06:57:02 -07:00