diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-10-23 07:16:47 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-23 07:16:47 +0000 |
commit | 1df7dc5171abfe1eab3e95be964f61c5876198f1 (patch) | |
tree | 315ceaa093b86b8e875512825302f38e32f697a4 /extra/completions | |
parent | d8a98f88295e59d6518ae780a9857c033a83161c (diff) | |
download | alacritty-1df7dc5171abfe1eab3e95be964f61c5876198f1.tar.gz alacritty-1df7dc5171abfe1eab3e95be964f61c5876198f1.zip |
Add multi-window support
Previously Alacritty would always initialize only a single terminal
emulator window feeding into the winit event loop, however some
platforms like macOS expect all windows to be spawned by the same
process and this "daemon-mode" can also come with the advantage of
increased memory efficiency.
The event loop has been restructured to handle all window-specific
events only by the event processing context with the associated window
id. This makes it possible to add new terminal windows at any time using
the WindowContext::new function call.
Some preliminary tests have shown that for empty terminals, this reduces
the cost of additional terminal emulators from ~100M to ~6M. However at
this point the robustness of the daemon against issues with individual
terminals has not been refined, making the reliability of this system
questionable.
New windows can be created either by using the new `CreateNewWindow`
action, or with the `alacritty msg create-window` subcommand. The
subcommand sends a message to an IPC socket which Alacritty listens on,
its location can be found in the `ALACRITTY_SOCKET` environment
variable.
Fixes #607.
Diffstat (limited to 'extra/completions')
-rw-r--r-- | extra/completions/_alacritty | 74 | ||||
-rw-r--r-- | extra/completions/alacritty.bash | 9 | ||||
-rw-r--r-- | extra/completions/alacritty.fish | 62 |
3 files changed, 110 insertions, 35 deletions
diff --git a/extra/completions/_alacritty b/extra/completions/_alacritty index c97d563e..1313128e 100644 --- a/extra/completions/_alacritty +++ b/extra/completions/_alacritty @@ -1,20 +1,62 @@ #compdef alacritty -local ign +# Completions available for the first parameter. +_alacritty_first_param() { + # Main subcommands. + _describe "command" "(msg:'Available socket messages')" -(( $#words > 2 )) && ign='!' + # Default options. + _alacritty_main +} + +# Completions available for parameters after the first. +_alacritty_following_param() { + case $words[2] in + msg) + _alacritty_msg;; + *) + _alacritty_main;; + esac +} + +# Completions for the main Alacritty executable. +_alacritty_main() { + # Limit some suggestions to the first option. + local ignore + (( $#words > 2 )) && ignore='!' + + _arguments \ + "$ignore(-)"{-h,--help}"[print help information]" \ + "$ignore(-)"{-V,--version}"[print version information]" \ + "--print-events[print all events to stdout]" \ + '(-v)'{-q,-qq}"[reduce the level of verbosity (min is -qq)]" \ + "--ref-test[generate ref test]" \ + "--hold[remain open after child process exits]" \ + '(-q)'{-v,-vv,-vvv}"[increase the level of verbosity (max is -vvv)]" \ + "--class=[define the window class]:class" \ + "--embed=[define the X11 window ID (as a decimal integer) to embed Alacritty within]:windowId" \ + "(-e --command)"{-e,--command}"[execute command (must be last arg)]:program: _command_names -e:*::program arguments: _normal" \ + "--config-file=[specify an alternative config file]:file:_files" \ + "*"{-o=,--option=}"[override config file options]:option" \ + "(-t --title)"{-t=,--title=}"[define the window title]:title" \ + "--working-directory=[start shell in specified directory]:directory:_directories"\ + "--socket=[Path for IPC socket creation]:file:_files" +} + +# Completions for the `msg` subcommand. +_alacritty_msg() { + # Limit some suggestions to the first option. + local ignore + (( $#words > 3 )) && ignore='!' + + _arguments \ + "$ignore(-)"{-h,--help}"[print help information]" \ + "$ignore(-)"{-V,--version}"[print version information]" \ + "(-s --socket)"{-s=,--socket=}"[Path for IPC socket creation]:file:_files" \ + "*: :((create-window:'Create a new window in the same Alacritty process'))" +} + +# Handle arguments based on their position. _arguments \ - "$ign(-)"{-h,--help}"[print help information]" \ - "--print-events[print all events to stdout]" \ - '(-v)'{-q,-qq}"[reduce the level of verbosity (min is -qq)]" \ - "--ref-test[generate ref test]" \ - "--hold[remain open after child process exits]" \ - '(-q)'{-v,-vv,-vvv}"[increase the level of verbosity (max is -vvv)]" \ - "$ign(-)"{-V,--version}"[print version information]" \ - "--class=[define the window class]:class" \ - "--embed=[define the X11 window ID (as a decimal integer) to embed Alacritty within]:windowId" \ - "(-e --command)"{-e,--command}"[execute command (must be last arg)]:program: _command_names -e:*::program arguments: _normal" \ - "--config-file=[specify an alternative config file]:file:_files" \ - "*"{-o=,--option=}"[override config file options]:option" \ - "(-t --title)"{-t=,--title=}"[define the window title]:title" \ - "--working-directory=[start shell in specified directory]:directory:_directories" + "1: :_alacritty_first_param" \ + "*: :_alacritty_following_param" diff --git a/extra/completions/alacritty.bash b/extra/completions/alacritty.bash index e514126c..464afe6e 100644 --- a/extra/completions/alacritty.bash +++ b/extra/completions/alacritty.bash @@ -11,7 +11,7 @@ _alacritty() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" prevprev="${COMP_WORDS[COMP_CWORD-2]}" - opts="-h --help -V --version --print-events -q -qq -v -vv -vvv --ref-test --hold -e --command --config-file -o --option -t --title --embed --class --working-directory" + opts="-h --help -V --version --print-events -q -qq -v -vv -vvv --ref-test --hold -e --command --config-file -o --option -t --title --embed --class --working-directory --socket msg" # If `--command` or `-e` is used, stop completing for i in "${!COMP_WORDS[@]}"; do @@ -29,8 +29,8 @@ _alacritty() # Complete all commands in $PATH COMPREPLY=( $(compgen -c -- "${cur}") ) return 0;; - --config-file) - # Path based completion + --config-file | --socket) + # File completion local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- "${cur}") ) @@ -44,6 +44,9 @@ _alacritty() compopt -o filenames COMPREPLY=( $(compgen -d -- "${cur}") ) return 0;; + msg) + COMPREPLY=( $(compgen -W "-h --help -V --version -s --socket" -- "${cur}") ) + return 0;; esac # Show all flags if there was no previous word diff --git a/extra/completions/alacritty.fish b/extra/completions/alacritty.fish index 6f8da9b0..fa399ffb 100644 --- a/extra/completions/alacritty.fish +++ b/extra/completions/alacritty.fish @@ -1,74 +1,104 @@ +# Available subcommands +set -l commands msg help + +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ + -a "msg help" + # Meta complete -c alacritty \ + -n "not __fish_seen_subcommand_from help" \ -s "v" \ -l "version" \ -d "Prints version information" complete -c alacritty \ + -n "not __fish_seen_subcommand_from help" \ -s "h" \ -l "help" \ -d "Prints help information" # Config complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -f \ -l "config-file" \ -d "Specify an alternative config file" complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "t" \ -l "title" \ -d "Defines the window title" complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -l "class" \ -d "Defines the window class" complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -l "embed" \ -d "Defines the X11 window ID (as a decimal integer) to embed Alacritty within" complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -x \ -a '(__fish_complete_directories (commandline -ct))' \ -l "working-directory" \ -d "Start shell in specified directory" complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -l "hold" \ -d "Remain open after child process exits" complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "o" \ -l "option" \ -d "Override config file options" +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ + -l "socket" \ + -d "Path for IPC socket creation" # Output -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -l "print-events" \ -d "Print all events to stdout" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "q" \ -d "Reduces the level of verbosity (min is -qq)" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "qq" \ -d "Reduces the level of verbosity" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "v" \ -d "Increases the level of verbosity" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "vv" \ -d "Increases the level of verbosity" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "vvv" \ -d "Increases the level of verbosity" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -l "ref-test" \ -d "Generates ref test" -complete \ - -c alacritty \ +complete -c alacritty \ + -n "not __fish_seen_subcommand_from $commands" \ -s "e" \ -l "command" \ -d "Execute command (must be last arg)" + +# Subcommand `msg` +complete -c alacritty \ + -n "__fish_seen_subcommand_from msg" \ + -s "s" \ + -l "socket" \ + -d "Socket path override" +complete -c alacritty \ + -n "__fish_seen_subcommand_from msg" \ + -a "create-window help" |