add wezterm ls-fonts --codepoints

This commit is contained in:
Wez Furlong committed 2022-09-20 22:06:03 -07:00
1 parent 4d45bd7bc4
commit b11451f727
5 files changed
+33 -7

No files matched your search

+5 -1
View File
@@ -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=()
;;
+2 -1
View File
@@ -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'
+3 -2
View File
@@ -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
+6 -2
View File
@@ -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<String>,
/// 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<String>,
/// Show rasterized glyphs for the text in --text or --codepoints using ascii blocks.
#[clap(long, requires = "text")]
pub rasterize_ascii: bool,
}
+17 -1
View File
@@ -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(),