From a0ac4510e0721aaa8c92596843d3c3f53ab8ad1e Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Sat, 12 Aug 2017 17:24:14 -0500 Subject: [PATCH] Rewrote scanner results auto expansion with FormatUtils. --- fluxion.sh | 11 ++++++----- lib/FormatUtils.sh | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fluxion.sh b/fluxion.sh index 45dc3df..28445ec 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -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[@] \ diff --git a/lib/FormatUtils.sh b/lib/FormatUtils.sh index 9759419..377a656 100644 --- a/lib/FormatUtils.sh +++ b/lib/FormatUtils.sh @@ -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.