fixed center function
This commit is contained in:
parent
c03ad9e033
commit
2fac6ba3a3
1 changed files with 7 additions and 5 deletions
12
functions
12
functions
|
|
@ -374,10 +374,12 @@ subboxborder(){
|
|||
|
||||
# For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable
|
||||
center(){
|
||||
#local padding="";
|
||||
padding="$(printf '%0.1s' \ {1..100})"
|
||||
#padding=" "
|
||||
printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${left_border}${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}${right_border}"
|
||||
local padding=""
|
||||
padding="$(printf ' %.0s' {1..100})"
|
||||
local string_length=${#1}
|
||||
local padding_length=$(( (BOXWIDTH - 2 - string_length) / 2 ))
|
||||
printf "%s%s %s %s%s\n" "$left_border" "${padding:0:padding_length}" "$1" "${padding:0:padding_length}" "$right_border"
|
||||
#printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${left_border}${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}${right_border}"
|
||||
#printf "%s %s %s %s %s\n" "$left_border" "$padding" "$1" "$padding" "$right_border";
|
||||
#echo -en "\r${ESC}[$(((BOXWIDTH-${#1})/2))C$@\r${ESC}[${BOXWIDTH}C\n"
|
||||
}
|
||||
|
|
@ -588,7 +590,7 @@ trim() {
|
|||
|
||||
strip-html-tags() {
|
||||
local input="$1"
|
||||
local stripped=$(echo "$input" | sed 's/<[^>]*>//g')
|
||||
local stripped=$(echo "$input" | sed 's/<[^>]*>//g' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
echo "$stripped"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue