Add generic calcHeight()

This commit is contained in:
Santiago Lo Coco 2022-01-24 23:57:33 -03:00
parent cf55e4285e
commit 80694b75fc
1 changed files with 6 additions and 7 deletions

View File

@ -213,23 +213,22 @@ calcWidthDialog() {
fi fi
} }
calcHeightWhiptail() { calcHeight() {
newlines=$(printf "$1" | grep -c $'\n') newlines=$(printf "$1" | grep -c $'\n')
chars=$(echo "$1" | wc -c) chars=$(echo "$1" | wc -c)
height=$(echo "$chars" "$newlines" | awk '{ height=$(echo "$chars" "$newlines" | awk '{
x = (($1 - $2 + ($2 * 60)) / 60) x = (($1 - $2 + ($2 * 60)) / 60)
printf "%d", (x == int(x)) ? x : int(x) + 1 printf "%d", (x == int(x)) ? x : int(x) + 1
}') }')
}
calcHeightWhiptail() {
calcHeight "$@"
echo $((6+height)) echo $((6+height))
} }
calcHeightDialog() { calcHeightDialog() {
newlines=$(printf "$1" | grep -c $'\n') calcHeight "$@"
chars=$(echo "$1" | wc -c)
height=$(echo "$chars" "$newlines" | awk '{
x = (($1 - $2 + ($2 * 60)) / 60)
printf "%d", (x == int(x)) ? x : int(x) + 1
}')
echo $((4+height)) echo $((4+height))
} }