220 Commits

Author SHA1 Message Date
Mitchell Hashimoto
6a44d3196d input: yeet usingnamespace 2024-08-16 10:16:46 -07:00
Mitchell Hashimoto
64c267a8c7 Merge pull request #2052 from rockorager/pretty-print
cli/list-keybinds: add pretty printing
2024-08-06 14:53:15 -07:00
Tim Culverhouse
59e226154c cli/list-keybinds: add pretty printing
Add pretty printing to the +list-keybinds command. This is done by
bringing in a dependency on libvaxis to handle the styling. Pretty
printing happens automatically when printing to a tty, and can be
disabled either by redirecting output or using the flag `--plain`
2024-08-06 12:19:39 -05:00
Łukasz Niemier
f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Mitchell Hashimoto
a75ee29f2d Merge pull request #1981 from injust/adjust-line
Add `adjust_selection` actions for `beginning_of_line` and `end_of_line`
2024-07-22 09:40:45 -07:00
multifred
72c672adb7 Fix multiple deprecated names for zig lib/std 2024-07-22 00:07:17 +02:00
Justin Su
97bd46de7f Add adjust_selection actions for beginning_of_line and end_of_line 2024-07-20 23:06:47 -04:00
Mitchell Hashimoto
a62b76eda3 core: add binding to write screen to file 2024-07-19 20:24:51 -07:00
Mitchell Hashimoto
55657465a7 add write_selection_file
Based on the work by @gigamaax
2024-07-19 20:20:49 -07:00
Mitchell Hashimoto
e3df08039a some bikeshedding 2024-07-19 20:03:20 -07:00
karei
6fde429728 core: support opening scrollback file in default text editor 2024-07-19 19:56:00 -07:00
Mitchell Hashimoto
72c0f9dd32 adjust selection 2024-07-19 14:20:28 -07:00
Mitchell Hashimoto
72d8af5d0b rename to expand_selection 2024-07-19 14:19:21 -07:00
Cameron Dart
cdeeeb9f88 feat: keybinds for text selection on copy mode 2024-07-19 14:08:52 -07:00
Mitchell Hashimoto
2d7baaa7d7 apprt/gtk: toggle_window_decorations keybinding
Fixes #1943
2024-07-15 21:23:52 -07:00
Mitchell Hashimoto
f8fe0445a5 core: clicking OSC8 links work 2024-07-05 21:40:39 -07:00
Mitchell Hashimoto
6faeb9ba40 core: mouse pressure state and callbacks 2024-06-29 10:42:45 -05:00
Gordon Cassie
c967a35abb Fix some basic build errors. 2024-06-24 15:16:24 -07:00
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
Qwerasd
d4a7549222 feat(font): Non-integer point sizes
Allows for high dpi displays to get odd numbered pixel sizes, for
example, 13.5pt @ 2px/pt for 27px font. This implementation performs
all the sizing calculations with f32, rounding to the nearest pixel
size when it comes to rendering. In the future this can be enhanced
by adding fractional scaling to support fractional pixel sizes.
2024-05-09 00:03:40 -04:00
Mitchell Hashimoto
8dbedeb76c fix breaking changes with latest zig 2024-04-17 20:50:50 -07:00
Mitchell Hashimoto
fc4284e406 input: Key.Side needs a specific backing int for use in packed 2024-04-17 20:50:50 -07:00
Mitchell Hashimoto
026484fea6 fix more comptime var leaks 2024-04-17 20:50:50 -07:00
rok
df9b8f1fbc input: fix bs emitting sequence when it should not
In korean input method on macos, it should simply return empty string.
Issue was created after https://github.com/mitchellh/ghostty/pull/1659.

```
gksr<BS> # 한ㄱ<BS>
```

'ㄱ' at the end should be removed with single <BS>, but for now
it requires two <bs> to remove 'ㄱ'.
2024-04-08 22:11:01 +09:00
Mitchell Hashimoto
91ba47af1f input: add test for backspace change 2024-04-05 08:25:14 -07:00
rok
51bfde69ba input: do not emit sequence on <BS> when their's UTF-8 text 2024-04-05 19:55:17 +09:00
Mitchell Hashimoto
0bd673435f input: add test for esc clearing dead key state 2024-04-04 21:57:32 -07:00
rok
9326ae363c input: escape can be used to clear dead key state
This fixes korean input method issue on mac. When typing korean
and press escape in vim, composing korean character should remain.
2024-04-05 03:17:39 +09:00
Mitchell Hashimoto
461b16ce34 font sizes are limited to u8 (max size = 255 points)
Fixes #1618

Font sizes in configuration were always a u8, but the keybinding and
internal state was a u16 so it allowed for an ever-growing font size. At
a certain point, there is an integer overflow which causes it to wrap
around. This is all silly, 255 should be large enough for anyone[1]

[1]: Ready to be super wrong about this
2024-03-27 20:36:59 -07:00
Gregory Anders
c634ba363a input: fix associated text on macOS
Ghostty does not report associated text on macOS when
macos-option-as-alt is enabled for _any_ key press, whether or not the
Alt modifier is actually present. The "option as alt" decision should
only be made when the alt modifier is present.
2024-03-25 13:43:32 -05:00
ProfOak
96daf97d19 Add keybind support for shift+insert selection paste 2024-02-21 19:33:05 -06:00
Gregory Anders
cff9671bdf Omit release events for backspace, enter, and tab if report_all is unset 2024-02-18 09:43:05 -06:00
Mitchell Hashimoto
1170cee550 input: encode ctrl+shift+<ascii letter> in CSIu as lowercase + shift
This follows a specific behavior Kitty has, but no other terminal seems
to have, but it is a reasonable behavior that is in use by real programs
as found by our beta testing community.

We diverge from Kitty though in that we only apply this to ASCII
letters. Kitty does not CSIu encode special characters like `@` or `$`.
For these characters, Ghostty still encodes it as specified by fixterms.
2024-02-17 13:45:49 -08:00
Mitchell Hashimoto
4a6ba59f73 input: send shifted uppercase ASCII letters as CSIu
Related to #1507

The comments in this change have most of the detail. The primary gist:

  - caps-lock is handled correctly so #1501 is still fixed
  - only characters pressed with the shift key are affected
2024-02-17 08:39:27 -08:00
Mitchell Hashimoto
2f36fd4b5f input: ctrl ASCII uppercase behaves the same as ctrl lowercase
Fixes #1505

I verified this behavior with every other terminal and I've added test
cases for it. We previously had a test case to assert the opposite,
which is incorrect.
2024-02-11 14:28:53 -08:00
Mitchell Hashimoto
f414787779 move SplitDirection to apprt 2024-02-04 20:42:42 -08:00
Tim Culverhouse
1824a0fe87 split: add auto as split option
Add an `auto` split direction which splits along the larger direction.
2024-02-04 21:28:17 -06:00
Erlend Lind Madsen
4475f5b9c5 url/Link: simplify regex, remove 'find_longest' param and add new tests 2024-02-02 01:23:39 +01:00
Mitchell Hashimoto
88e7c96eac Merge pull request #1431 from mitchellh/mouse-mods-alt
core: handle mouse capture events with link highlighting
2024-02-01 09:20:04 -08:00
Mitchell Hashimoto
6de4533afb core: handle mouse capture events with link highlighting
Fixes #1416

At a high level, the issue is that when mouse capture is enabled (i.e. in
neovim), "shift" escapes the capture. So "cmd+shift" is equal to "cmd"
which doesn't get sent to the TUI program and so on. For link
highlighting which now requires "cmd" (super) is held, we were sending
"cmd+shift" to the renderer so we weren't checking for links.

So the core of this commit is respecting this scenario and stripping the
shift modifier.

This commit also found that when the mouse wasn't over a link, we were
always checking and highlighting links on line one of the visible
screen. This bug is fixed and should also result in a very slight
performance improvement on rendering in all cases.
2024-02-01 09:19:39 -08:00
Mitchell Hashimoto
eafc9559d7 core: add "reset" keybinding to reset the terminal
Fixes #1425
2024-02-01 08:46:39 -08:00
Mitchell Hashimoto
f65989fd92 Merge pull request #1387 from mattrobenolt/cmd-click
Open links with Super+click
2024-01-27 21:04:51 -08:00
Mitchell Hashimoto
3efe88c85c input: add link highlight always/hover w/ mods 2024-01-27 19:07:49 -08:00
Mitchell Hashimoto
ae11cc9042 add a new highlight state that requires modifiers 2024-01-27 19:03:03 -08:00
Mitchell Hashimoto
0726a8d1fa apprt/embedded: ctrl-only should use binding-mods only
This allows it to ignore control side differences.
2024-01-27 11:15:54 -08:00
Mitchell Hashimoto
bf4211e060 input: handle more ctrl+<key> sequences, namely ctrl+_
Previously, we encoded `ctrl+_` in the CSIu format[1]. This breaks most
notably emacs which expects the legacy ambiguous encoding.

This commit utilizes the generator from Kitty to generate our control
key mappings. We also switch from keycode mapping to key contents
mapping which appears to be the correct behavior also compared to other
terminals.

In the course of doing this, I also found one bug with our fixterms
implementation. Fixterms states: "The Shift key should not be considered
as a modifier for Unicode characters, because it is most likely used to
obtain the character in the first place (e.g. the shift key is often
required to obtain the ! symbol)." We were not applying that logic and
now do.

[1]: https://www.leonerd.org.uk/hacks/fixterms/
2024-01-25 15:25:23 -08:00
gabydd
6f04bd4a79 don't write ":" when printing keybinding action with no argument 2024-01-22 21:01:16 -05:00
Aurélien Cibrario
509be969af Added plus + key 2024-01-21 21:09:24 -08:00