Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completion of new style X fonts
- X-seq: zsh-workers 30177
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: completion of new style X fonts
- Date: Wed, 01 Feb 2012 17:13:49 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1328112830; bh=HP4zwuzPhY7a61LfS2NnR7VL3dmVZEEuEsaZsWgC9uY=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:From:To:Subject:Date:Message-ID; b=V1TtKsUrdGo1eVtpO9NP2XR5sIRPTFMo1eZ0Zce9xuyNH9H7jmrFjnmkHcSM7kh8HNXhGrRGqzlkFMDApHD+AndFS67cyWWh6CTjjvdigdw/850DKOLOa5cpJuMqGDeYxSm/xBHst202L0uhSTp3QuF00FBL5oy2oZ5njfSUh6Q=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This adds completion for fontconfig style X patterns. At the moment, I'm
only calling it from xterm's -fa option but there may well be other
places.
Oliver
Index: Completion/X/Command/_xterm
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_xterm,v
retrieving revision 1.2
diff -u -r1.2 _xterm
--- Completion/X/Command/_xterm 16 Jan 2002 16:29:52 -0000 1.2
+++ Completion/X/Command/_xterm 1 Feb 2012 16:01:34 -0000
@@ -9,6 +9,7 @@
'-cc:character class:' \
'-cr:text cursor color:_x_color' \
'-e:program: _command_names -e:*::program arguments: _normal' \
+ '-fa:font pattern:_xft_fonts' \
'-fb:bold font:_x_font' \
'-fi:icon font:_x_font' \
'-hc:background color for highlighted text:_x_color' \
Index: Completion/X/Type/_xft_fonts
===================================================================
RCS file: Completion/X/Type/_xft_fonts
diff -N Completion/X/Type/_xft_fonts
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Completion/X/Type/_xft_fonts 1 Feb 2012 16:01:34 -0000
@@ -0,0 +1,43 @@
+#compdef fc-list fc-match
+
+local -a suf
+local font=${${PREFIX//-[0-9]##:/:}%:*}: ret=1
+local attr
+
+compset -S ':*' || suf=( -S: -r "-: \t\n\-" )
+if compset -P '*:'; then
+ attr="${PREFIX%\=*}"
+ if compset -P '*='; then
+ case $attr in
+ hintstyle)
+ _wanted value expl 'value' compadd "$suf[@]" \
+ hint{none,slight,medium,full} && ret=0
+ ;;
+ *)
+ _wanted value expl 'value' compadd "$suf[@]" \
+ ${${(f)"$(_call_program font-attrs
+ fc-list $font $attr 2>/dev/null)"//,/$'\n'}##*=} && ret=0
+ ;;
+ esac
+ else
+ _tags elements {weight,slant,width,spacing}-constants
+ while _tags; do
+ _requested elements expl element compadd -qS= hintstyle hinting autohint \
+ size ${${(u)${(M)${(f)"$(_call_program elements
+ fc-list -v $font 2>/dev/null)"}:# [a-z]*}%%:*}#?} && ret=0
+ _requested weight-constants expl 'weight constant' compadd "$suf[@]" \
+ thin bold regular medium semibold heavy roman && ret=0
+ _requested slant-constants expl 'slant constant' compadd "$suf[@]" \
+ roman italic oblique && ret=0
+
+ (( ret )) || break
+ done
+ fi
+elif compset -P '*[^\\]-'; then
+ _message -e size 'point size' && ret=0
+else
+ _wanted fonts expl font compadd "$suf[@]" \
+ ${${(f)"$(_call_program fonts fc-list 2>/dev/null)"//,/$'\n'}%%:*} && ret=0
+fi
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author