Add calcHeight and calcWidth
This commit is contained in:
parent
fb2b3f79e4
commit
e3fef752a7
28
install.sh
28
install.sh
|
@ -337,8 +337,8 @@ calcAndRun() {
|
||||||
argc="$#"; i=1
|
argc="$#"; i=1
|
||||||
for item in "$@"; do
|
for item in "$@"; do
|
||||||
[ $i -eq $((argc-2)) ] && str="$item"
|
[ $i -eq $((argc-2)) ] && str="$item"
|
||||||
[ "$item" = "WIDTH" ] && { function="calcWidthDialog"; dimName="width"; }
|
[ "$item" = "WIDTH" ] && { function="calcWidth"; dimName="width"; }
|
||||||
[ "$item" = "HEIGHT" ] && { function="calcHeightDialog"; dimName="height"; }
|
[ "$item" = "HEIGHT" ] && { function="calcHeight"; dimName="height"; }
|
||||||
((i++))
|
((i++))
|
||||||
done
|
done
|
||||||
dim=$($function "$str")
|
dim=$($function "$str")
|
||||||
|
@ -352,6 +352,30 @@ calcAndRun() {
|
||||||
return $exitStatus
|
return $exitStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calcWidth() {
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}')
|
||||||
|
echo $((4+height))
|
||||||
|
}
|
||||||
|
|
||||||
askForPassword() {
|
askForPassword() {
|
||||||
password=$(calcAndRun dialog --insecure --passwordbox "\"\nNow, enter the password for santioaguit-pc.\"" 10 WIDTH)
|
password=$(calcAndRun dialog --insecure --passwordbox "\"\nNow, enter the password for santioaguit-pc.\"" 10 WIDTH)
|
||||||
exitIfCancel "You must enter a password."
|
exitIfCancel "You must enter a password."
|
||||||
|
|
Loading…
Reference in New Issue