zsh-workers
 help / color / mirror / code / Atom feed
* MPlayer completion fonction
@ 2001-12-30 16:15 Bruno Bonfils
  2001-12-30 22:16 ` Clint Adams
  2002-01-02 18:12 ` Oliver Kiddle
  0 siblings, 2 replies; 3+ messages in thread
From: Bruno Bonfils @ 2001-12-30 16:15 UTC (permalink / raw)
  To: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 298 bytes --]

hi,

i submit you the first completion function for mplayer.

i don't know how to use pattern matching in order to take only
driver of a mplayer -vo help. (how to suppress the first line ?)
if you have an idea...

++

-- 
 Bruno Bonfils
 Admin Sys GNU/Linux

 http://www.oxianet.com

[-- Attachment #1.2: _mplayer --]
[-- Type: text/plain, Size: 4949 bytes --]

#compdef mplayer

#
# MPlayer Zsh function
#
# Dec 2001, Bruno Bonfils <asyd@zshfr.org>
#

_audio-codec-list ()
{
    local list
    list=(${$(mplayer -ac help | sed '1,7d' | more | awk '{ print $1 }\' )})
    _wanted audio-codec expl 'audio-codec require' compadd $list
}

_video-codec-list ()
{
    local list
    list=(${$(mplayer -vc help | sed '1,7d' | more | awk '{ print $1 }\' )})
    _wanted video-codec expl 'video-codec require' compadd $list
}

_video-driver-list ()
{
    local list
    list=(${$(mplayer -vo help | sed '1,5d' | cut -f 2)})
    _wanted video-driver expl 'video-driver require' compadd $list
}

_audio-driver-list ()
{
    local list
    list=(${$(mplayer -ao help | sed '1,5d' | cut -f 2)})
    _wanted audio-driver expl 'audio-driver require' compadd $list
}

_arguments -C -s \
    '-framedrop[enable slow dropping (for slow machine)]' \
    '-nobps[use alternative A-V sync method for AVI files]' \
    '-fs[fullscreen]' \
    '-gui[start with the gui]' \
    '-nosound[no sound]' \
    '-dvd[tell MPlayer which movies to play]:titleid' \
    '-chapter[specify which chapter to start playing at]:chapter' \
    '-vo[video driver]:video-driver attachment:_video-driver-list' \
    '-ao[audio driver]:audio-driver attachment:_audio-driver-list' \
    '-vcd[play video cd track]:track' \
    '-vm[use XF86VidMode extension for mode changing]' \
    '-zoom[use software scaling, where available (use with -nofs)]' \
    '-x[scale image to x width if driver supports]:width' \
    '-y[scale image to y height if driver supports]:height' \
    '-xy[scale image by factor if driver supports]:factor' \
    '-pp[apply postprocess filter]:filter attachment:_filter-list' \
    '-ffactor[resample alphmap of the font]:factor:(0 0.75 1 10)' \
    '-sub[use/display this subtitle file]:subtitle:_files' \
    '-subfps[specify frame/sec rate of subtitle file only]:rate' \
    '-osdlevel[specifies which mode the osd should start]:osd-level:(0 1 2)' \
    '-lircconf[specifies a configfile for lirc]:lirc-config-files attachment:_files' \
    '-v[enable verbose output]' \
    '-quiet[display less output, status messages]' \
    '-benchmark[use with combination with -nosound and -vo null for benchmarking]' \
    '-skin[skin directory]:skin directory:_path_files -/' \
    '-aspect[set aspect ratio of movies]:ratio' \
    '-monitoraspect[set aspect ratio of your screen]:ratio' \
    '-vc[force usage of a specific video codec]:video-codec attachment:_video-codec-list' \
    '-ac[force usage of a specific audio codec]:audio-codec attachment:_audio-codec-list' \
    '-vfm[force usage of a specific video codec family]:video-codec-family:(1 2 3 4 5)' \
    '-afm[force usage of a specific audio codec family]:audio-codec-family:(1 2 3 4 5)' \
    '-sb[seek to byte position]:byte' \
    '-ss[seek to given time position (format hh:mm\[:ss\])]:position' \
    '-abs[sound carte audio buffer size(in bytes, default: measuring)]' \
    '-delay[audio delay in seconds (may be +/- float value)]:delay' \
    '-nobps[do not use avg byte/sec value for A-V sync (AVI)]' \
    '-aid[select audio channel]:audio-channel' \
    '-vid[select video channel]:video-channel' \
    '-fps[force frame rate (if value is wrong in the header)]:frame-rate' \
    '-mc[maximun sync correction per 5 frames (in second)]:max-sync-correction' \
    '-ni[force usage of non-interlaced avi parser]' \
    '-include[specify config file to be parsed after the default]:config-file:_files' \
    '-z[specify compression level for png output]:compression-level:(0 1 2 3 4 5 6 7 8)' \
    '-idx[rebuilds index of the avi]' \
    '-forceidx[force rebuilding of index]' \
    '-nodshow[disable usage of directshow video codecs]' \
    '-forcexv[force using xvideo (sdl)]' \
    '-dumpaudio[writes audio stream of the file to ./stream.dump]' \
    '-noframedrop[no frame dropping]' \
    '-framedrop[frame dropping]' \
    '-nodouble[disable double buffering (default)]' \
    '-double[enable double buffering]' \
    '-dvdkey[key to decrypt stream encoded with css]:key' \
    '-steromode[select type of mpeg1 stereo output]:stereo-mode:(0 1 2)' \
    '-srate[specifies Hz to playback audio on]:frequence' \
    '-config[specifies where to search for config files]' \
    '-display[specify the hostname and display number of the X server]:x-display' \
    '-unicode[tells mplayer to handle the subtitle file as unicode]' \
    '-utf8[tells mplayer to handle the subtitle file as utf8]' \
    '-fsmode[fullscreen mode]:fs-mode:(0 1 2 3)' \
    '-frames[mplayer plays number frame, and quits]:frame-number' \
    '-fb[specifies the framebuffer device to user]' \
    '-fbmode[change videomode from /etc/fb.modes]:fbmode' \
    '-fbmodeconfig[use config file instead /etc/fb.modes]:fbmodeconfig:_files' \
    '*:video file:_files -g \*.\(\#i\)avi \*.\(\#i\)mpeg \*.\(\#i\)mpg \*.\(\#i\)mov \*.\(\#i\)asf \*.\(\#i\)vob \*.\(\#i\)mjpg' \
    && return 0

return 1

[-- Attachment #2: Type: application/pgp-signature, Size: 249 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MPlayer completion fonction
  2001-12-30 16:15 MPlayer completion fonction Bruno Bonfils
@ 2001-12-30 22:16 ` Clint Adams
  2002-01-02 18:12 ` Oliver Kiddle
  1 sibling, 0 replies; 3+ messages in thread
From: Clint Adams @ 2001-12-30 22:16 UTC (permalink / raw)
  To: Bruno Bonfils, zsh-workers

> i don't know how to use pattern matching in order to take only
> driver of a mplayer -vo help. (how to suppress the first line ?)
> if you have an idea...

${${${(M)${(f)"$(mplayer -vo help)"}:#	*}/	/}/	/:}

Assuming they don't change the output format, this will find all
relevant lines by virtue of the beginning TAB, discard them, then replace
the second tabs with colons in case you want to use those descriptions
(and why waste free descriptions?).

All blocks of whitespace in that line should be literal TABs, by the
way.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MPlayer completion fonction
  2001-12-30 16:15 MPlayer completion fonction Bruno Bonfils
  2001-12-30 22:16 ` Clint Adams
@ 2002-01-02 18:12 ` Oliver Kiddle
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2002-01-02 18:12 UTC (permalink / raw)
  To: Bruno Bonfils; +Cc: zsh-workers

Bruno Bonfils wrote:
> 
> i submit you the first completion function for mplayer.

I've had a glance and it looks good.

> i don't know how to use pattern matching in order to take only
> driver of a mplayer -vo help. (how to suppress the first line ?)
> if you have an idea...

To just suppress the first line, it would be something like
  ${${(f)"$(mplayer -vo help)"}[2,-1]}
but I don't know what the output looks like so I expect Clint's
answer will be more useful.

> _audio-codec-list ()
> {
>     local list
>     list=(${$(mplayer -ac help | sed '1,7d' | more | awk '{ print $1 }\' )})
>     _wanted audio-codec expl 'audio-codec require' compadd $list
> }

You'll need to declare expl local in these functions too.

What is the more command in the pipeline for?

You can probably replace the pipeline with some sort of zsh
substitution which would be more efficient but less readable. In this
case, it'll be something like:
   list=( ${${(f)"$(mplayer -ac help)"}[8,-1]%% *} )

You can also make it more efficient by using `compadd -a list'

>     '-ffactor[resample alphmap of the font]:factor:(0 0.75 1 10)' \

typo - should be alphamap

>    '-skin[skin directory]:skin directory:_path_files -/' \

You might want to look at the _path_files -W option here to complete
from within ~/.mplayer/Skin and /usr/local/share/mplayer/Skin.

>     '-abs[sound carte audio buffer size(in bytes, default: measuring)]' \

wrong language for the word card.

>    '-display[specify the hostname and display number of the X server]:x-display

You can call _x_display to complete display names. Or use _x_arguments instead
of _arguments to get a number of common X arguments automatically.

>     '-fb[specifies the framebuffer device to user]' \

-fb should take a parameter I think for the device.

Oliver

This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a pro-active anti-virus service working around the clock, around the globe visit http://www.messagelabs.com/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-01-02 18:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-30 16:15 MPlayer completion fonction Bruno Bonfils
2001-12-30 22:16 ` Clint Adams
2002-01-02 18:12 ` Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).