A bit of work towards box drawing and string placement.
This could let me do my clock idea... or a text/gui colour chooser.
This commit is contained in:
@ -4,13 +4,14 @@ send_os_command()
|
||||
{
|
||||
_splat=""
|
||||
_suffix=""
|
||||
echo -n ']'
|
||||
while [ -n "${1}" ]
|
||||
do
|
||||
[ -n '${_splat}' ] && _splat=${_splat}';'
|
||||
_splat="${_splat}${1}"
|
||||
[ -n '${_splat}' ] && echo -n ';'
|
||||
echo -n "${1}"
|
||||
shift 1
|
||||
done
|
||||
echo "]${_splat}${_suffix}"
|
||||
echo -n "${suffix}"
|
||||
}
|
||||
|
||||
send_csi_command()
|
||||
@ -18,28 +19,104 @@ send_csi_command()
|
||||
_splat=""
|
||||
_suffix="${1}"
|
||||
shift 1
|
||||
|
||||
|
||||
echo -n ''
|
||||
echo -n '['
|
||||
|
||||
# First one no ';' prefix....
|
||||
echo -n "${1}"
|
||||
shift 1
|
||||
|
||||
while [ -n "${1}" ]
|
||||
do
|
||||
[ -n '${_splat}' ] && _splat="${_splat}"';'
|
||||
_splat="${_splat}${1}"
|
||||
[ -n '${_splat}' ] && echo -n ';'
|
||||
echo -n "${1}"
|
||||
shift 1
|
||||
done
|
||||
echo ${_splat}
|
||||
echo "[${_splat}${_suffix}"
|
||||
echo -n "${_suffix}"
|
||||
}
|
||||
|
||||
erase_block()
|
||||
{
|
||||
send_csi_command '${' $*
|
||||
send_csi_command '${' ${*}
|
||||
}
|
||||
|
||||
fill_block_raw()
|
||||
{
|
||||
send_csi_command '$x' ${*}
|
||||
}
|
||||
|
||||
fill_block()
|
||||
{
|
||||
send_csi_command '$x' $*
|
||||
_code=`printf '%d' "'$1"`
|
||||
shift 1
|
||||
fill_block_raw ${_code} ${*}
|
||||
}
|
||||
|
||||
write_char_raw()
|
||||
{
|
||||
fill_block_raw $1 $2 $3 $2 $3
|
||||
}
|
||||
|
||||
write_char()
|
||||
{
|
||||
_code=`printf '%d' "'$1"`
|
||||
shift 1
|
||||
write_char_raw ${_code} ${*}
|
||||
}
|
||||
|
||||
erase_block 20 20 30 30
|
||||
fill_block X 21 21 29 29
|
||||
write_string()
|
||||
{
|
||||
_str=$1
|
||||
shift 1
|
||||
_row=$1
|
||||
shift 1
|
||||
_col=$1
|
||||
while [ -n "$_str" ]
|
||||
do
|
||||
_ch=${_str:0:1}
|
||||
_str=${_str:1}
|
||||
_code=`printf '%d' "'$_ch"`
|
||||
write_char_raw $_code $_row $_col
|
||||
_col=$(( ${_col} + 1 ))
|
||||
done
|
||||
}
|
||||
|
||||
draw_box()
|
||||
{
|
||||
# T L B R
|
||||
_T=$1
|
||||
_L=$2
|
||||
_B=$3
|
||||
_R=$4
|
||||
write_char + $_T $_L
|
||||
write_char + $_T $_R
|
||||
write_char + $_B $_L
|
||||
write_char + $_B $_R
|
||||
|
||||
fill_block - $_T $(( $_L + 1 )) $_T $(( $_R - 1 ))
|
||||
fill_block - $_B $(( $_L + 1 )) $_B $(( $_R - 1 ))
|
||||
|
||||
fill_block '|' $(( $_T + 1 )) $_L $(( $_B - 1 )) $_L
|
||||
fill_block '|' $(( $_T + 1 )) $_R $(( $_B - 1 )) $_R
|
||||
}
|
||||
|
||||
###############
|
||||
#
|
||||
# Builds a box of specified dimensions
|
||||
# (and clears the middle).
|
||||
#
|
||||
###############
|
||||
build_box()
|
||||
{
|
||||
erase_block $*
|
||||
draw_box $*
|
||||
}
|
||||
|
||||
#erase_block 20 20 30 30
|
||||
#fill_block X 21 21 29 29
|
||||
#write_char Y 25 25
|
||||
|
||||
build_box 8 24 19 99
|
||||
write_string "Hello World" 10 26
|
||||
|
Reference in New Issue
Block a user