bash-completion.sh
branchv_0
changeset 10 ded44e94147c
parent 8 8ef1980db907
child 11 07247893054e
equal deleted inserted replaced
9:0d362165241e 10:ded44e94147c
    11 # GNU General Public License for more details.
    11 # GNU General Public License for more details.
    12 #
    12 #
    13 # You should have received a copy of the GNU General Public License
    13 # You should have received a copy of the GNU General Public License
    14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
    14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
    15 
    15 
       
    16 _relpipe_in_jack_completion_ports() {
       
    17 	# TODO: simpler and faster implementation in relpipe-out-jack or relpipe-in-jack C++ code
       
    18 	jack_lsp -tp 2>/dev/null \
       
    19 		| tr -d \\t \
       
    20 		| tr \\n \\0 \
       
    21 		| relpipe-in-cli \
       
    22 			--relation "jack_midi_port" \
       
    23 			--attribute "name" string \
       
    24 			--attribute "properties" string \
       
    25 			--attribute "type" string \
       
    26 			--records-on-stdin true \
       
    27 		| relpipe-tr-grep '.*' 'properties' 'output' \
       
    28 		| relpipe-tr-grep '.*' 'type' 'midi' \
       
    29 		| relpipe-tr-cut '.*' 'name' \
       
    30 		| relpipe-out-nullbyte \
       
    31 		| tr \\0 \\n
       
    32 }
       
    33 
    16 _relpipe_in_jack_completion() {
    34 _relpipe_in_jack_completion() {
    17 	local w0 w1 w2 w3
    35 	local w0 w1 w2 w3
    18 
    36 
    19 	COMPREPLY=()
    37 	COMPREPLY=()
    20 	w0=${COMP_WORDS[COMP_CWORD]}
    38 	w0=${COMP_WORDS[COMP_CWORD]}
    21 	w1=${COMP_WORDS[COMP_CWORD-1]}
    39 	w1=${COMP_WORDS[COMP_CWORD-1]}
    22 	w2=${COMP_WORDS[COMP_CWORD-2]}
    40 	w2=${COMP_WORDS[COMP_CWORD-2]}
    23 	w3=${COMP_WORDS[COMP_CWORD-3]}
    41 	w3=${COMP_WORDS[COMP_CWORD-3]}
    24 
    42 
    25 	BOOLEAN=(
    43 	  if [[ "$w1" == "--jack-client-name"             && "x$w0" == "x" ]];    then COMPREPLY=("'relpipe-in-jack'")
    26 		"true"
    44 	elif [[ "$w1" == "--jack-connect-to-port"                          ]];    then COMPREPLY=($(compgen -W "$(_relpipe_in_jack_completion_ports)" -- "$w0"))
    27 		"false"
    45 	elif [[ "$w1" == "--required-jack-connections"    && "x$w0" == "x" ]];    then COMPREPLY=("0")
    28 	)
       
    29 
       
    30 	if   [[ "$w1" == "--TODO"                                          ]];    then COMPREPLY=($(compgen -W "${BOOLEAN[*]}" -- "$w0"))
       
    31 	elif [[ "$w1" == "--jack-client-name"             && "x$w0" == "x" ]];    then COMPREPLY=("'relpipe-in-jack'")
       
    32 	else
    46 	else
    33 		OPTIONS=(
    47 		OPTIONS=(
    34 			"--jack-client-name"
    48 			"--jack-client-name"
       
    49 			"--jack-connect-to-port"
       
    50 			"--required-jack-connections"
    35 		)
    51 		)
    36 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    52 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    37 	fi
    53 	fi
    38 }
    54 }
    39 
    55