21 Commits

Author SHA1 Message Date
Mitchell Hashimoto
df97c19a37 macOS: "option-as-alt" defaults to "true" for US keyboard layouts
A common issue for US-centric users of a terminal is that the "option"
key on macOS is not treated as the "alt" key in the terminal.

## Background

macOS does not have an "alt" key, but instead has an "option" key. The "option"
key is used for a variety of purposes, but the troublesome behavior for some
(and expected/desired behavior for others) is that it is used to input special
characters.

For example, on a US standard layout, `option-b` inputs `∫`. This is not
a typically desired character when using a terminal and most users will
instead expect that `option-b` maps to `alt-b` for keybinding purposes
with whatever shell, TUI, editor, etc. they're using.

On non-US layouts, the "option" key is a critical modifier key for
inputting certain characters in the same way "shift" is a critical
modifier key for inputting certain characters on US layouts.

We previously tried to change the default for `macos-option-as-alt`
to `left` (so that the left option key behaves as alt) because I had the
wrong assumption that international users always used the right option
key with terminals or were used to this. But very quickly beta users
with different layouts (such as German, I believe) noted that this is
not the case and broke their idiomatic input behavior. This behavior was
therefore reverted.

## Solution

This confusing behavior happened frequently enough that I decided to
implement the more complex behavior in this commit. The new behavior is
that when a US layout is active, `macos-option-as-alt` defaults to true
if it is unset. When a non-US layout is active, `macos-option-as-alt`
defaults to false if it is unset. This happens live as users change
their keyboard layout.

**An important goal of Ghostty is to have zero-config defaults** that
satisfy the majority of users. Fiddling with configurations is -- for
most -- an annoying task and software that works well enough out of the
box is delightful. Based on surveying beta users, I believe this commit
will result in less configuration for the majority of users.

## Other Terminals

This behavior is unique amongst terminals as far as I know.
Terminal.app, Kitty, iTerm2, Alacritty (I stopped checking there) all
default to the default macOS behavior (option is option and special
characters are inputted).

All of the aforementioned terminals have a setting to change this
behavior, identical to Ghostty (or, Ghostty identical to them perhaps
since they all predate Ghostty).

I couldn't find any history where users requested the behavior of
defaulting this to something else for US based keyboards. That's
interesting since this has come up so frequently during the Ghostty
beta!
2024-12-11 10:27:08 -08:00
Mitchell Hashimoto
5c1ffbb642 apprt: implement key_sequence action 2024-10-08 21:55:00 -07:00
Mitchell Hashimoto
6a44d3196d input: yeet usingnamespace 2024-08-16 10:16:46 -07: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
Mitchell Hashimoto
87f5d6f6a8 apprt/embedded: do not depend on macOS APIs on non-macOS 2024-01-14 14:31:14 -08:00
Mitchell Hashimoto
3360a008cd build: build produces a broken object file for iOS
This gets `zig build -Dtarget=aarch64-ios` working. By "working" I mean
it produces an object file without compiler errors. However, the object
file certainly isn't useful since it uses a number of features that will
not work in the iOS sandbox.

This is just an experiment more than anything to see how hard it would be to
get libghostty working within iOS to render a terminal. Note iOS doesn't
support ptys so this wouldn't be a true on-device terminal. The
challenge right now is to just get a terminal rendering (not usable).
2024-01-13 21:38:58 -08:00
Mitchell Hashimoto
be05c3af53 input: add Link 2023-11-29 15:30:22 -08:00
Gregory Anders
0a2d435481 core: add resize_split binding with default keys
On macOS, use Cmd+Ctrl+Arrow keys as default bindings for resizing by 10
points in the given direction.
2023-11-05 20:20:39 -06:00
Mitchell Hashimoto
29bbcbbf92 core: add input binding to control terminal inspector 2023-10-24 15:27:14 -07:00
Mitchell Hashimoto
b42178bf34 input: add kitty keymap data 2023-08-16 22:08:05 -07:00
Mitchell Hashimoto
f57fd99d3e input: starting to work on KeyEncoder, got ctrl sequences 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
23f6f950b9 input: add all the mappings for pc style function keys
Not hooked up yet.
2023-08-13 14:55:31 -07:00
Mitchell Hashimoto
57f7a59168 input: rename Keymap to KeymapDarwin since its macos only for now 2023-08-11 12:02:01 -07:00
Mitchell Hashimoto
1ded176377 input: only load Keymap on darwin 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
1e1ad7deb9 macos: use the new self-hosted translation 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
3d23f26326 input, macos: initial work on keymapper and macos usage of it 2023-08-11 12:01:58 -07:00
Mitchell Hashimoto
04c38ef3b0 macos: change focus callback to use an enum so we can get other dirs 2023-03-11 17:44:00 -08:00
Mitchell Hashimoto
fa9ee0815f apprt/embedded: newSplit callback 2023-03-08 14:56:50 -08:00
Mitchell Hashimoto
9aa5378ffa Track/cache button state and mods state 2022-08-26 13:55:24 -07:00
Mitchell Hashimoto
222f70857a move input stuff to src/input 2022-08-23 19:52:14 -07:00