summary refs log tree commit diff
path: root/Completion/X
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2012-02-10 12:41:37 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2012-02-10 12:41:37 +0000
commitb627021d6fe493b9da3204cf87f5f3b43d071eb1 (patch)
tree9a62fe910983539b2df99b57e40e5c8b85baf08d /Completion/X
parent3489c1579916c588bfda59b931620a96c86c4a34 (diff)
downloadzsh-b627021d6fe493b9da3204cf87f5f3b43d071eb1.tar.gz
zsh-b627021d6fe493b9da3204cf87f5f3b43d071eb1.tar.xz
zsh-b627021d6fe493b9da3204cf87f5f3b43d071eb1.zip
30177: completion for fontconfig fonts
Diffstat (limited to 'Completion/X')
-rw-r--r--Completion/X/Command/_xterm1
-rw-r--r--Completion/X/Type/_xft_fonts43
2 files changed, 44 insertions, 0 deletions
diff --git a/Completion/X/Command/_xterm b/Completion/X/Command/_xterm
index a246ab48e..7619b280a 100644
--- a/Completion/X/Command/_xterm
+++ b/Completion/X/Command/_xterm
@@ -9,6 +9,7 @@ _xt_arguments \
   '-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' \
diff --git a/Completion/X/Type/_xft_fonts b/Completion/X/Type/_xft_fonts
new file mode 100644
index 000000000..0d5f56fe5
--- /dev/null
+++ b/Completion/X/Type/_xft_fonts
@@ -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}-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