Rewrote scanner results auto expansion with FormatUtils.

This commit is contained in:
Matias Barcenas 2017-08-12 17:24:14 -05:00
parent ad89264442
commit a0ac4510e0
2 changed files with 9 additions and 6 deletions

View File

@ -740,12 +740,13 @@ function set_target_ap() {
fi
done
local bashWidth=$(tput cols)
local ssidWidth=$(($bashWidth - 50))
local headWidth=$(($bashWidth / 2 + 4))
local headerTitle=$(format_center "WIFI LIST"; echo -n "$FormatCenter\n\n")
local header=$(printf "%${headWidth}s\n\n$CRed[$CYel * $CRed]$CClr %-${ssidWidth}s %4s %3s %3s %2s %8s %18s\n" "WIFI LIST" "SSID" "QLTY" "PWR" "STA" "CH" "SECURITY" "MAC ADDRESS")
io_query_format_fields "$header" "$CRed[$CYel%03d$CRed]%b %-${ssidWidth}s %3s%% %3s %3d %2s %8s %18s\n" \
format_autosize "$CRed[$CYel * $CRed]$CClr %-*s %4s %3s %3s %2s %8s %18s\n"
local headerFields=$(printf "$FormatAutosize" "ESSID" "QLTY" "PWR" "STA" "CH" "SECURITY" "BSSID")
format_autosize "$CRed[$CYel%03d$CRed]%b %-*s %3s%% %3s %3d %2s %8s %18s\n"
io_query_format_fields "$headerTitle$headerFields" "$FormatAutosize" \
TargetAPCandidatesColor[@] \
TargetAPCandidatesESSID[@] \
TargetAPCandidatesQuality[@] \

View File

@ -44,7 +44,9 @@ format_calculate_length() {
FormatCalculateLength=$((__format_calculate_length__literalsLength + __format_calculate_length__staticsLength))
}
format_autosize() {
# TODO: This function's performance could sure use improvement...
# This is a semi-permanent fix, unless someone wants to tackle it...
format_autosize() { # Note that this does not yet support multiple lines (multiple \n).
# Treat horizontal tab as a specifier with a length of tab-length.
format_calculate_length "`echo "$1" | sed -r 's/\\\\t/%'"$FormatTabLength"'s/g'`"
# Exploit the fact the previous function just calculated FormatStripSpecifiers.