From 9573eee324b59d5ae3991654e0d5028e20b28242 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Jan 2017 03:01:11 +1100 Subject: [PATCH 1/6] Prin: Fix underline not working --- neofetch | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index b2a60827..5e4f8929 100755 --- a/neofetch +++ b/neofetch @@ -2541,11 +2541,9 @@ info() { output="$(trim "${!2:-${!1}}")" if [[ "$2" && "${output// }" ]]; then - length="$((${#1} + ${#output} + 2))" prin "$1" "$output" elif [[ "${output// }" ]]; then - [[ -z "$length" ]] && length="${#output}" prin "$output" else @@ -2558,14 +2556,20 @@ info() { prin() { # If $2 doesn't exist we format $1 as info. if [[ "$(trim "$1")" && "$2" ]]; then - string="${1//$'\033[0m'}${2:+: $2}" + string="${1}${2:+: $2}" else string="${2:-$1}" local subtitle_color="$info_color" fi + string="$(trim "${string//$'\033[0m'}")" + + # Log length if it doesn't exist. + if [[ -z "$length" ]]; then + length="$(strip_sequences "$string")" + length="${#length}" + fi # Format the output. - string="$(trim "$string")" string="${string/:/${reset}${colon_color}:${info_color}}" string="${subtitle_color}${bold}${string}" @@ -2582,9 +2586,10 @@ prin() { get_underline() { if [[ "$underline_enabled" == "on" ]]; then printf -v underline "%${length}s" - underline="${underline_color}${underline// /$underline_char}" + printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${underline// /$underline_char}${reset} " unset -v length fi + prin=1 } get_line_break() { @@ -2633,6 +2638,15 @@ trim_quotes() { printf "%s" "$trim_output" } +strip_sequences() { + strip="${1//$'\033['3?m}" + strip="${strip//$'\033['38\;5\;[0-9]m}" + strip="${strip//$'\033['38\;5\;[0-9][0-9]m}" + strip="${strip//$'\033['38\;5\;[0-9][0-9][0-9]m}" + + printf "%s\n" "$strip" +} + uppercase() { ((bash_version >= 4)) && printf "%s" "${1^}" } From ebba162affbb6a470836e1348ad2fd4c0d4f02ad Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Jan 2017 03:05:19 +1100 Subject: [PATCH 2/6] General: Be less greedy --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 5e4f8929..24e3e6ff 100755 --- a/neofetch +++ b/neofetch @@ -2639,7 +2639,7 @@ trim_quotes() { } strip_sequences() { - strip="${1//$'\033['3?m}" + strip="${1//$'\033['3[0-9]m}" strip="${strip//$'\033['38\;5\;[0-9]m}" strip="${strip//$'\033['38\;5\;[0-9][0-9]m}" strip="${strip//$'\033['38\;5\;[0-9][0-9][0-9]m}" From 745665b9d1d33527f6d9da9ff664f12ea1f387f6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Jan 2017 07:19:51 +1100 Subject: [PATCH 3/6] Travis: Test underlines --- config/travis | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/config/travis b/config/travis index 1fa6eaeb..34bdb023 100644 --- a/config/travis +++ b/config/travis @@ -39,13 +39,20 @@ print_info() { info cols info line_break - # Testing + # Testing. prin "prin" prin "prin" "prin" # Testing no subtitles. info uptime info disk + + # Testing underlines. + info "Memory" memory + info underline + + prin "This is a test" + info underline } refresh_rate="on" From 599ab60909fdb7173a66f476b96bcd075d66efe9 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Jan 2017 07:26:43 +1100 Subject: [PATCH 4/6] Travis: Echo length of underline --- neofetch | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neofetch b/neofetch index 24e3e6ff..e9132210 100755 --- a/neofetch +++ b/neofetch @@ -2584,6 +2584,8 @@ prin() { } get_underline() { + echo "$length" + if [[ "$underline_enabled" == "on" ]]; then printf -v underline "%${length}s" printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${underline// /$underline_char}${reset} " From 728357f4ad447617bb929f22f621a0ec752d3763 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Jan 2017 07:30:13 +1100 Subject: [PATCH 5/6] Underline: Fix travis --- neofetch | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/neofetch b/neofetch index e9132210..8aecade2 100755 --- a/neofetch +++ b/neofetch @@ -2584,11 +2584,9 @@ prin() { } get_underline() { - echo "$length" - if [[ "$underline_enabled" == "on" ]]; then printf -v underline "%${length}s" - printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${underline// /$underline_char}${reset} " + printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${underline_color}${underline// /$underline_char}${reset} " unset -v length fi prin=1 From 3d0ea7c6a2448964893d2093b42395d1d29a9916 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Jan 2017 08:18:09 +1100 Subject: [PATCH 6/6] Travis: Remove testing --- config/travis | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/travis b/config/travis index 34bdb023..903818f9 100644 --- a/config/travis +++ b/config/travis @@ -46,13 +46,6 @@ print_info() { # Testing no subtitles. info uptime info disk - - # Testing underlines. - info "Memory" memory - info underline - - prin "This is a test" - info underline } refresh_rate="on"