repcahr optimizations
This commit is contained in:
parent
1e83f6977e
commit
a1e5b66a07
1 changed files with 47 additions and 14 deletions
61
functions
61
functions
|
|
@ -299,10 +299,14 @@ set-boxtype(){
|
||||||
#set-boxtype
|
#set-boxtype
|
||||||
|
|
||||||
repchar() {
|
repchar() {
|
||||||
n=1
|
if [[ $# -ne 2 || ! $2 =~ ^[0-9]+$ ]]; then
|
||||||
while [ $n -le $2 ] ; do
|
warn "repcahr() Incorrect usage. Usage: rephar <char> <count>"
|
||||||
echo -n "$1"
|
return 1
|
||||||
n=$((n+1))
|
fi
|
||||||
|
local char="$1"
|
||||||
|
local count="$2"
|
||||||
|
for (( i=0; i<$count; i++ )); do
|
||||||
|
printf "%s" "$char"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,8 +335,7 @@ boxline(){
|
||||||
}
|
}
|
||||||
|
|
||||||
boxseparator(){
|
boxseparator(){
|
||||||
repchar "$box_break_line" $((BOXWIDTH-3))
|
printf '%s\n' "$(repchar "$box_break_line" $((BOXWIDTH-3)))"
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boxborder(){
|
boxborder(){
|
||||||
|
|
@ -343,6 +346,12 @@ boxborder(){
|
||||||
boxbottom
|
boxbottom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boxlinelog() {
|
||||||
|
local _cmd=${@:1}
|
||||||
|
#echo -e "$left_border $(logger echo -e "${1}")\r${ESC}[${BOXWIDTH}C$right_border"
|
||||||
|
logger echo -e "$left_border $_cmd\r${ESC}[${BOXWIDTH}C$right_border"
|
||||||
|
}
|
||||||
|
|
||||||
boxborderlog(){
|
boxborderlog(){
|
||||||
local _cmd=()
|
local _cmd=()
|
||||||
boxtop
|
boxtop
|
||||||
|
|
@ -355,15 +364,39 @@ boxborderlog(){
|
||||||
boxbottom
|
boxbottom
|
||||||
}
|
}
|
||||||
|
|
||||||
subboxborder(){
|
subboxborder() {
|
||||||
BOXWIDTH_ORG=$BOXWIDTH
|
level=${1:-0}
|
||||||
BOXWIDTH=$(($BOXWIDTH*75/100))
|
local indent=$((level*2))
|
||||||
boxline $(boxtop)
|
local border_char="━"
|
||||||
for line in "$@" ; do
|
local top_border=""
|
||||||
boxline $(boxline "$line")
|
local bottom_border=""
|
||||||
|
|
||||||
|
# Set the border characters based on the level of nesting
|
||||||
|
if ((level==0)); then
|
||||||
|
left_border="$left_top_border"
|
||||||
|
right_border="$right_top_border"
|
||||||
|
top_border="$rep_char $border_char $indent"
|
||||||
|
bottom_border="$rep_char $border_char $indent"
|
||||||
|
else
|
||||||
|
left_border="$left_border"
|
||||||
|
right_border="$right_border"
|
||||||
|
top_border="$rep_char $border_char $indent"
|
||||||
|
bottom_border="$rep_char $border_char $indent"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate the top border
|
||||||
|
boxline "$(boxborder "$top_border")"
|
||||||
|
((level++))
|
||||||
|
|
||||||
|
# Generate the output lines
|
||||||
|
for line in "${@:2}" ; do
|
||||||
|
boxline "$(repchar " " $indent)$(boxline "$line")"
|
||||||
|
boxseparator
|
||||||
done
|
done
|
||||||
boxline $(boxbottom)
|
|
||||||
BOXWIDTH=$BOXWIDTH_ORG
|
# Generate the bottom border
|
||||||
|
((level--))
|
||||||
|
boxline "$(boxborder "$bottom_border")"
|
||||||
}
|
}
|
||||||
|
|
||||||
# # For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable
|
# # For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue