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
|
||||
}
|
||||
|
||||
get_terminal_size()
|
||||
{
|
||||
send_csi_command t 18
|
||||
read_key _seq
|
||||
|
||||
|
||||
# Consume ^[[8;
|
||||
|
||||
echo "Pre Array: ${_seq}"
|
||||
_seq=(${_seq})
|
||||
echo "Array: ${_seq}"
|
||||
_seq=(${_seq[@]:4})
|
||||
echo "Trimmed Array: ${_seq}"
|
||||
|
||||
_rows=0
|
||||
while [ "${_seq[ 0 ]}" != ";" ]
|
||||
do
|
||||
_rchar="${_seq[ 0 ]}"
|
||||
echo "RChar: ${_rchar}"
|
||||
_seq=${_seq[@]:1}
|
||||
|
||||
#_rows=$(( ${_rows} * 16 + $( printf "\x${_rchar}" ) ))
|
||||
done
|
||||
|
||||
|
||||
erase_block 11 1 15 32
|
||||
_cols=0
|
||||
while [ "${_seq[ 0 ]}" != ";" ]
|
||||
do
|
||||
_cchar="${_seq[ 0 ]}"
|
||||
_seq=${_seq[@]:1}
|
||||
|
||||
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
|
||||
#_cols=$(( ${_cols} * 16 + $( printf "\x${_cchar}" ) ))
|
||||
done
|
||||
|
||||
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
|
||||
eval $1=\"${_rows}\"
|
||||
eval $2=\"${_cols}\"
|
||||
}
|
Reference in New Issue
Block a user