Beruflich Dokumente
Kultur Dokumente
/bin/bash
# Draw-box.sh: Drawing a box using ASCII characters.
# Script by Stefano Palmeri, with minor editing by document author.
# Minor edits suggested by Jim Angstadt.
# Used in the "ABS Guide" with permission.
######################################################################
### draw_box function doc ###
# The "draw_box" function lets the user
#+ draw a box into a terminal.
#
# Usage: draw_box ROW COLUMN HEIGHT WIDTH [COLOR]
# ROW and COLUMN represent the position
#+ of the upper left angle of the box you're going to draw.
# ROW and COLUMN must be greater than 0
#+ and less than current terminal dimension.
# HEIGHT is the number of rows of the box, and must be > 0.
# HEIGHT + ROW must be <= than current terminal height.
# WIDTH is the number of columns of the box and must be > 0.
# WIDTH + COLUMN must be <= than current terminal width.
#
# E.g.: If your terminal dimension is 20x80,
# draw_box 2 3 10 45 is good
# draw_box 2 3 19 45 has bad HEIGHT value (19+2 > 20)
# draw_box 2 3 18 78 has bad WIDTH value (78+3 > 80)
#
# COLOR is the color of the box frame.
# This is the 5th argument and is optional.
# 0=black 1=red 2=green 3=tan 4=blue 5=purple 6=cyan 7=white.
# If you pass the function bad arguments,
#+ it will just exit with code 65,
#+ and no messages will be printed on stderr.
#
# Clear the terminal before you start to draw a box.
# The clear command is not contained within the function.
# This allows the user to draw multiple boxes, even overlapping ones.
### end of draw_box function doc ###
######################################################################
draw_box(){
#=============#
HORZ="-"
VERT="|"
CORNER_CHAR="+"
MINARGS=4
E_BADARGS=65
#=============#