Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completing fonts again, updated _urxvt
- X-seq: zsh-workers 30801
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: completing fonts again, updated _urxvt
- Date: Fri, 16 Nov 2012 23:25:21 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1353104722; bh=TUE5sj7leZ2Sg6/CXIDUZUJMYRiHXRC8S3OOf4QUG2Y=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:From:To:Subject:Date:Message-ID; b=vrC1Ql9W5chUEqXDWt82fKbqdBPG4Xf7oIeycoC2q37iys0qO8ibW5QbOMC4pr6O8dM5+IU4JRrONdU30eCaADl3Zq+YeAsXJzQLMpiShCCz7ahsZ68Voi+mUcsKDl6Sj50BoQqEwqn9jWakKLRATIZQjUgmykDmneq1KGmBhgg=
- 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
It seems some (possibly newer) versions of fc-list output the font file
names by default breaking the _xft_fonts completion. fc-list is not well
documented but I decided to go with fc-list -f '%{family},' instead of
fc-list : family because it ends up being shorter. This might not work
on older systems however.
There isn't actually a standard way to specify XFT style fonts. Both
xterm and urxvt use the same as fc-list but vim takes family and size
separated by a space. Other programs may do other things but I'll wait
and see before making _xft_fonts more customisable.
Oliver
Index: Completion/X/Command/_urxvt
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_urxvt,v
retrieving revision 1.3
diff -u -r1.3 _urxvt
--- Completion/X/Command/_urxvt 25 Aug 2005 19:51:03 -0000 1.3
+++ Completion/X/Command/_urxvt 16 Nov 2012 22:15:11 -0000
@@ -1,39 +1,72 @@
-#compdef urxvt
+#compdef rxvt urxvt urxvtc
+
+local curcontext="$curcontext" state line expl ret=1
+local -a suf long_args
+typeset -A opt_args
+typeset -U extensions
+
+[[ -prefix -- ]] || zstyle -T ":completion:${curcontext}:options" prefix-needed &&
+ : ${(A)long_args:=${${${${${${${(M)${(f)"$(urxvt --help 2>&1)"}:# *:*}/ /--}// /}/fontname/fontname:->fonts}/:color/:color:_x_color}/boolean/boolean:(true false)}/:(searchpath|file)/:path:_files}}
_x_arguments \
- -+{rv,ls,j,ptab,sb,sr,st,si,sk,sw,ip,ipf,ut,vb,tcw,insecure,uc,bc,pb,bl,ssc,ssr} \
- '-tn:terminal type:' \
+ -+{rv,ls,j,ss,ptab,sb,sr,st,si,sk,sw,ip,tr,ut,vb,tcw,insecure,uc,bc,pb,is,override-redirect,hold,bl,sbg,ssc,ssr} \
+ '-tn[specify value of TERM]:terminal type:_terminals' \
'-C[intercept console messages]' \
'-iconic[start iconic]' \
- '-sbt[scroll bar thickness]:pixels:' \
+ '-cd[start shell in specific directory]:directory:_files -/' \
+ '-sbt[scroll bar thickness]:pixels' \
'-tint[tint color]:color:_x_color' \
- '-fade[make colors darker when losing focus]:percentage:' \
- '-sh[shade background when tinting]:percentage:' \
- '-bg:background color:_x_color' \
- '-fg:foreground color:_x_color' \
- '-cr:cursor color:_x_color' \
- '-pr:pointer color:_x_color' \
- '-pr2:pointer background color:_x_color' \
- '-bd:border color:_x_color' \
+ '-fade[make colors darker when losing focus]:percentage' \
+ '-fadecolor[specify target color for off-focus fading]:color:_x_color' \
+ '-sh[shade background when tinting]:percentage' \
+ '-bg[background color]:color:_x_color' \
+ '-fg[foreground color]:color:_x_color' \
+ '-hc[highlight color]:color:_x_color' \
+ '-cr[cursor color]:color:_x_color' \
+ '-pr[pointer color]:color:_x_color' \
+ '-pr2[pointer background color]:color:_x_color' \
+ '-bd[border color]:color:_x_color' \
'-pixmap:pixmap:_files' \
- '-fn:normal font:_x_font' \
- '-fb:bold font:_x_font' \
- '-fi:italic font:_x_font' \
- '-fbi:bold italic font:_x_font' \
+ '-icon[specify icon image]:image file:_files' \
+ '-fn:normal font:->fonts' \
+ '-fb:bold font:->fonts' \
+ '-fi:italic font:->fonts' \
+ '-fbi:bold italic font:->fonts' \
'-im:input method:(SCIM)' \
+ '-pe[enable perl extension]:perl extension:->extensions' \
'-pt:input style:(OverTheSpot OffTheSpot Root)' \
'-imlocale:locale input method:_locales' \
'-imfont:fontset for styles OverTheSpot and OffTheSpot:_x_font' \
- '-name:client instance, icon, and title strings:' \
- '-title:title name for window:' \
- '-n:icon name for window:' \
- '-sl:save lines:' \
+ '-name:client instance, icon, and title strings' \
+ '(-T -title)'{-T,-title}':title name for window' \
+ '-n:icon name for window' \
+ '-sl:save lines' \
'-embed:window id to embed terminal in:_x_window' \
- '-pty-fd:file descriptor of pty to use:' \
- '-w:external border in pixels:' \
- '-b:internal border in pixels:' \
- '-lsp:number of extra pixels between rows:' \
+ '-pty-fd:file descriptor of pty to use' \
+ '-w:external border in pixels' \
+ '-b:internal border in pixels' \
+ '-lsp:number of extra pixels between rows' \
+ '-letsp:letter spacing adjustment' \
'-mod:meta modifier:_x_modifier' \
'-e:program: _command_names -e:*::program arguments: _normal' \
'-help[print help]' \
- '--help[list long options]'
+ '--help[list long options]' $long_args && ret=0
+
+case $state in
+ fonts)
+ if compset -P xft:; then
+ _xft_fonts && ret=0
+ else
+ _x_font && ret=0
+ fi
+ ;;
+ extensions)
+ compset -S ',*' || suf=( -qS , )
+ compset -P '*,'; compset -P -
+ extensions=( {$commands[urxvt]:h:h,/usr,/usr/local}/lib{,64}/urxvt/perl(N) )
+ _wanted extensions expl 'perl extension' compadd $suf[@] default \
+ $extensions/*(:t) && ret=0
+ ;;
+esac
+
+return ret
Index: Completion/X/Type/_xft_fonts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Type/_xft_fonts,v
retrieving revision 1.1
diff -u -r1.1 _xft_fonts
--- Completion/X/Type/_xft_fonts 10 Feb 2012 12:41:38 -0000 1.1
+++ Completion/X/Type/_xft_fonts 16 Nov 2012 22:15:11 -0000
@@ -37,7 +37,7 @@
_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
+ ${(us:,:)$(_call_program fonts fc-list -f '%\{family\},' 2>/dev/null)} && ret=0
fi
return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author