Update calcWidth and calcHeight and add new aux functions
This commit is contained in:
parent
aee30e8591
commit
bad19e05c2
54
install.sh
54
install.sh
|
@ -333,9 +333,41 @@ networkConf() {
|
||||||
unset hostname
|
unset hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calcWidthDialog() {
|
||||||
|
str=$1; count=1; found=false; option=1
|
||||||
|
for (( i = 0; i < ${#str}; i++ )); do
|
||||||
|
if [ "${str:$i:1}" = "\\" ] && [ "${str:$((i+1)):1}" = "n" ]; then
|
||||||
|
[ $count -ge $option ] && option=$count
|
||||||
|
found=true
|
||||||
|
count=-1
|
||||||
|
fi
|
||||||
|
((count++))
|
||||||
|
done
|
||||||
|
[ $option -ge $count ] && count=option
|
||||||
|
echo $((count+3))
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}')
|
||||||
|
echo $((4+height))
|
||||||
|
}
|
||||||
|
|
||||||
calcWidthAndRun() {
|
calcWidthAndRun() {
|
||||||
width=$(echo "$@" | grep -oP '(?<=").*?(?=")' | wc -c)
|
argc="$#"; i=1
|
||||||
comm=$(echo "$@" | sed "s/WIDTH/$((width+8))/g")
|
for item in "$@"; do
|
||||||
|
if [ $i -eq $((argc-2)) ]; then
|
||||||
|
str="$item"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
width=$(calcWidthDialog "$str")
|
||||||
|
comm=$(echo "$@" | sed "s/WIDTH/$width/g")
|
||||||
if [[ $comm != *"3>&1 1>&2 2>&3" ]]; then
|
if [[ $comm != *"3>&1 1>&2 2>&3" ]]; then
|
||||||
comm="${comm} 3>&1 1>&2 2>&3"
|
comm="${comm} 3>&1 1>&2 2>&3"
|
||||||
fi
|
fi
|
||||||
|
@ -346,14 +378,16 @@ calcWidthAndRun() {
|
||||||
}
|
}
|
||||||
|
|
||||||
calcHeightAndRun() {
|
calcHeightAndRun() {
|
||||||
str=$(echo "$@" | grep -oP '(?<=").*?(?=")')
|
argc="$#"; i=1
|
||||||
newlines=$(printf "$str" | grep -c $'\n')
|
for item in "$@"; do
|
||||||
chars=$(echo "$str" | wc -c)
|
if [ $i -eq $((argc-2)) ]; then
|
||||||
height=$(echo "$chars" "$newlines" | awk '{
|
str="$item"
|
||||||
x = (($1 - $2 + ($2 * 60)) / 60)
|
break
|
||||||
printf "%d", (x == int(x)) ? x : int(x) + 1
|
fi
|
||||||
}')
|
((i++))
|
||||||
comm=$(echo "$@" | sed "s/HEIGHT/$((5+height))/g")
|
done
|
||||||
|
height=$(calcHeightDialog "$str")
|
||||||
|
comm=$(echo "$@" | sed "s/HEIGHT/$height/g")
|
||||||
if [[ $comm != *"3>&1 1>&2 2>&3" ]]; then
|
if [[ $comm != *"3>&1 1>&2 2>&3" ]]; then
|
||||||
comm="${comm} 3>&1 1>&2 2>&3"
|
comm="${comm} 3>&1 1>&2 2>&3"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue