From Flying Tamarin, 3 Months ago, written in Plain Text.
  1. boxframe(){
  2.   # desc: draw a border at ($geo)-1 and print a message
  3.   # usage: boxframe "$n-cols" "$n-lines" "$style" "${msg[@]}"
  4.   [[ "$1" == "--help" ]] && printf -- "boxframe\noptions: 0:space 1:star 2:box 3:checker\n" && return 0
  5.  
  6.   declare opt col lin msg tl tr bl br h v
  7.   declare -a s
  8.  
  9.   # Assign box drawing chars where:
  10.   #l:┌    k:┐    m:└    j:┘   q:─    v:│
  11.   tl='l' tr='k' bl='m' br='j' h='q' v='x'
  12.   opt="$1"; col="$2"; lin="$3"
  13.   shift 3
  14.   msg="$(columnate 2 "$col" "$@")"
  15.  
  16.   horz(){ eval printf $'\x1b\(0%c' "$h{1..${col}"\}; }
  17.   vert(){ eval printf $'\x1b\(0\x1b[D%c\x1b[B' "$v{1..${lin}"\}; }
  18.   unionvert(){
  19.     [[ "${FUNCNAME[-1]}" == "lvert" ]] \
  20.       && eval printf -- $'\x1b\(0\x1b[D\x1b[1K%c\x1b[B' "$1{1..$2"\} \
  21.       || eval printf -- $'\x1b\(0\x1b[D%c\x1b[B' "$1{1..$2"\}
  22.   }
  23.   lvert(){ unionvert "$v" "$lin"; }
  24.   rvert(){ unionvert "$v" "$lin" "$col"; }
  25.  
  26.   case "$opt" in
  27.     0) s=(' ' ' ' ' ' ' ') ;;
  28.     1) s=('*' '*' '*' '*') ;;
  29.     2) s=('j' 'm' 'l' 'k') ;;
  30.     3) s=('a' 'a' 'a' 'a') ;;
  31.     *) s=(' ' ' ' ' ' ' ') ;;
  32.   esac
  33.  
  34.   # Do it the other way! print message, then walk the edge of the screen to draw box.
  35.   printf -- "\x1b[?25l\x1b[2;3H$msg" # Set cursor to invis in addition to printing
  36.   # Ordered as: top, right, left, bottom
  37.   printf -- "\x1b[0;0H%s\r%s\x1b[${col}C\b%s" "$(horz)" "${s[0]}${tl}" "${tr}${s[1]}"
  38.   printf -- "\x1b[2;${col}H%s%s\r%s"          "$(rvert)" "$tr"          "$br"
  39.   printf -- "\x1b[2;3H%s%s\r%s"               "$(lvert)" "$bl"          "$tl"
  40.   printf -- "\x1b[${lin};0H%s\b%s\r%s"        "$(horz)" "${br}${s[2]}" "${s[3]}${bl}"
  41. }
captcha