diff --git a/scripts/common.sh b/scripts/common.sh index 5aebd94..c3bc5d3 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -213,23 +213,22 @@ calcWidthDialog() { fi } -calcHeightWhiptail() { +calcHeight() { newlines=$(printf "$1" | grep -c $'\n') 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 }') +} + +calcHeightWhiptail() { + calcHeight "$@" echo $((6+height)) } calcHeightDialog() { - newlines=$(printf "$1" | grep -c $'\n') - 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 - }') + calcHeight "$@" echo $((4+height)) }