5828 Commits

Author SHA1 Message Date
Mitchell Hashimoto
298d6194f4 config: change color to a defined C struct for libghostty 2024-12-21 19:31:30 -08:00
Qwerasd
077dad11b4 font: add cursor-height metric, and adjust- config for it. 2024-12-21 20:15:53 -05:00
Anund
e8d79ed035 bash: move functions and variables out of global scope 2024-12-22 11:33:41 +11:00
Damien MEHALA
196af6f2ca config: quick terminal auto hide
Introduce a setting allowing to customize the behavior of the quick terminal
when it loses focus. By default, the quick terminal will automatically hide.
However, you can now configure it to remain open by setting
`quick-terminal-autohide: false`.

Resolves #2558
2024-12-22 01:08:47 +01:00
Mitchell Hashimoto
a74b555c42 bash: standardize on shorthand escape sequences (#3055)
We used a mix of shorthand and octal representations when printing these
control characters. Standardize on the shorter, more readable shorthand
notation because that's what we use in the other shell integration
scripts.
2024-12-21 12:02:23 -08:00
Jon Parise
76cd6b8b2e bash: standardize on shorthand escape sequences
We used a mix of shorthand and octal representations when printing these
control characters. Standardize on the shorter, more readable shorthand
notation because that's what we use in the other shell integration
scripts.
2024-12-21 10:19:58 -05:00
Mitchell Hashimoto
fc297da834 surface: don't early return when clearing hyperlinks (#3033)
When outside the viewport, other actions such as scrolling might be
happening, and doing an early return when clearing hyperlinks prevents
scrolling upwards.

We reposition the check, and do not early return so we can process
scrolling when it happens.

This fixes #2645, restoring the ability to scroll upwards while
retaining the behavior of hyperlinks when outside the viewport.

(and, yes I still permit my commits to be relicensed to MIT)

## Before
[Screen Recording 2024-12-21 at
01.36.02.webm](https://github.com/user-attachments/assets/bf144455-ff26-4d4e-9eff-c3d632c02c17)

## After
[Screen Recording 2024-12-21 at
01.36.44.webm](https://github.com/user-attachments/assets/308a795f-971d-4807-b4ba-91bd3685c185)
2024-12-21 07:18:31 -08:00
Mitchell Hashimoto
457bedc540 Bash complex completions (#3044)
Given https://github.com/ghostty-org/ghostty/discussions/2994 revert
f1728f594a.
Add documentation to help point people towards the discussion and needed
changes to handle `COMP_WORDBREAKS` not including expected characters.

We know macOS and nixos defaults to including `=` so explicit handling
to change behaviour should only be required if it turns out some
systematically used tool brings in a completion function that changes
`COMP_WORDBREAKS` away from the default. (something they should not be
doing)

If necessary I can create a issue to track handling unexpected word
breaks usage. This change improves the current completions.

I agree to re-license my commits to MIT
2024-12-21 07:10:08 -08:00
Mitchell Hashimoto
75a45f5692 config: blank title docs 2024-12-21 07:09:35 -08:00
Anund
9c96a80f8b bash: document COMP_WORDBREAKS interaction 2024-12-21 14:09:18 +11:00
Anund
3f94c84c80 Revert "bash: remove quoted completions while sorting possible portability issue"
This reverts commit f1728f594a681941b85a8d2fa8a136d625d9b633.
2024-12-21 13:43:41 +11:00
Mitchell Hashimoto
8f15f1a066 Make Ghostty release channel aware
Ghostty now has a release channel build configuration. Current valid
values are "tip" and "stable" but I imagine more will be added in the
future.

The release channel is inferred whether the version we specify with the
`-Dversion-string` build flag has a prerelease tag or not. If it does,
the release channel is "tip". If it doesn't, the release channel is
"stable".

This also adds a configuration to specify the release channel for
auto-updates for the macOS application.
2024-12-20 14:21:59 -08:00
moni
819b7e066d surface: don't early return when clearing hyperlinks
When outside the viewport, other actions such as scrolling might be happening, and doing an early return when clearing hyperlinks prevents scrolling upwards.

We do not early return so we can process scrolling when it happens.
2024-12-21 04:24:00 +08:00
Mitchell Hashimoto
5bb05996eb avoid asserting working directory is absolute (#3028)
`std.fs.accessAbsolute` asserts if the user proposed path is absolute,
which we are seemingly passing as-is with no validating that it is.

When running with safety checks on, passing non-absolute path to
--working-directory will make ghostty crash.

I changed it to use `Dir.access`, which is just `accessAbsolute` without
the check.

This has the side effect of also allowing relative working directory.
2024-12-20 08:25:51 -08:00
Mitchell Hashimoto
0f588d72c7 Change to F3 legacy encoding with modifiers (#3019)
The [fixterms](http://www.leonerd.org.uk/hacks/fixterms/) "Really
Special Keypresses" section suggests using CSI 1 ; Ps R for F3, but this
is also a valid cursor position report. The intention was to make
back-compatible changes, so this is fairly considered a specification
bug.

This changes F3 in legacy mode to send CSI 13 ; Ps ~ instead, this is a
variant listed in fixterms, is what kitty protocol uses, and lacks the
problematic overlap with cursor positions.

The KeyEncoder.zig unit test has been changed accordingly, and all tests
pass on my machine.
2024-12-20 08:25:30 -08:00
Khang Nguyen Duy
239056c90f avoid asserting working directory is absolute
`std.fs.accessAbsolute` asserts if the user proposed path is absolute,
which we are seemingly passing as-is with no validating that it is.

When running with safety checks on, passing non-absolute path to
--working-directory will make ghostty crash.

I changed it to use `Dir.access`, which is just `accessAbsolute` without
the check.

This has the side effect of also allowing relative working directory.
2024-12-20 22:41:28 +07:00
Mitchell Hashimoto
270d454c4e webgen: update config to support callouts, emit keybind actions 2024-12-19 17:15:39 -08:00
Sam Atman
8cadc7030c Change to F3 legacy encoding with modifiers
The [fixterms](http://www.leonerd.org.uk/hacks/fixterms/) "Really
Special Keypresses" section suggests using CSI 1 ; Ps R for F3, but this
is also a valid cursor position report.  The intention was to make back-
compatible changes, so this is fairly considered a specification bug.

This changes F3 in legacy mode to send CSI 13 ; Ps ~ instead, this is a
variant listed in fixterms, is what kitty protocol uses, and lacks the
problematic overlap with cursor positions.

The KeyEncoder.zig unit test has been changed accordingly, and all tests
pass on my machine.
2024-12-19 17:05:29 -05:00
Mitchell Hashimoto
d6e7685816 Docfix: correct comment for modifyOtherKeys sequence (#3018)
The comment in `function_keys.zig` was missing the `>` character for the
sequence. I've confirmed that this was just the comment, Ghostty treats
the original as an SGR sequence, which it is. Conversely, it does treat
`\x1b[>4;2m` as activating modifyOtherKeys.
2024-12-19 14:02:56 -08:00
Sam Atman
d885a266d4 Docfix: correct comment for modifyOtherKeys sequence
The comment in `function_keys.zig` was missing the `>` character for the
sequence.  I've confirmed that this was just the comment, Ghostty treats
the original as an SGR sequence, which it is.  Conversely, it does treat
`\x1b[>4:2m` as activating modifyOtherKeys.
2024-12-19 16:51:28 -05:00
Mitchell Hashimoto
fa3896be03 Fix emoji size and atlas padding (#3016)
Fixes a bug where emojis got smaller when font thicken was enabled
because they were constrained for some reason, here demonstrated by
artificially narrowing the cells with `adjust-cell-width=-45%`:
|`font-thicken`|main|this PR|
|-|-|-|
|`false`|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/c5c25d94-ea73-47e1-80e9-ed3baff76511"
/>|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/f74a35e1-ab7e-470d-b873-f33e63c1c9bb"
/>|
|`true`|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/e7c1e096-4a54-456c-afb0-5adcb94eaf00"
/>|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/80d3d7dd-f572-489a-ab56-d2d5ca9f3508"
/>|

And reworks the CoreText atlas margin/padding calculations to be more
efficient, you can see comparisons with and without thicken both before
and after this change here:
<details>
<summary>Atlas Textures</summary>

### main
|`font-thicken`|gray|color|
|-|-|-|

|`false`|![image](https://github.com/user-attachments/assets/d73a8963-ebfc-44d7-8b57-92db54612336)|![image](https://github.com/user-attachments/assets/4305243b-6459-45aa-bd42-bb263f3b0a9f)|

|`true`|![image](https://github.com/user-attachments/assets/94810d04-ea30-40f9-8d08-07b487b98ad1)|![image](https://github.com/user-attachments/assets/be5f1a2a-7c11-4805-977b-edf8aa7232a1)|

### this PR
|`font-thicken`|gray|color|
|-|-|-|

|`false`|![image](https://github.com/user-attachments/assets/e1debdcb-36bd-44d3-8776-27f4a2285821)|![image](https://github.com/user-attachments/assets/5cdc5eb8-6122-4bf7-8525-93a1b83d2bf0)|

|`true`|![image](https://github.com/user-attachments/assets/423bfb38-2657-4f48-a6fb-77986d049615)|![image](https://github.com/user-attachments/assets/136e970f-25e7-4ec5-8819-5a981381d18f)|
</details>

The atlas padding calculations were also affecting the issue with the
emojis getting smaller when thicken was enabled, because they were given
extra space to account for the thickening but they're bitmap so they
don't get affected by thickening.
2024-12-19 13:31:06 -08:00
Qwerasd
0e21293d43 font(coretext): improve atlas padding calculations
- Simplifies and clarifies the math for how the bounding box for
rendered glyphs is computed
- Reduces margin from 2px between glyphs to 1px by only padding the
bottom and right side of each glyph
- Avoids excessive padding to glyph box when font thicken is enabled or
when using a synthetic bold (it was previously 4x as much padding as
necessary in some cases)
2024-12-19 13:30:52 -08:00
Niclas van Eyk
7d71eabae8 docs: fix referenced toggle window decorations action name 2024-12-19 22:05:59 +01:00
Qwerasd
4ca6413ec9 renderer: do not constrain color glyphs
There is no reason to and I do not know where this assumption came from.
It's very possible for a colored glyph to (intentionally!) exceed the
cell bounds, and we shouldn't be stopping this...
2024-12-19 11:21:57 -05:00
Mitchell Hashimoto
82c9787fd3 build: generate reference page for config for website 2024-12-18 07:06:35 -08:00
Mitchell Hashimoto
34dca8149b bash: improve clearing of multiline prompts (#3003)
Bash doesn't redraw the leading lines in a multiline prompt so we mark
the last line as a secondary prompt (k=s) to prevent the preceding lines
from being erased by Ghostty after a resize.

Our previously attempt at this (#1973) was flawed. Instead, we now just
re-issue the OSC "133;A" command with a 'k=s' (secondary) kind at the
end of our prompt string.

This isn't a great solution because it stomps on the prompt's "133;B"
command (end of prompt and start of user input), but it's sufficient for
now and only applies in the multiline prompt case.

Going forward, we should revisit our semantic prompt implementation. Our
row-based approach is too limiting; lines can have multiple markers, and
markers should be recorded with their full coordinates so they can form
ranges.

See: https://per.bothner.com/blog/2019/shell-integration-proposal/

Fixes: #1961
2024-12-17 14:17:41 -08:00
Jon Parise
63747d1e22 bash: improve clearing of multiline prompts
Bash doesn't redraw the leading lines in a multiline prompt so we mark
the last line as a secondary prompt (k=s) to prevent the preceding lines
from being erased by Ghostty after a resize.

Our previously attempt at this (#1973) was flawed. Instead, we now just
re-issue the OSC "133;A" command with a 'k=s' (secondary) kind at the
end of our prompt string.

This isn't a great solution because it stomps on the prompt's "133;B"
command (end of prompt and start of user input), but it's sufficient for
now and only applies in the multiline prompt case.

Going forward, we should revisit our semantic prompt implementation. Our
row-based approach is too limiting; lines can have multiple markers, and
markers should be recorded with their full coordinates so they can form
ranges.

See: https://per.bothner.com/blog/2019/shell-integration-proposal/
2024-12-17 16:28:41 -05:00
Jon Parise
a2c546c8d1 config: disable forced shell integration for -e
This prevents forcibly injecting any configured shell integration into
the command's environment. Automatic shell detection is enabled, unless
shell integration has been explicitly disabled.
2024-12-17 12:12:51 -08:00
Jeffrey C. Ollie
82e67430cd cli: add +show-face CLI action
This CLI action shows what font face Ghostty will use to display
a particular codepoint.
2024-12-17 13:09:32 -06:00
Jeffrey C. Ollie
813c48cb12 core: allow u21 as a cli argument type 2024-12-17 13:08:48 -06:00
Jeffrey C. Ollie
97a2b94c9b core: allow cli actions to use arg parsing diagnostics 2024-12-17 13:07:48 -06:00
Anund
38b42fc970 shell-integration: add bashrc location lookup in Nixos
fixes #2979
2024-12-17 21:49:15 +11:00
Mitchell Hashimoto
ae6c4c3f0c terminal: handle consecutive .input's in clearPrompt (#2990)
Our semantic prompts are row-based, so the last prompt marker set on a
row "wins". In the case of at least our bash shell integration, this
means that consecutive prompt lines will all be marked as .input (OSC
133;B -- end-of-prompt, start of input).

Previously, clearPrompt() identified the current prompt's "area" by
searching upward from the current row until it encounters a .prompt
marker or some command output. In the bash case, .prompt is never the
dominant ("last") marker, so clearPrompt() would aggressively clear all
immediately preceding consecutive prompts.

With this change, we'll stop searching upwards when we encounter some
command output, a .prompt marker, _or another .input marker_. That last
case prevents clearPrompt() from unintentionally clearing earlier prompt
lines.

There may be improvements we can make to the way that our bash shell
integration emits semantic prompt markers, but I think this logic is
generally sound for all cases, and it specifically improves the current
bash prompt-clearing experience.

---

Before and after, after resizing the terminal window to trigger a
reflow:

<img width="504"
src="https://github.com/user-attachments/assets/91aa652e-e262-445a-8eed-7268c0d66428"
/>
<img width="510"
src="https://github.com/user-attachments/assets/b43e0aa4-0e24-4f4e-9b2c-b6b07c8f8c77"
/>
2024-12-16 21:08:21 -08:00
Jon Parise
82756f8b4c terminal: handle consecutive .input's in clearPrompt
Our semantic prompts are row-based, so the last prompt marker set on a
row "wins". In the case of at least our bash shell integration, this
means that consecutive prompt lines will all be marked as .input (OSC
133;B -- end-of-prompt, start of input).

Previously, clearPrompt() identified the current prompt's "area" by
searching upward from the current row until it encounters a .prompt
marker or some command output. In the bash case, .prompt is never the
dominant ("last") marker, so clearPrompt() would aggressively clear all
immediately preceding consecutive prompts.

With this change, we'll stop searching upwards when we encounter some
command output, a .prompt marker, _or another .input marker_. That last
case prevents clearPrompt() from unintentionally clearing earlier prompt
lines.

There may be improvements we can make to the way that our bash shell
integration emits semantic prompt markers, but I think this logic is
generally sound for all cases, and it specifically improves the current
bash prompt-clearing experience.
2024-12-16 21:06:15 -08:00
Jeffrey C. Ollie
7816705898 build: allow CLI actions to have enum option values
A typo in the fish completions (that was likely copied to the zsh and
bash completions) prevented CLI actions from using enums as option
values because the completions tried to access non-existent fields from
type introspection. This doesn't cause any problems _now_ because no CLI
action uses an enum as an option value. However as soon as you try and
add one the completions fail to compile.

This patch fixes the incorrect field reference. It also adds the ability
to have _optional_ enums as option values.
2024-12-16 18:03:32 -06:00
Mitchell Hashimoto
56f285cbc2 Handle fonts with missing or invalid OS/2 tables (#2985)
It turns out this happens more than I thought. Most notably, apple's
fallback font for a bunch of symbols, `Apple Gothic`, has no OS/2 table
🙃. I've gone ahead and fixed it so that both CoreText and FreeType
handle this gracefully.

Speaking of graceful handling, this problem came to attention due to our
very *un*-graceful handling of when a font fails to load due to a
metrics calculation error. It results in a bunch of blanked out text,
very bad, we should fix that.

*At some point I'll try to collect a group of test fonts with all sorts
of weirdnesses to exercise the weird edge cases in our handling.*
2024-12-16 12:43:59 -08:00
Mitchell Hashimoto
2b78ac4382 font: style edits for #2985 2024-12-16 12:30:34 -08:00
Mitchell Hashimoto
bd48dcc748 os: add prependEnv(), like appendEnv() (#2983)
We can use this function in setupXdgDataDirs() to simplify the
XDG_DATA_DIRS environment variable code in a more standardized way.
2024-12-16 12:24:29 -08:00
Qwerasd
a06388869d fix: sCapHeight and sxHeight only exist when OS/2 version >= 2 2024-12-16 15:20:26 -05:00
Qwerasd
13e4861dff font(freetype): tolerate fonts without OS/2 tables
This is more common than anticipated, so proper fallback logic has been
added. Why must fonts be like this? -.-
2024-12-16 14:53:29 -05:00
Qwerasd
5cd214066d font(coretext): tolerate fonts without OS/2 tables
This creates big problems if we don't, since a lot of symbols end up
falling back to Apple Gothic, which doesn't have an OS/2 table.
2024-12-16 14:52:07 -05:00
Aaron Bull Schaefer
7999423244 docs: fix typo 2024-12-16 08:00:29 -08:00
Jon Parise
f141f4b2b0 os: add prependEnv(), like appendEnv()
We can use this function in setupXdgDataDirs() to simplify the
XDG_DATA_DIRS environment variable code in a more standardized way.
2024-12-16 10:56:27 -05:00
Mitchell Hashimoto
8814844a45 macos: add our application bundle to XDG_DATA_DIRS (#2974)
We're packaging more and more application-specific data directories in
our application bundle. It's helpful to add that path to XDG_DATA_DIRS
so those applications (that support XDG_DATA_DIRS) can locate their data
directories without additional user-level configuration.

This also fixes a typo ("MATHPATH") in the nearby MANPATH-building code.
2024-12-15 21:27:14 -08:00
Jon Parise
d981ddf128 macos: add our application bundle to XDG_DATA_DIRS
We're packaging more and more application-specific data directories in
our application bundle. It's helpful to add that path to XDG_DATA_DIRS
so those applications (that support XDG_DATA_DIRS) can locate their data
directories without additional user-level configuration.

This also fixes a typo ("MATHPATH") in the nearby MANPATH-building code.
2024-12-15 21:24:43 -08:00
Mitchell Hashimoto
0ad4b6bf44 bash: add bash completion generation (#2963)
Bash completions on par with fish and zsh completions. There's a lot of
room to add additional custom completions in all three languages. (see
`key) return;;` for cases)

I've noticed a few mistakes with the other completions I'll raise as a
separate PR.

<details>
  <summary>Generated ghostty.bash - updated</summary>

```bash

# -o nospace requires we add back a space when a completion is finished
# and not part of a --key= completion
addSpaces() {
  for idx in "${!COMPREPLY[@]}"; do
    [ -n "${COMPREPLY[idx]}" ] && COMPREPLY[idx]="${COMPREPLY[idx]} ";
  done
}

_fonts() {
  local IFS=$'\n'
  mapfile -t COMPREPLY < <( compgen -P '"' -S '"' -W "$($ghostty +list-fonts | grep '^[A-Z]' )" -- "$cur")
}

_themes() {
  local IFS=$'\n'
  mapfile -t COMPREPLY < <( compgen -P '"' -S '"' -W "$($ghostty +list-themes | sed -E 's/^(.*) \(.*$/\1/')" -- "$cur")
}

_files() {
  mapfile -t COMPREPLY < <( compgen -o filenames -f -- "$cur" )
  for i in "${!COMPREPLY[@]}"; do
    if [[ -d "${COMPREPLY[i]}" ]]; then
      COMPREPLY[i]="${COMPREPLY[i]}/";
    fi
    if [[ -f "${COMPREPLY[i]}" ]]; then
      COMPREPLY[i]="${COMPREPLY[i]} ";
    fi
  done
}

_dirs() {
  mapfile -t COMPREPLY < <( compgen -o dirnames -d -- "$cur" )
  for i in "${!COMPREPLY[@]}"; do
    if [[ -d "${COMPREPLY[i]}" ]]; then
      COMPREPLY[i]="${COMPREPLY[i]}/";
    fi
  done
  if [[ "${#COMPREPLY[@]}" == 0 && -d "$cur" ]]; then
    COMPREPLY=( "$cur " )
  fi
}

config="--help"
config+=" --version"
config+=" --font-family="
config+=" --font-family-bold="
config+=" --font-family-italic="
config+=" --font-family-bold-italic="
config+=" --font-style="
config+=" --font-style-bold="
config+=" --font-style-italic="
config+=" --font-style-bold-italic="
config+=" --font-synthetic-style="
config+=" --font-feature="
config+=" --font-size="
config+=" --font-variation="
config+=" --font-variation-bold="
config+=" --font-variation-italic="
config+=" --font-variation-bold-italic="
config+=" --font-codepoint-map="
config+=" --font-thicken="
config+=" --adjust-cell-width="
config+=" --adjust-cell-height="
config+=" --adjust-font-baseline="
config+=" --adjust-underline-position="
config+=" --adjust-underline-thickness="
config+=" --adjust-strikethrough-position="
config+=" --adjust-strikethrough-thickness="
config+=" --adjust-cursor-thickness="
config+=" --grapheme-width-method="
config+=" --freetype-load-flags="
config+=" --theme="
config+=" --background="
config+=" --foreground="
config+=" --selection-foreground="
config+=" --selection-background="
config+=" --selection-invert-fg-bg="
config+=" --minimum-contrast="
config+=" --palette="
config+=" --cursor-color="
config+=" --cursor-invert-fg-bg="
config+=" --cursor-opacity="
config+=" --cursor-style="
config+=" --cursor-style-blink="
config+=" --cursor-text="
config+=" --cursor-click-to-move="
config+=" --mouse-hide-while-typing="
config+=" --mouse-shift-capture="
config+=" --mouse-scroll-multiplier="
config+=" --background-opacity="
config+=" --background-blur-radius="
config+=" --unfocused-split-opacity="
config+=" --unfocused-split-fill="
config+=" --command="
config+=" --initial-command="
config+=" --wait-after-command="
config+=" --abnormal-command-exit-runtime="
config+=" --scrollback-limit="
config+=" --link="
config+=" --link-url="
config+=" --fullscreen="
config+=" --title="
config+=" --class="
config+=" --x11-instance-name="
config+=" --working-directory="
config+=" --keybind="
config+=" --window-padding-x="
config+=" --window-padding-y="
config+=" --window-padding-balance="
config+=" --window-padding-color="
config+=" --window-vsync="
config+=" --window-inherit-working-directory="
config+=" --window-inherit-font-size="
config+=" --window-decoration="
config+=" --window-title-font-family="
config+=" --window-theme="
config+=" --window-colorspace="
config+=" --window-height="
config+=" --window-width="
config+=" --window-save-state="
config+=" --window-step-resize="
config+=" --window-new-tab-position="
config+=" --resize-overlay="
config+=" --resize-overlay-position="
config+=" --resize-overlay-duration="
config+=" --focus-follows-mouse="
config+=" --clipboard-read="
config+=" --clipboard-write="
config+=" --clipboard-trim-trailing-spaces="
config+=" --clipboard-paste-protection="
config+=" --clipboard-paste-bracketed-safe="
config+=" --image-storage-limit="
config+=" --copy-on-select="
config+=" --click-repeat-interval="
config+=" --config-file="
config+=" --config-default-files="
config+=" --confirm-close-surface="
config+=" --quit-after-last-window-closed="
config+=" --quit-after-last-window-closed-delay="
config+=" --initial-window="
config+=" --quick-terminal-position="
config+=" --quick-terminal-screen="
config+=" --quick-terminal-animation-duration="
config+=" --shell-integration="
config+=" --shell-integration-features="
config+=" --osc-color-report-format="
config+=" --vt-kam-allowed="
config+=" --custom-shader="
config+=" --custom-shader-animation="
config+=" --macos-non-native-fullscreen="
config+=" --macos-titlebar-style="
config+=" --macos-titlebar-proxy-icon="
config+=" --macos-option-as-alt="
config+=" --macos-window-shadow="
config+=" --macos-auto-secure-input="
config+=" --macos-secure-input-indication="
config+=" --linux-cgroup="
config+=" --linux-cgroup-memory-limit="
config+=" --linux-cgroup-processes-limit="
config+=" --linux-cgroup-hard-fail="
config+=" --gtk-single-instance="
config+=" --gtk-titlebar="
config+=" --gtk-tabs-location="
config+=" --adw-toolbar-style="
config+=" --gtk-wide-tabs="
config+=" --gtk-adwaita="
config+=" --desktop-notifications="
config+=" --bold-is-bright="
config+=" --term="
config+=" --enquiry-response="
config+=" --auto-update="

_handleConfig() {
  case "$prev" in
    --font-family) _fonts ;;
    --font-family-bold) _fonts ;;
    --font-family-italic) _fonts ;;
    --font-family-bold-italic) _fonts ;;
    --font-style) return ;;
    --font-style-bold) return ;;
    --font-style-italic) return ;;
    --font-style-bold-italic) return ;;
    --font-synthetic-style) mapfile -t COMPREPLY < <( compgen -W "bold no-bold italic no-italic bold-italic no-bold-italic" -- "$cur" ); addSpaces ;;
    --font-feature) return ;;
    --font-size) return ;;
    --font-variation) return ;;
    --font-variation-bold) return ;;
    --font-variation-italic) return ;;
    --font-variation-bold-italic) return ;;
    --font-codepoint-map) return ;;
    --font-thicken) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --adjust-cell-width) return ;;
    --adjust-cell-height) return ;;
    --adjust-font-baseline) return ;;
    --adjust-underline-position) return ;;
    --adjust-underline-thickness) return ;;
    --adjust-strikethrough-position) return ;;
    --adjust-strikethrough-thickness) return ;;
    --adjust-cursor-thickness) return ;;
    --grapheme-width-method) mapfile -t COMPREPLY < <( compgen -W "legacy unicode" -- "$cur" ); addSpaces ;;
    --freetype-load-flags) mapfile -t COMPREPLY < <( compgen -W "hinting no-hinting force-autohint no-force-autohint monochrome no-monochrome autohint no-autohint" -- "$cur" ); addSpaces ;;
    --theme) _themes ;;
    --background) return ;;
    --foreground) return ;;
    --selection-foreground) return ;;
    --selection-background) return ;;
    --selection-invert-fg-bg) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --minimum-contrast) return ;;
    --palette) return ;;
    --cursor-color) return ;;
    --cursor-invert-fg-bg) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --cursor-opacity) return ;;
    --cursor-style) mapfile -t COMPREPLY < <( compgen -W "bar block underline block_hollow" -- "$cur" ); addSpaces ;;
    --cursor-style-blink) return ;;
    --cursor-text) return ;;
    --cursor-click-to-move) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --mouse-hide-while-typing) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --mouse-shift-capture) mapfile -t COMPREPLY < <( compgen -W "false true always never" -- "$cur" ); addSpaces ;;
    --mouse-scroll-multiplier) return ;;
    --background-opacity) return ;;
    --background-blur-radius) return ;;
    --unfocused-split-opacity) return ;;
    --unfocused-split-fill) return ;;
    --command) return ;;
    --initial-command) return ;;
    --wait-after-command) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --abnormal-command-exit-runtime) return ;;
    --scrollback-limit) return ;;
    --link) return ;;
    --link-url) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --fullscreen) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --title) return ;;
    --class) return ;;
    --x11-instance-name) return ;;
    --working-directory) _dirs ;;
    --keybind) return ;;
    --window-padding-x) return ;;
    --window-padding-y) return ;;
    --window-padding-balance) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --window-padding-color) mapfile -t COMPREPLY < <( compgen -W "background extend extend-always" -- "$cur" ); addSpaces ;;
    --window-vsync) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --window-inherit-working-directory) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --window-inherit-font-size) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --window-decoration) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --window-title-font-family) return ;;
    --window-theme) mapfile -t COMPREPLY < <( compgen -W "auto system light dark ghostty" -- "$cur" ); addSpaces ;;
    --window-colorspace) mapfile -t COMPREPLY < <( compgen -W "srgb display-p3" -- "$cur" ); addSpaces ;;
    --window-height) return ;;
    --window-width) return ;;
    --window-save-state) mapfile -t COMPREPLY < <( compgen -W "default never always" -- "$cur" ); addSpaces ;;
    --window-step-resize) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --window-new-tab-position) mapfile -t COMPREPLY < <( compgen -W "current end" -- "$cur" ); addSpaces ;;
    --resize-overlay) mapfile -t COMPREPLY < <( compgen -W "always never after-first" -- "$cur" ); addSpaces ;;
    --resize-overlay-position) mapfile -t COMPREPLY < <( compgen -W "center top-left top-center top-right bottom-left bottom-center bottom-right" -- "$cur" ); addSpaces ;;
    --resize-overlay-duration) return ;;

    --clipboard-read) mapfile -t COMPREPLY < <( compgen -W "allow deny ask" -- "$cur" ); addSpaces ;;
    --clipboard-write) mapfile -t COMPREPLY < <( compgen -W "allow deny ask" -- "$cur" ); addSpaces ;;
    --clipboard-trim-trailing-spaces) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --clipboard-paste-protection) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --clipboard-paste-bracketed-safe) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --image-storage-limit) return ;;
    --copy-on-select) mapfile -t COMPREPLY < <( compgen -W "false true clipboard" -- "$cur" ); addSpaces ;;
    --click-repeat-interval) return ;;
    --config-file) _files ;;
    --config-default-files) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --confirm-close-surface) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --quit-after-last-window-closed) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --quit-after-last-window-closed-delay) return ;;
    --initial-window) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --quick-terminal-position) mapfile -t COMPREPLY < <( compgen -W "top bottom left right" -- "$cur" ); addSpaces ;;
    --quick-terminal-screen) mapfile -t COMPREPLY < <( compgen -W "main mouse macos-menu-bar" -- "$cur" ); addSpaces ;;
    --quick-terminal-animation-duration) return ;;
    --shell-integration) mapfile -t COMPREPLY < <( compgen -W "none detect bash elvish fish zsh" -- "$cur" ); addSpaces ;;
    --shell-integration-features) mapfile -t COMPREPLY < <( compgen -W "cursor no-cursor sudo no-sudo title no-title" -- "$cur" ); addSpaces ;;
    --osc-color-report-format) mapfile -t COMPREPLY < <( compgen -W "none 8-bit 16-bit" -- "$cur" ); addSpaces ;;
    --vt-kam-allowed) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --custom-shader) _files ;;
    --custom-shader-animation) mapfile -t COMPREPLY < <( compgen -W "false true always" -- "$cur" ); addSpaces ;;
    --macos-non-native-fullscreen) mapfile -t COMPREPLY < <( compgen -W "false true visible-menu" -- "$cur" ); addSpaces ;;
    --macos-titlebar-style) mapfile -t COMPREPLY < <( compgen -W "native transparent tabs hidden" -- "$cur" ); addSpaces ;;
    --macos-titlebar-proxy-icon) mapfile -t COMPREPLY < <( compgen -W "visible hidden" -- "$cur" ); addSpaces ;;
    --macos-option-as-alt) return ;;
    --macos-window-shadow) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --macos-auto-secure-input) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --macos-secure-input-indication) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --linux-cgroup) mapfile -t COMPREPLY < <( compgen -W "never always single-instance" -- "$cur" ); addSpaces ;;
    --linux-cgroup-memory-limit) return ;;
    --linux-cgroup-processes-limit) return ;;
    --linux-cgroup-hard-fail) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --gtk-single-instance) mapfile -t COMPREPLY < <( compgen -W "desktop false true" -- "$cur" ); addSpaces ;;
    --gtk-titlebar) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --gtk-tabs-location) mapfile -t COMPREPLY < <( compgen -W "top bottom left right" -- "$cur" ); addSpaces ;;
    --adw-toolbar-style) mapfile -t COMPREPLY < <( compgen -W "flat raised raised-border" -- "$cur" ); addSpaces ;;
    --gtk-wide-tabs) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --gtk-adwaita) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --desktop-notifications) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --bold-is-bright) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
    --term) return ;;
    --enquiry-response) return ;;
    --auto-update) mapfile -t COMPREPLY < <( compgen -W "off check download" -- "$cur" ); addSpaces ;;
    *) mapfile -t COMPREPLY < <( compgen -W "$config" -- "$cur" ) ;;
  esac

  return 0
}

list_fonts="--family= --style= --bold= --italic= --help"
list_keybinds="--default= --docs= --plain= --help"
list_themes="--path= --plain= --help"
list_actions="--docs= --help"
show_config="--default= --changes-only= --docs= --help"
validate_config="--config-file= --help"

_handleActions() {
  case "${COMP_WORDS[1]}" in
    +list-fonts)
      case $prev in
        --family) return;;
        --style) return;;
        --bold) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        --italic) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        *) mapfile -t COMPREPLY < <( compgen -W "$list_fonts" -- "$cur" ) ;;
      esac
    ;;
    +list-keybinds)
      case $prev in
        --default) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        --docs) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        --plain) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        *) mapfile -t COMPREPLY < <( compgen -W "$list_keybinds" -- "$cur" ) ;;
      esac
    ;;
    +list-themes)
      case $prev in
        --path) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        --plain) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        *) mapfile -t COMPREPLY < <( compgen -W "$list_themes" -- "$cur" ) ;;
      esac
    ;;
    +list-actions)
      case $prev in
        --docs) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        *) mapfile -t COMPREPLY < <( compgen -W "$list_actions" -- "$cur" ) ;;
      esac
    ;;
    +show-config)
      case $prev in
        --default) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        --changes-only) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        --docs) mapfile -t COMPREPLY < <( compgen -W "true false" -- "$cur" ); addSpaces ;;
        *) mapfile -t COMPREPLY < <( compgen -W "$show_config" -- "$cur" ) ;;
      esac
    ;;
    +validate-config)
      case $prev in
        --config-file) _files ;;
        *) mapfile -t COMPREPLY < <( compgen -W "$validate_config" -- "$cur" ) ;;
      esac
    ;;
    *) mapfile -t COMPREPLY < <( compgen -W "--help" -- "$cur" ) ;;
  esac

  return 0
}

topLevel="-e"
topLevel+=" --help"
topLevel+=" --version"
topLevel+=" +list-fonts"
topLevel+=" +list-keybinds"
topLevel+=" +list-themes"
topLevel+=" +list-colors"
topLevel+=" +list-actions"
topLevel+=" +show-config"
topLevel+=" +validate-config"
topLevel+=" +crash-report"

_ghostty() {
  cur=""; prev=""; prevWasEq=false; COMPREPLY=()
  ghostty="$1"

  if [ "$2" = "=" ]; then cur=""
  else                    cur="$2"
  fi

  if [ "$3" = "=" ]; then prev="${COMP_WORDS[COMP_CWORD-2]}"; prevWasEq=true;
  else                    prev="${COMP_WORDS[COMP_CWORD-1]}"
  fi

  # current completion is double quoted add a space so the curor progresses
  if [[ "$2" == \"*\" ]]; then
    COMPREPLY=( "$cur " );
    return;
  fi

  case "$COMP_CWORD" in
    1)
      case "${COMP_WORDS[1]}" in
        -e | --help | --version) return 0 ;;
        --*) _handleConfig ;;
        *) mapfile -t COMPREPLY < <( compgen -W "${topLevel}" -- "$cur" ); addSpaces ;;
      esac
      ;;
    *)
      case "$prev" in
        -e | --help | --version) return 0 ;;
        *)
          if [[ "=" != "${COMP_WORDS[COMP_CWORD]}" && $prevWasEq != true ]]; then
            # must be completing with a space after the key eg: '--<key> '
            # clear out prev so we don't run any of the key specific completions
            prev=""
          fi

          case "${COMP_WORDS[1]}" in
            --*) _handleConfig ;;
            +*) _handleActions ;;
          esac
          ;;
      esac
      ;;
  esac

  return 0
}

complete -o nospace -o bashdefault -F _ghostty ghostty
```
</details>

cc @jparise 
I agree to re-license my commits to MIT
Closes #2053
2024-12-15 18:14:56 -08:00
Jeffrey C. Ollie
0c6f4afb34 fix sprite drawing test 2024-12-15 18:00:50 -06:00
Jeffrey C. Ollie
3588d81dcb simplify the code for separated block quadrants 2024-12-15 17:59:04 -06:00
Mitchell Hashimoto
f50e8a5fdb Add new font adjust configs (#2962)
Add keys for adjusting overline position/thickness and box drawing
thickness, + docs to each adjust key clarifying what the metric they
adjust does.
2024-12-15 14:09:30 -08:00
Mitchell Hashimoto
fdd330d22d apprt/gtk: stylistic changes 2024-12-15 14:01:10 -08:00