8306 Commits

Author SHA1 Message Date
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
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
Mitchell Hashimoto
cf00d14f4d docs: fix typo (#2984)
There was a minor typo in the configuration documentation.
2024-12-16 08:33:11 -08: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
6a1df9fb8d macos: add bash-completion to the application bundle (#2982) 2024-12-16 07:10:52 -08:00
Jon Parise
f81bb892c0 macos: add bash-completion to the application bundle 2024-12-16 08:38:55 -05:00
Mitchell Hashimoto
50cee99988 Harmonize README_TESTERS.md and CONTRIBUTING.md (#2916)
Hi!

This tweaks README_TESTERS.md to match what's in CONTRIBUTING.md better.

Fixes #2912

Thanks for considering!
2024-12-15 21:31:06 -08:00
thyttan
d65534554e Harmonize README_TESTERS.md and CONTRIBUTING.md 2024-12-15 21:30:54 -08:00
Mitchell Hashimoto
0907425d8f Add information about community config tool (#2914)
I never got a response in the Discord server about PRing this so I
figured I would open the PR anyways.

I thought it might be a good idea to add this info into the README for
all the testers currently using Ghostty. I also think it might be a good
idea to have this in place before Ghostty goes public to potentially cut
down on the number of incoming requests for help and support regarding
configuration files and the inevitable duplicate requests for GUI
settings.

If this isn't something you'd like to add, feel free to close this. If
you want it adjusted in some way, let me know!
2024-12-15 21:30:15 -08: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
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
71547c06a3 apprt/gtk: abstract AdwHeaderBar and GtkHeaderBar (#2749)
This will make further changes a little bit more readable.
2024-12-15 14:05:03 -08:00
Mitchell Hashimoto
fdd330d22d apprt/gtk: stylistic changes 2024-12-15 14:01:10 -08:00
Tristan Partin
98380f3c42 apprt/gtk: abstract AdwHeaderBar and GtkHeaderBar
This will make further changes a little bit more readable.

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-15 14:01:10 -08:00
Mitchell Hashimoto
09b7c7b617 apprt/gtk: add gtk-tabs-location=hidden (#2729)
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]
2024-12-15 13:54:30 -08:00
Mitchell Hashimoto
fc6357ac70 apprt/gtk: slight style feedback 2024-12-15 13:54:06 -08:00
Anund
79d2f508a9 bash: support short form boolean options 2024-12-16 08:23:28 +11:00
Anund
f1728f594a bash: remove quoted completions while sorting possible portability issue 2024-12-16 08:22:42 +11:00
Mitchell Hashimoto
ceef2900e2 bash: re-enable automatic bash shell detection (#2966)
Bash shell detection was originally disabled in #1823 due to problems
with /bin/bash on macOS.

Apple distributes their own patched version of Bash 3.2 on macOS that
disables the POSIX-style $ENV-based startup path:


e5397a7e74/bash-3.2/shell.c (L1112-L1114)

This means we're unable to perform our automatic shell integration
sequence in this specific environment. Standard Bash 3.2 works fine.

Knowing this, we can re-enable bash shell detection by default unless
we're running "/bin/bash" on Darwin. We can safely assume that's the
unsupported Bash executable because /bin is non-writable on modern macOS
installations due to System Integrity Protection.

macOS users can either manually source our shell integration script
(which otherwise works fine with Apple's Bash) or install a standard
version of Bash from Homebrew or elsewhere.
2024-12-15 07:13:53 -08:00
Anund
ea181579df bash: add _files and _dirs to correctly add spaces to only the final result 2024-12-16 01:32:51 +11:00
Anund
361967f721 bash: formatting changes, change to reference binary name via variable 2024-12-16 01:32:50 +11:00
Anund
c02789205e bash: fix incorrect completion for '--key ' 2024-12-16 01:32:46 +11:00
Mitchell Hashimoto
de3674ff39 Update iTerm2 colorschemes (#2972)
Upstream revision:
5fd82e34a3
2024-12-14 17:11:31 -08:00
mitchellh
854ec586f9 deps: Update iTerm2 color schemes 2024-12-15 01:05:52 +00:00
Jon Parise
a0ce70651a bash: re-enable automatic bash shell detection
Bash shell detection was originally disabled in #1823 due to problems
with /bin/bash on macOS.

Apple distributes their own patched version of Bash 3.2 on macOS that
disables the POSIX-style $ENV-based startup path:

e5397a7e74/bash-3.2/shell.c (L1112-L1114)

This means we're unable to perform our automatic shell integration
sequence in this specific environment. Standard Bash 3.2 works fine.

Knowing this, we can re-enable bash shell detection by default unless
we're running "/bin/bash" on Darwin. We can safely assume that's the
unsupported Bash executable because /bin is non-writable on modern macOS
installations due to System Integrity Protection.

macOS users can either manually source our shell integration script
(which otherwise works fine with Apple's Bash) or install a standard
version of Bash from Homebrew or elsewhere.
2024-12-14 17:31:28 -05:00
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
Mitchell Hashimoto
fba10a442c Fish/zsh completion simple fixes (#2964)
Adds -e handling to both completions. Updates eval overhead on fish to
avoid similar adjustments made in #2962. Fixes improperly escaped sed
expression for generating theme names in completions.

I agree to re-license these commits as MIT
2024-12-14 08:23:40 -08: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
Mitchell Hashimoto
a73cb2b258 font: fix sign of usWinDescent interpretation (#2960)
comment explains

In the future we should probably find or craft example fonts that have
weird metrics in their tables and make unit tests for them.
2024-12-13 10:50:37 -08:00
Qwerasd
4573890f22 font: fix sign of usWinDescent interpretation 2024-12-13 13:14:49 -05:00
Mitchell Hashimoto
b2a9af7359 Unified metrics fixes (#2959)
Fix a couple issues that arose from the unified metrics stuff.

One is that cursor sprites weren't rendering wide for wide characters-
I've extracted cursor rendering to a separate file so it's not mixed in
with Box any more, it should be correct now.

The other issue is that I was assuming most fonts had sane `sTypo*`
metrics for vertical sizing, but I was very wrong, so I've replaced the
extraction of the vertical metrics with code that performs a similar
process to what FreeType does to determine a font's ascent. This fixes
the problem, here's an example with a font with the issue:
|Before|After|
|-|-|
|<img width="752" alt="image"
src="https://github.com/user-attachments/assets/71752b0c-35d7-4c35-b5bb-301149d906a7"
/>|<img width="752" alt="image"
src="https://github.com/user-attachments/assets/2f9ae8ce-9f3a-4701-b0fe-e032da7e2246"
/>|
2024-12-13 10:08:25 -08: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
0d0d06e50a Add delay before a title change to avoid flicker on macOS (#2929)
Implements #2503 for macOS

This PR introduces a delay (75ms) before a title change to avoid the
flicker caused by fast running commands.

It adds a timer to `titleDidChange` in the
[BaseTerminalController](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/BaseTerminalController.swift)
to delay the window title update.

However, this alone didn't work with `macos-titlebar-style = tabs` as
the main window title is hidden and toolbar tab titles are set
separately in
[TerminalController](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalController.swift).
I have added another timer in there to avoid flicker for tab titles.

I also tried @qwerasd205's suggested approach by putting the timer in
the
[SurfaceView](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Ghostty/SurfaceView_AppKit.swift)
and setting it inside `setTitle` in
[Ghostty.App](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Ghostty/Ghostty.App.swift),
and that also works. Maybe this a better approach as it avoids having
two timers?

There is still a flicker from the title changing from default "👻
Ghostty" to the current directory when opening new tabs but neither
approach fixes that. Not too sure how to prevent that.

Before:


https://github.com/user-attachments/assets/bd87ff36-9888-4d01-904a-2e80b8edea18

After:


https://github.com/user-attachments/assets/dae8eb24-8ae0-4412-ab84-bf313aac8063
2024-12-13 06:30:36 -08:00
Mitchell Hashimoto
68bf5a9492 ci: on release, only upload appcast after binaries 2024-12-12 21:12:35 -08: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