Merge pull request #648 from dylanaraps/strip
Prin: Fix underline not working
This commit is contained in:
commit
198d1e77c0
|
@ -39,7 +39,7 @@ print_info() {
|
|||
info cols
|
||||
info line_break
|
||||
|
||||
# Testing
|
||||
# Testing.
|
||||
prin "prin"
|
||||
prin "prin" "prin"
|
||||
|
||||
|
|
24
neofetch
24
neofetch
|
@ -2543,11 +2543,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
|
||||
|
@ -2560,14 +2558,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}"
|
||||
|
||||
|
@ -2584,9 +2588,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_color}${underline// /$underline_char}${reset} "
|
||||
unset -v length
|
||||
fi
|
||||
prin=1
|
||||
}
|
||||
|
||||
get_line_break() {
|
||||
|
@ -2635,6 +2640,15 @@ trim_quotes() {
|
|||
printf "%s" "$trim_output"
|
||||
}
|
||||
|
||||
strip_sequences() {
|
||||
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}"
|
||||
|
||||
printf "%s\n" "$strip"
|
||||
}
|
||||
|
||||
uppercase() {
|
||||
((bash_version >= 4)) && printf "%s" "${1^}"
|
||||
}
|
||||
|
|
Reference in New Issue