diff --git a/assets/shell-completion/bash b/assets/shell-completion/bash index 4c57cb937..b9678315f 100644 --- a/assets/shell-completion/bash +++ b/assets/shell-completion/bash @@ -391,7 +391,7 @@ _wezterm() { return 0 ;; wezterm__ls__fonts) - opts="-h --list-system --text --rasterize-ascii --help" + opts="-h --list-system --text --codepoints --rasterize-ascii --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -401,6 +401,10 @@ _wezterm() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --codepoints) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; *) COMPREPLY=() ;; diff --git a/assets/shell-completion/fish b/assets/shell-completion/fish index 00ce538d7..9f68f3b86 100644 --- a/assets/shell-completion/fish +++ b/assets/shell-completion/fish @@ -37,8 +37,9 @@ complete -c wezterm -n "__fish_seen_subcommand_from connect" -l workspace -d 'Ov complete -c wezterm -n "__fish_seen_subcommand_from connect" -l position -d 'Override the position for the initial window launched by this process.' -r complete -c wezterm -n "__fish_seen_subcommand_from connect" -s h -l help -d 'Print help information' complete -c wezterm -n "__fish_seen_subcommand_from ls-fonts" -l text -d 'Explain which fonts are used to render the supplied text string' -r +complete -c wezterm -n "__fish_seen_subcommand_from ls-fonts" -l codepoints -d 'Explain which fonts are used to render the specified unicode code point sequence. Code points are comma separated hex values' -r complete -c wezterm -n "__fish_seen_subcommand_from ls-fonts" -l list-system -d 'Whether to list all fonts available to the system' -complete -c wezterm -n "__fish_seen_subcommand_from ls-fonts" -l rasterize-ascii -d 'Show rasterized glyphs for the text in --text using ascii blocks' +complete -c wezterm -n "__fish_seen_subcommand_from ls-fonts" -l rasterize-ascii -d 'Show rasterized glyphs for the text in --text or --codepoints using ascii blocks' complete -c wezterm -n "__fish_seen_subcommand_from ls-fonts" -s h -l help -d 'Print help information' complete -c wezterm -n "__fish_seen_subcommand_from show-keys" -l key-table -d 'In lua mode, show only the named key table' -r complete -c wezterm -n "__fish_seen_subcommand_from show-keys" -l lua -d 'Show the keys as lua config statements' diff --git a/assets/shell-completion/zsh b/assets/shell-completion/zsh index 2177d7c07..02f31330d 100644 --- a/assets/shell-completion/zsh +++ b/assets/shell-completion/zsh @@ -80,9 +80,10 @@ _arguments "${_arguments_options[@]}" \ ;; (ls-fonts) _arguments "${_arguments_options[@]}" \ -'(--list-system)--text=[Explain which fonts are used to render the supplied text string]:TEXT: ' \ +'(--list-system --codepoints)--text=[Explain which fonts are used to render the supplied text string]:TEXT: ' \ +'(--list-system)--codepoints=[Explain which fonts are used to render the specified unicode code point sequence. Code points are comma separated hex values]:CODEPOINTS: ' \ '--list-system[Whether to list all fonts available to the system]' \ -'--rasterize-ascii[Show rasterized glyphs for the text in --text using ascii blocks]' \ +'--rasterize-ascii[Show rasterized glyphs for the text in --text or --codepoints using ascii blocks]' \ '-h[Print help information]' \ '--help[Print help information]' \ && ret=0 diff --git a/wezterm-gui-subcommands/src/lib.rs b/wezterm-gui-subcommands/src/lib.rs index dbd7d2765..885c3fd84 100644 --- a/wezterm-gui-subcommands/src/lib.rs +++ b/wezterm-gui-subcommands/src/lib.rs @@ -331,10 +331,14 @@ pub struct LsFontsCommand { pub list_system: bool, /// Explain which fonts are used to render the supplied text string - #[clap(long = "text", conflicts_with = "list-system")] + #[clap(long = "text", conflicts_with_all = &["list-system", "codepoints"])] pub text: Option, - /// Show rasterized glyphs for the text in --text using ascii blocks. + /// Explain which fonts are used to render the specified unicode code point sequence. Code points are comma separated hex values. + #[clap(long, conflicts_with = "list-system")] + pub codepoints: Option, + + /// Show rasterized glyphs for the text in --text or --codepoints using ascii blocks. #[clap(long, requires = "text")] pub rasterize_ascii: bool, } diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index d25dd377f..6ebf860a4 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -801,7 +801,23 @@ pub fn run_ls_fonts(config: config::ConfigHandle, cmd: &LsFontsCommand) -> anyho ambiguous_are_wide: config.treat_east_asian_ambiguous_width_as_wide, }; - if let Some(text) = &cmd.text { + let text = match (&cmd.text, &cmd.codepoints) { + (Some(text), _) => Some(text.to_string()), + (_, Some(codepoints)) => { + let mut s = String::new(); + for cp in codepoints.split(",") { + let cp = u32::from_str_radix(cp, 16) + .with_context(|| format!("{cp} is not a hex number"))?; + let c = char::from_u32(cp) + .ok_or_else(|| anyhow!("{cp} is not a valid unicode codepoint value"))?; + s.push(c); + } + Some(s) + } + _ => None, + }; + + if let Some(text) = &text { let line = Line::from_text( text, &CellAttributes::default(),