#!/bin/sh
#
# Provide some enhancements to the wxcopy command, which copies standard input
# to an X11 clipboard text buffer.
#
# Allow copying from stdin to any of the cutbuffers.  Note that they are
# indexed counting from 0.
#
# Author: Luke Kendall
#

if [ $# = 0 ]
then
    wxcopy $WXCOPY_DEFS
else
    MYNAME=`basename $0`
    USAGE="usage: $MYNAME [ [0-9]... ] [wxcopy's args]"
    for n
    do
	if expr "x$n" : 'x[0-9][0-9]*$' > /dev/null
	then
	    NUMARGS="$NUMARGS $n"
	elif [ "x$n" = "x-h" ]
	then
	    echo "$USAGE" >&2
	    exit 0
	else
	    WXARGS="$WXARGS $n"
	fi
    done
    set - $NUMARGS
    wxcopy $WXCOPY_DEFS $WXARGS -cutbuffer $1
    ORIG="$1"
    shift
    for n
    do
	wxpaste -cutbuffer $ORIG | wxcopy $WXCOPY_DEFS $WXARGS -cutbuffer $n
    done
fi
