5817 Commits

Author SHA1 Message Date
Tristan Partin
06ba06cfd0 apprt/gtk: unify tooltip text with AdwTabButton
AdwTabButton uses "View Open Tabs."

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-14 12:40:11 -06:00
Tristan Partin
73bb2bb9bc apprt/gtk: add gtk-tabs-location=hidden
This is only supported on libadwaita. Instead of the normal tab overview
button, we will use an AdwTabButton[0].

Link: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.TabButton.html [0]
Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-14 12:40:11 -06:00
Anund
fddc880941 bash: add bash completion generation
closes #2053
2024-12-15 02:37:12 +11:00
Anund
5195042f96 zsh: add -e completion, fix incorrectly copied sed expression
skip +version +help to keep completions the same across bash/zsh/fish
2024-12-15 02:06:16 +11:00
Anund
71aec52b8c fish: raise eval quota inline with other completions, add -e 2024-12-15 01:28:52 +11:00
Qwerasd
60b554c0a8 build: increase zsh completion gen eval branch quota
Exceeded due to a larger config struct
2024-12-13 15:44:01 -05:00
Qwerasd
d48c6fc885 config: add adjust keys for new font metrics 2024-12-13 15:36:13 -05:00
Qwerasd
4573890f22 font: fix sign of usWinDescent interpretation 2024-12-13 13:14:49 -05:00
Qwerasd
8a5d484729 font: more robust extraction of vertical metrics from tables
Previously always assuming the typo metrics were good caused some fonts
to have abnormally short cell heights.
2024-12-13 13:00:03 -05:00
Qwerasd
13dd4bd897 font/sprite: separate out cursor rendering from Box
(Fixes width handling when hovering wide chars)
2024-12-13 12:16:15 -05:00
Mitchell Hashimoto
fa72646e96 Unified font metrics (#2948)
This is a big one, I kind of over scoped a touch. I don't have it in me
to do a clean-up pass on this code before PR-ing it, so apologies for
any weirdness; I'll happily resolve any feedback, but trying to review
my own code right now is not something my brain wants to do.

#### Summary
- Font metric calculations reworked to be based primarily on data from
font tables, and now the majority of the logic is shared between
CoreText and FreeType, and we have more control over the specifics.
- Sprite font metrics for the position and thickness of underlines,
strikethroughs, and overlines are now separate, as well as box drawing
thickness, allowing for individual adjustments.
- Minimums are applied to font metrics to avoid *completely* broken
results from fonts with degenerate values in them.

### Unified Metrics Calculations
I added a solid foundation for parsing as many SFNT font tables as we
need, and added parsing for `head`, `hhea` (unused), `post`, and `OS/2`.
I didn't make a strong effort to account for variable fonts, so if a
variable font changes vertical metrics significantly it could cause
issues -- luckily, width, which is the most likely metric to change, is
not a problem, since we get the width by having our backends measure the
advances for us, which does account for variations correctly.

### Separated Sprite Metrics
I reworked the sprite renderer to just get a copy of the metrics that it
can use directly, instead of being given its own metrics (width, height,
thickness) -- so that the different thickness metrics can be used for
their intended purposes, and so that offsets for "unadjusted" characters
can be handled in the Box renderer itself.

### Minimums
Prevent degenerate fonts and bad `adjust` configs from creating, e.g.
zero-thickness underlines by applying a minimum to certain fields after
calculating metrics and after applying modifiers.

### Misc.
Fixed `init` for CoreText faces selecting the first predefined instance
of a variable font rather than the default.
2024-12-12 21:02:09 -08:00
Mitchell Hashimoto
b7dc767237 face: add more RLS types and explicit error sets 2024-12-12 19:47:58 -08:00
Qwerasd
586a7e517e font(freetype): actually take max ascii width instead of first 2024-12-12 21:30:01 -05:00
Qwerasd
f54379aacd font(Box/cursors): properly account for un-adjusted height 2024-12-12 21:04:30 -05:00
Qwerasd
0a29b78a6c clarify naming convention 2024-12-12 20:38:26 -05:00
Mitchell Hashimoto
ddb51122d0 Preserve ZSH options in the shell integration (#2950)
This fixes the #2847. There were two problems:
1. Documentation made it easy to use the bash example as a template for
calling other integrations
2. f the ZSH integration script is called the same way as for bash, it
would clobber the options

This PR fixes both. Now the ZSH script can be simply called with
`source`.

Here is why the options were clobbered, and how the method of calling
affected it:

The `-L` flag (local scope) ensures that the emulation mode only applies
to the current function scope. When the function ends, the shell reverts
to its previous state. When called outside of a function, the flags
persist even after the script execution ends.

The recommended way of calling the ZSH integration included `autoload
-Uz` that created a function with the integration script as its body.
When called directly, the assumptions about being in the function body
broke.

This PR moves a lot of code into a function, so it's best to review with
whitespace ignored in the diff.
2024-12-12 16:44:56 -08:00
Mitchell Hashimoto
6f01dbf792 Select boundary dollar (#2938)
Proposed fix for #2933
2024-12-12 16:30:19 -08:00
Mitchell Hashimoto
e5e090deaf test: big perf win by pausing integ checks while growing pages (#2956)
In multiple tests we create 1 or more pages by growing them 1 row at a
time, which results in an integrity check of the page for each row grown
which is just... horrible. By simply pausing integrity checks while
growing these pages (since growing them is not the point of the test) we
MASSIVELY speed up all of these tests.

Also reduced grapheme bytes during testing and made the Terminal "glitch
text" test actually assert what it intends to achieve, rather than just
blindly assuming 100 copies of the text will be the right amount -- this
lets us stop a lot earlier, making it take practically no time.
2024-12-12 16:12:22 -08:00
Mitchell Hashimoto
b47f36c444 Fix typo in config documentation (#2936)
them -> theme
2024-12-12 16:09:31 -08:00
Borys Lykah
2d26965f39 Fix style warning 2024-12-12 16:54:01 -07:00
Qwerasd
10abeba414 test: big perf win by pausing integ checks while growing pages
In multiple tests we create 1 or more pages by growing them 1 row at a
time, which results in an integrity check of the page for each row grown
which is just... horrible. By simply pausing integrity checks while
growing these pages (since growing them is not the point of the test) we
MASSIVELY speed up all of these tests.

Also reduced grapheme bytes during testing and made the Terminal "glitch
text" test actually assert what it intends to achieve, rather than just
blindly assuming 100 copies of the text will be the right amount -- this
lets us stop a lot earlier, making it take practically no time.
2024-12-12 16:58:48 -05:00
Mitchell Hashimoto
c1a6319490 unicode: emoji modifier requires emoji modifier base preceding to not… (#2954)
… break

Fixes #2941

This fixes the rendering of the text below. For those that can't see it,
it is the following in UTF-32: `0x22 0x1F3FF 0x22`.

```
"🏿"
```

`0x1F3FF` is the Fitzpatrick modifier for dark skin tone. It has the
Unicode property `Emoji_Modifier`. Emoji modifiers are defined in UTS
#51 and are only valid based on ED-13:

```
emoji_modifier_sequence := emoji_modifier_base emoji_modifier
emoji_modifier_base := \p{Emoji_Modifier_Base}
emoji_modifier := \p{Emoji_Modifier}
```

Additional quote from UTS #51:

> To have an effect on an emoji, an emoji modifier must immediately
follow
> that base emoji character. Emoji presentation selectors are neither
needed
> nor recommended for emoji characters when they are followed by emoji
> modifiers, and should not be used in newly generated emoji modifier
> sequences; the emoji modifier automatically implies the emoji
presentation
> style.

Our precomputed grapheme break table was mistakingly not following this
rule. This commit fixes that by adding a check for that every
`Emoji_Modifier` character must be preceded by an `Emoji_Modifier_Base`.
This only has a cost during compilation (table generation). The runtime
cost is identical; the table size didn't increase since we had leftover
bits we could use.
2024-12-12 13:05:59 -08:00
Mitchell Hashimoto
fd1201323e unicode: emoji modifier requires emoji modifier base preceding to not break
Fixes #2941

This fixes the rendering of the text below. For those that can't see it,
it is the following in UTF-32: `0x22 0x1F3FF 0x22`.

```
"🏿"
```

`0x1F3FF` is the Fitzpatrick modifier for dark skin tone. It has the
Unicode property `Emoji_Modifier`. Emoji modifiers are defined in UTS
#51 and are only valid based on ED-13:

```
emoji_modifier_sequence := emoji_modifier_base emoji_modifier
emoji_modifier_base := \p{Emoji_Modifier_Base}
emoji_modifier := \p{Emoji_Modifier}
```

Additional quote from UTS #51:

> To have an effect on an emoji, an emoji modifier must immediately follow
> that base emoji character. Emoji presentation selectors are neither needed
> nor recommended for emoji characters when they are followed by emoji
> modifiers, and should not be used in newly generated emoji modifier
> sequences; the emoji modifier automatically implies the emoji presentation
> style.

Our precomputed grapheme break table was mistakingly not following this
rule. This commit fixes that by adding a check for that every
`Emoji_Modifier` character must be preceded by an `Emoji_Modifier_Base`.
This only has a cost during compilation (table generation). The runtime
cost is identical; the table size didn't increase since we had leftover
bits we could use.
2024-12-12 12:53:08 -08:00
Qwerasd
536ed60db1 fix(kittygfx): load & display command shouldn't respond to i=0,I=0
Load and display (`T`) was responding even with implicit IDs, because
the display was achieved with an early return in the transmit function
that bypassed the logic to silence implicit ID responses- by making it
not an early return we fix this.
2024-12-12 15:30:37 -05:00
Borys Lykah
69e2537438 Preserve ZSH options in the shell integration 2024-12-12 12:56:21 -07:00
Qwerasd
0557bf8301 font(metrics): always apply minimum values after calculating 2024-12-12 13:47:13 -05:00
Toby Jaffey
276f8537cc Merge branch 'select_boundary_dollar' of github.com:ringtailsoftware/ghostty into select_boundary_dollar 2024-12-12 16:48:28 +00:00
Toby Jaffey
47273de4c3 Added "selectWord with character boundary" test for dollar sign. 2024-12-12 16:47:04 +00:00
Toby Jaffey
8cc6a5729c Merge branch 'ghostty-org:main' into select_boundary_dollar 2024-12-12 08:02:54 +00:00
Josh Mills
db1019b1c0 Fix typo in config documentation 2024-12-12 06:42:27 +00:00
Mitchell Hashimoto
b19d0d3638 Back out "apprt/gtk: force X11 backend on GTK 4.14"
This backs out commit bb185cf6b695420ce8b43b5c1cadd16ef71c481a.

This was breaking IME input for some users and overall I couldn't find
other users where this really fixed anything other than me so I'm going
to back this out and fix this using my own system.
2024-12-11 20:27:30 -08:00
Mitchell Hashimoto
c325e13306 mdgen: use bold face for option and action names (#2931)
This is a small aesthetic change. From my own experience (and a brief
informal survey of other man pages in section 5), man pages commonly
emphasize "keywords" like this in some fashion (either using bold or a
different foreground color). This makes the man page easier to read
since there is more distinction between the option name and its
description.

## Before


![image](https://github.com/user-attachments/assets/3423910b-4df8-4f4a-8626-d6da01893b27)


![image](https://github.com/user-attachments/assets/0308f041-3a50-48c2-ac2b-14220e679cba)

## After


![image](https://github.com/user-attachments/assets/570411b9-8c25-4f80-8a40-1bb69fd2c8dd)


![image](https://github.com/user-attachments/assets/3d0d4217-8257-48bb-9bf6-978b1cbf16dd)
2024-12-11 19:37:39 -08:00
Qwerasd
fb50143cec font(coretext): add metrics test case for CT, fix variable font init
Variable font init used to just select the first available predefined
instance, if there were any, which is often not desirable- using
createFontDescriptorFromData instead of createFontDescritorsFromData
ensures that the default variation config is selected. In the future we
should probably allow selection of predefined instances, but for now
this is the correct behavior.

I found this bug when adding the metrics calculation test case for
CoreText, hence why fixing it is part of the same commit.
2024-12-11 21:14:21 -05:00
Toby Jaffey
5ef422b69a Add '$' to select boundaries, for same behaviour as iTerm 2024-12-11 23:38:34 +00:00
Qwerasd
bd18452310 font: unify metrics calculations & separate sprite metrics
Unify grid metrics calculations by relying on shared logic mostly based
on values directly from the font tables, this deduplicates a lot of code
and gives us more control over how we interpret various metrics.

Also separate metrics for underlined, strikethrough, and overline
thickness and position, and box drawing thickness, so that they can
individually be adjusted as the user desires.
2024-12-11 16:55:52 -05:00
Gregory Anders
d016bf8392 mdgen: use bold face for option and action names 2024-12-11 13:16:01 -06:00
Mitchell Hashimoto
ab60fbc096 apprt/glfw: add noop keyboardLayout func to satisfy tests and builds 2024-12-11 11:14:45 -08:00
Mitchell Hashimoto
22cc802157 gtk: pass surface to clipboard window by reference instead of by value (#2928)
The surface might be mutated during the clipboard confirmation (resized
in my case), leading to the copied cursor `page_pin` being invalidated.

Fixes #1714. Would be nice if @stgarf can verify this.

I agree to the MIT relicensing.
2024-12-11 10:51:36 -08:00
Mitchell Hashimoto
0ee90bb248 keybind: format leader bindings into multiple entries (#2923)
**Context**

Currently, if there are multiple keybindings with a shared prefix,
they are grouped into a nested series of Binding.Sets.
For example, as reported in #2734, the following bindings:

    keybind = ctrl+z>1=goto_tab:1
    keybind = ctrl+z>2=goto_tab:2
    keybind = ctrl+z>3=goto_tab:3

Result in roughly the following structure (in pseudo-code):

    Keybinds{
        Trigger("ctrl+z"): Value.leader{
            Trigger("1"): Value.leaf{action: "goto_tab:1"},
            Trigger("2"): Value.leaf{action: "goto_tab:2"},
            Trigger("3"): Value.leaf{action: "goto_tab:3"},
        }
    }

When this is formatted into a string (and therefore in +list-keybinds),
it is turned into the following as Value.format just concatenates
all the sibling bindings ('1', '2', '3') into consecutive bindings,
and this is then fed into a single configuration entry:

    keybind = ctrl+z>1=goto_tab:1>3=goto_tab:3>2=goto_tab:2

**Fix**

To fix this, Value needs to produce a separate configuration entry
for each sibling binding in the Value.leader case.
So we can't produce the entry (formatter.formatEntry) in Keybinds
and need to pass information down the Value tree to the leaf nodes,
each of which will produce a separate entry with that function.

This is accomplished with the help of a new Value.formatEntries method
that recursively builds up the prefix for the keybinding,
finally flushing it to the formatter when it reaches a leaf node.

This is done without extra allocations by using a FixedBufferStream
with the same buffer as before, sharing it between calls to nested
siblings of the same prefix.

**Testing**

Besides the included unit tests, I ran the GLFW-based app
and verified that the resulting binary produced the correct output
with `ghostty +show-config`:

```
❯ .zig-cache//o/02a32e7ba516d2692577a46f1a0df682/ghostty +show-config 2>/dev/null | grep goto_tab
keybind = ctrl+z>1=goto_tab:1
keybind = ctrl+z>3=goto_tab:3
keybind = ctrl+z>2=goto_tab:2
```

**Caveats**

We do not track the order in which the bindings were added
so the order is not retained in the formatConfig output.

Resolves #2734
2024-12-11 10:51:21 -08:00
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
Khang Nguyen Duy
cb67fbd08d gtk: pass surface to clipboard window by reference instead of by value
The surface might be mutated during the clipboard confirmation
(resized in my case), leading to the copied cursor page_pin being
invalidated.
2024-12-12 00:21:59 +07:00
Abhinav Gupta
495e4081e4 fix: NoSpaceLeft => OutOfMemory
NoSpaceLeft is not permitted to be returned in this context,
so turn it into OutOfMemory when we fail to write to the buffer.
2024-12-11 09:21:31 -08:00
Mitchell Hashimoto
3f21921568 Add zsh completions and improve fish completions (#2925)
Adds zsh completion generation and improves fish completion generation
to cover all actions with arguments.

<details>
  <summary>Generated _ghostty contents</summary>
  
  ```zsh
#compdef ghostty

_fonts () {
  local font_list=$(ghostty +list-fonts | grep -Z '^[A-Z]')
  local fonts=(${(f)font_list})
  _describe -t fonts 'fonts' fonts
}

_themes() {
  local theme_list=$(ghostty +list-themes | sed -E 's/^(.*) \(.*\$/\0/')
  local themes=(${(f)theme_list})
  _describe -t themes 'themes' themes
}
_config() {
  _arguments \
    "--help" \
    "--version" \
    "--font-family=-:::_fonts" \
    "--font-family-bold=-:::_fonts" \
    "--font-family-italic=-:::_fonts" \
    "--font-family-bold-italic=-:::_fonts" \
    "--font-style=-:::( )" \
    "--font-style-bold=-:::( )" \
    "--font-style-italic=-:::( )" \
    "--font-style-bold-italic=-:::( )" \
"--font-synthetic-style=-:::(bold no-bold italic no-italic bold-italic
no-bold-italic)" \
    "--font-feature=-:::( )" \
    "--font-size=-:::( )" \
    "--font-variation=-:::( )" \
    "--font-variation-bold=-:::( )" \
    "--font-variation-italic=-:::( )" \
    "--font-variation-bold-italic=-:::( )" \
    "--font-codepoint-map=-:::( )" \
    "--font-thicken=-:::(true false)" \
    "--adjust-cell-width=-:::( )" \
    "--adjust-cell-height=-:::( )" \
    "--adjust-font-baseline=-:::( )" \
    "--adjust-underline-position=-:::( )" \
    "--adjust-underline-thickness=-:::( )" \
    "--adjust-strikethrough-position=-:::( )" \
    "--adjust-strikethrough-thickness=-:::( )" \
    "--adjust-cursor-thickness=-:::( )" \
    "--grapheme-width-method=-:::(legacy unicode)" \
"--freetype-load-flags=-:::(hinting no-hinting force-autohint
no-force-autohint monochrome no-monochrome autohint no-autohint)" \
    "--theme=-:::_themes" \
    "--background=-:::( )" \
    "--foreground=-:::( )" \
    "--selection-foreground=-:::( )" \
    "--selection-background=-:::( )" \
    "--selection-invert-fg-bg=-:::(true false)" \
    "--minimum-contrast=-:::( )" \
    "--palette=-:::( )" \
    "--cursor-color=-:::( )" \
    "--cursor-invert-fg-bg=-:::(true false)" \
    "--cursor-opacity=-:::( )" \
    "--cursor-style=-:::(bar block underline block_hollow)" \
    "--cursor-style-blink=-:::( )" \
    "--cursor-text=-:::( )" \
    "--cursor-click-to-move=-:::(true false)" \
    "--mouse-hide-while-typing=-:::(true false)" \
    "--mouse-shift-capture=-:::(false true always never)" \
    "--mouse-scroll-multiplier=-:::( )" \
    "--background-opacity=-:::( )" \
    "--background-blur-radius=-:::( )" \
    "--unfocused-split-opacity=-:::( )" \
    "--unfocused-split-fill=-:::( )" \
    "--command=-:::( )" \
    "--initial-command=-:::( )" \
    "--wait-after-command=-:::(true false)" \
    "--abnormal-command-exit-runtime=-:::( )" \
    "--scrollback-limit=-:::( )" \
    "--link=-:::( )" \
    "--link-url=-:::(true false)" \
    "--fullscreen=-:::(true false)" \
    "--title=-:::( )" \
    "--class=-:::( )" \
    "--x11-instance-name=-:::( )" \
    "--working-directory=-:::{_files -/}" \
    "--keybind=-:::( )" \
    "--window-padding-x=-:::( )" \
    "--window-padding-y=-:::( )" \
    "--window-padding-balance=-:::(true false)" \
    "--window-padding-color=-:::(background extend extend-always)" \
    "--window-vsync=-:::(true false)" \
    "--window-inherit-working-directory=-:::(true false)" \
    "--window-inherit-font-size=-:::(true false)" \
    "--window-decoration=-:::(true false)" \
    "--window-title-font-family=-:::( )" \
    "--window-theme=-:::(auto system light dark ghostty)" \
    "--window-colorspace=-:::(srgb display-p3)" \
    "--window-height=-:::( )" \
    "--window-width=-:::( )" \
    "--window-save-state=-:::(default never always)" \
    "--window-step-resize=-:::(true false)" \
    "--window-new-tab-position=-:::(current end)" \
    "--resize-overlay=-:::(always never after-first)" \
"--resize-overlay-position=-:::(center top-left top-center top-right
bottom-left bottom-center bottom-right)" \
    "--resize-overlay-duration=-:::( )" \
    "--focus-follows-mouse=-:::(true false)" \
    "--clipboard-read=-:::(allow deny ask)" \
    "--clipboard-write=-:::(allow deny ask)" \
    "--clipboard-trim-trailing-spaces=-:::(true false)" \
    "--clipboard-paste-protection=-:::(true false)" \
    "--clipboard-paste-bracketed-safe=-:::(true false)" \
    "--image-storage-limit=-:::( )" \
    "--copy-on-select=-:::(false true clipboard)" \
    "--click-repeat-interval=-:::( )" \
    "--config-file=-:::_files" \
    "--config-default-files=-:::(true false)" \
    "--confirm-close-surface=-:::(true false)" \
    "--quit-after-last-window-closed=-:::(true false)" \
    "--quit-after-last-window-closed-delay=-:::( )" \
    "--initial-window=-:::(true false)" \
    "--quick-terminal-position=-:::(top bottom left right)" \
    "--quick-terminal-screen=-:::(main mouse macos-menu-bar)" \
    "--quick-terminal-animation-duration=-:::( )" \
    "--shell-integration=-:::(none detect bash elvish fish zsh)" \
"--shell-integration-features=-:::(cursor no-cursor sudo no-sudo title
no-title)" \
    "--osc-color-report-format=-:::(none 8-bit 16-bit)" \
    "--vt-kam-allowed=-:::(true false)" \
    "--custom-shader=-:::_files" \
    "--custom-shader-animation=-:::(false true always)" \
    "--macos-non-native-fullscreen=-:::(false true visible-menu)" \
    "--macos-titlebar-style=-:::(native transparent tabs hidden)" \
    "--macos-titlebar-proxy-icon=-:::(visible hidden)" \
    "--macos-option-as-alt=-:::(false true left right)" \
    "--macos-window-shadow=-:::(true false)" \
    "--macos-auto-secure-input=-:::(true false)" \
    "--macos-secure-input-indication=-:::(true false)" \
    "--linux-cgroup=-:::(never always single-instance)" \
    "--linux-cgroup-memory-limit=-:::( )" \
    "--linux-cgroup-processes-limit=-:::( )" \
    "--linux-cgroup-hard-fail=-:::(true false)" \
    "--gtk-single-instance=-:::(desktop false true)" \
    "--gtk-titlebar=-:::(true false)" \
    "--gtk-tabs-location=-:::(top bottom left right)" \
    "--adw-toolbar-style=-:::(flat raised raised-border)" \
    "--gtk-wide-tabs=-:::(true false)" \
    "--gtk-adwaita=-:::(true false)" \
    "--desktop-notifications=-:::(true false)" \
    "--bold-is-bright=-:::(true false)" \
    "--term=-:::( )" \
    "--enquiry-response=-:::( )" \
    "--auto-update=-:::(off check download)" \

}

_ghostty() {
  typeset -A opt_args
  local context state line
  local opt=('--help' '--version')

  _arguments -C \
    '1:actions:->actions' \
    '*:: :->rest' \

  if [[ "$line[1]" == "--help" || "$line[1]" == "--version" ]]; then
    return
  fi

  if [[ "$line[1]" == -* ]]; then
    _config
    return
  fi

  case "$state" in
    (actions)
      local actions; actions=(
        '+version'
        '+help'
        '+list-fonts'
        '+list-keybinds'
        '+list-themes'
        '+list-colors'
        '+list-actions'
        '+show-config'
        '+validate-config'
        '+crash-report'
      )
      _describe '' opt
      _describe -t action 'action' actions
    ;;
    (rest)
      if [[ "$line[2]" == "--help" ]]; then
        return
      fi

      local help=('--help')
      _describe '' help

      case $line[1] in
        (+list-fonts)
          _arguments \
            '--family=-:::( )' \
            '--style=-:::( )' \
            '--bold=-:::(true false)' \
            '--italic=-:::(true false)' \
        ;;
        (+list-keybinds)
          _arguments \
            '--default=-:::(true false)' \
            '--docs=-:::(true false)' \
            '--plain=-:::(true false)' \
        ;;
        (+list-themes)
          _arguments \
            '--path=-:::(true false)' \
            '--plain=-:::(true false)' \
        ;;
        (+list-actions)
          _arguments \
            '--docs=-:::(true false)' \
        ;;
        (+show-config)
          _arguments \
            '--default=-:::(true false)' \
            '--changes-only=-:::(true false)' \
            '--docs=-:::(true false)' \
        ;;
        (+validate-config)
          _arguments \
            '--config-file=-:::_files' \
        ;;
      esac
    ;;
  esac
}

_ghostty "$@"

  ```
</details>

I agree to relicense my commits to MIT
2024-12-11 08:57:59 -08:00
Anund
54bd012443 fish: reuse Action options iteration code 2024-12-11 21:11:44 +11:00
Anund
c7deea6a7f zsh: add completions generation 2024-12-11 21:11:38 +11:00
Khang Nguyen Duy
cb5848c7b7 command: fix hostname test compatibility
hostname is not guaranteed on *nix as in the comment.
For example, Arch does not have hostname by default.
2024-12-11 16:54:28 +07:00
Abhinav Gupta
e2e12efbbf keybind: format leader bindings into multiple entries
**Context**

Currently, if there are multiple keybindings with a shared prefix,
they are grouped into a nested series of Binding.Sets.
For example, as reported in #2734, the following bindings:

    keybind = ctrl+z>1=goto_tab:1
    keybind = ctrl+z>2=goto_tab:2
    keybind = ctrl+z>3=goto_tab:3

Result in roughly the following structure (in pseudo-code):

    Keybinds{
        Trigger("ctrl+z"): Value.leader{
            Trigger("1"): Value.leaf{action: "goto_tab:1"}),
            Trigger("2"): Value.leaf{action: "goto_tab:2"}),
            Trigger("3"): Value.leaf{action: "goto_tab:3"}),
        }
    }

When this is formatted into a string (and therefore in +list-keybinds),
it is turned into the following as Value.format just concatenates
all the sibling bindings ('1', '2', '3') into consecutive bindings,
and this is then fed into a single configuration entry:

    keybind = ctrl+z>1=goto_tab:1>3=goto_tab:3>2=goto_tab:2

**Fix**

To fix this, Value needs to produce a separate configuration entry
for each sibling binding in the Value.leader case.
So we can't produce the entry (formatter.formatEntry) in Keybinds
and need to pass information down the Value tree to the leaf nodes,
each of which will produce a separate entry with that function.

This is accomplished with the help of a new Value.formatEntries method
that recursively builds up the prefix for the keybinding,
finally flushing it to the formatter when it reaches a leaf node.

This is done without extra allocations by using a FixedBufferStream
with the same buffer as before, sharing it between calls to nested
siblings of the same prefix.

**Caveats**

We do not track the order in which the bindings were added
so the order is not retained in the formatConfig output.

Resolves #2734
2024-12-10 21:23:26 -08:00
Qwerasd
7e5a164be8 font/opentype: add table parsing for head, hhea, post, and OS/2
(and a utility for parsing SFNT font files and fetching table data from
them)
2024-12-10 16:35:51 -05:00
Qwerasd
2f31e1b7fa fix(kittygfx): don't respond to T commands with no i or I
If a transmit and display command does not specify an ID or a number,
then it should not be responded to. We currently automatically assign
IDs in this situation, which isn't ideal since collisions can happen
which shouldn't, but this at least fixes the glaring observable issue
where transmit-and-display commands yield unexpected OK responses.
2024-12-10 14:30:59 -05:00
deftdawg
9252378c82 Merge branch 'ghostty-org:main' into alt-keybindings-copy-and-paste 2024-12-09 23:04:31 -05:00