Starting point for the terminal applications.
This commit is contained in:
52
bin/color_picker.sh
Executable file
52
bin/color_picker.sh
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
. ~/cshenv/lib/vulgar.sh
|
||||||
|
|
||||||
|
erase_block 11 1 15 32
|
||||||
|
|
||||||
|
create_button Red 12 2 Red 1
|
||||||
|
highlight_button Red
|
||||||
|
#build_box 12 2 14 8
|
||||||
|
#write_string "Red" 13 4
|
||||||
|
#fill_block_attributes 12 2 14 8 41
|
||||||
|
|
||||||
|
create_button Green 12 12 Green 2
|
||||||
|
#build_box 12 12 14 20
|
||||||
|
#write_string "Green" 13 14
|
||||||
|
|
||||||
|
create_button Blue 12 24 Blue 4
|
||||||
|
#build_box 12 24 14 31
|
||||||
|
#write_string "Blue" 13 26
|
||||||
|
|
||||||
|
Buttons=("Red" "Green" "Blue")
|
||||||
|
Index=0
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
read_key codes
|
||||||
|
sym=`translate_key ${codes}`
|
||||||
|
|
||||||
|
OldIndex=${Index}
|
||||||
|
|
||||||
|
if [ "${sym}" == "Right" ]
|
||||||
|
then
|
||||||
|
if (( ${Index} < $(( ${#Buttons} - 1 )) ))
|
||||||
|
then
|
||||||
|
Index=$(( ${Index} + 1 ))
|
||||||
|
|
||||||
|
unhighlight_button ${Buttons[${OldIndex}]}
|
||||||
|
highlight_button ${Buttons[${Index}]}
|
||||||
|
fi
|
||||||
|
elif [ "${sym}" == "Left" ]
|
||||||
|
then
|
||||||
|
if (( ${Index} > 0 ))
|
||||||
|
then
|
||||||
|
Index=$(( ${Index} - 1 ))
|
||||||
|
|
||||||
|
unhighlight_button ${Buttons[${OldIndex}]}
|
||||||
|
highlight_button ${Buttons[${Index}]}
|
||||||
|
fi
|
||||||
|
elif [ "${sym}" == "Escape" ]
|
||||||
|
then
|
||||||
|
#erase_block 11 1 15 32
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
5
bin/term_clock.sh
Executable file
5
bin/term_clock.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
. ~/cshenv/lib/vulgar.sh
|
||||||
|
|
||||||
|
get_terminal_size rows cols
|
||||||
|
|
||||||
|
echo "Terminal is ${rows} rows and ${cols} cols"
|
@ -282,57 +282,40 @@ unhighlight_button()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_terminal_size()
|
||||||
|
{
|
||||||
|
send_csi_command t 18
|
||||||
|
read_key _seq
|
||||||
|
|
||||||
|
|
||||||
|
# Consume ^[[8;
|
||||||
|
|
||||||
erase_block 11 1 15 32
|
echo "Pre Array: ${_seq}"
|
||||||
|
_seq=(${_seq})
|
||||||
|
echo "Array: ${_seq}"
|
||||||
|
_seq=(${_seq[@]:4})
|
||||||
|
echo "Trimmed Array: ${_seq}"
|
||||||
|
|
||||||
create_button Red 12 2 Red 1
|
_rows=0
|
||||||
highlight_button Red
|
while [ "${_seq[ 0 ]}" != ";" ]
|
||||||
#build_box 12 2 14 8
|
do
|
||||||
#write_string "Red" 13 4
|
_rchar="${_seq[ 0 ]}"
|
||||||
#fill_block_attributes 12 2 14 8 41
|
echo "RChar: ${_rchar}"
|
||||||
|
_seq=${_seq[@]:1}
|
||||||
|
|
||||||
create_button Green 12 12 Green 2
|
#_rows=$(( ${_rows} * 16 + $( printf "\x${_rchar}" ) ))
|
||||||
#build_box 12 12 14 20
|
done
|
||||||
#write_string "Green" 13 14
|
|
||||||
|
|
||||||
create_button Blue 12 24 Blue 4
|
|
||||||
#build_box 12 24 14 31
|
|
||||||
#write_string "Blue" 13 26
|
|
||||||
|
|
||||||
Buttons=("Red" "Green" "Blue")
|
_cols=0
|
||||||
Index=0
|
while [ "${_seq[ 0 ]}" != ";" ]
|
||||||
|
do
|
||||||
|
_cchar="${_seq[ 0 ]}"
|
||||||
|
_seq=${_seq[@]:1}
|
||||||
|
|
||||||
while true
|
#_cols=$(( ${_cols} * 16 + $( printf "\x${_cchar}" ) ))
|
||||||
do
|
done
|
||||||
read_key codes
|
|
||||||
sym=`translate_key ${codes}`
|
|
||||||
|
|
||||||
OldIndex=${Index}
|
eval $1=\"${_rows}\"
|
||||||
|
eval $2=\"${_cols}\"
|
||||||
if [ "${sym}" == "Right" ]
|
}
|
||||||
then
|
|
||||||
if (( ${Index} < $(( ${#Buttons} - 1 )) ))
|
|
||||||
then
|
|
||||||
Index=$(( ${Index} + 1 ))
|
|
||||||
|
|
||||||
unhighlight_button ${Buttons[${OldIndex}]}
|
|
||||||
highlight_button ${Buttons[${Index}]}
|
|
||||||
fi
|
|
||||||
elif [ "${sym}" == "Left" ]
|
|
||||||
then
|
|
||||||
if (( ${Index} > 0 ))
|
|
||||||
then
|
|
||||||
Index=$(( ${Index} - 1 ))
|
|
||||||
|
|
||||||
unhighlight_button ${Buttons[${OldIndex}]}
|
|
||||||
highlight_button ${Buttons[${Index}]}
|
|
||||||
fi
|
|
||||||
elif [ "${sym}" == "Escape" ]
|
|
||||||
then
|
|
||||||
#erase_block 11 1 15 32
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
Reference in New Issue
Block a user