bar: Rename all progress_ variables to bar_

This commit is contained in:
Dylan Araps 2016-11-13 21:20:20 +11:00
parent 0a9aa93aad
commit 2d0dbd2878
2 changed files with 40 additions and 33 deletions

View file

@ -250,24 +250,24 @@ block_height=1
# Progress bar character
# --progress_char elapsed_char total_char
progress_char_elapsed="-"
progress_char_total="="
bar_char_elapsed="-"
bar_char_total="="
# Progress border
# --progress_border on, off
progress_border="on"
bar_border="on"
# Progress bar length in spaces
# Number of chars long to make the progress bars.
# --progress_length num
progress_length="15"
bar_length="15"
# Progress bar colors
# When set to distro, uses your distro's logo colors
# Takes: num, "distro"
# --progress_colors col col
progress_color_elapsed="distro"
progress_color_total="distro"
bar_color_elapsed="distro"
bar_color_total="distro"
# Customize how the info is displayed.
# bar: Only the progress bar is displayed.

View file

@ -2581,16 +2581,16 @@ set_colors() {
fi
# Progress Bar colors
if [[ "$progress_color_elapsed" == "distro" ]]; then
progress_color_elapsed="$(color fg)"
if [[ "$bar_color_elapsed" == "distro" ]]; then
bar_color_elapsed="$(color fg)"
else
progress_color_elapsed="$(color "$progress_color_elapsed")"
bar_color_elapsed="$(color "$bar_color_elapsed")"
fi
case "$progress_color_total $1" in
"distro "[736]) progress_color_total="$c2" ;;
"distro "[0-9]) progress_color_total="$c1" ;;
*) progress_color_total="$(color "$progress_color_total")" ;;
case "$bar_color_total $1" in
"distro "[736]) bar_color_total="$c2" ;;
"distro "[0-9]) bar_color_total="$c1" ;;
*) bar_color_total="$(color "$bar_color_total")" ;;
esac
}
@ -2690,21 +2690,19 @@ get_user_config() {
bar() {
# Get the values
elapsed="$(($1 * progress_length / $2))"
elapsed="$(($1 * bar_length / $2))"
# Create the bar with spaces
prog="$(printf %"$elapsed"s)"
total="$(printf %"$((progress_length - elapsed))"s)"
total="$(printf %"$((bar_length - elapsed))"s)"
# Set the colors and swap the spaces for $progress_char
bar+="${progress_color_elapsed}${prog// /$progress_char_elapsed}"
bar+="${progress_color_total}${total// /$progress_char_total}"
bar+="${bar_color_elapsed}${prog// /$bar_char_elapsed}"
bar+="${bar_color_total}${total// /$bar_char_total}"
# Borders
if [[ "$progress_border" == "on" ]]; then
bar+="$(color fg)]"
bar="$(color fg)[$bar"
fi
[[ "$bar_border" == "on" ]] && \
bar="$(color fg)[${bar}$(color fg)]"
printf "%b\n" "${bar}${info_color}"
}
@ -2715,6 +2713,8 @@ cache() {
}
kde_config_dir() {
# If the user is using KDE get the KDE
# configuration directory.
if [[ "$kde_config_dir" ]]; then
return
@ -2754,9 +2754,10 @@ get_term_padding() {
}
dynamic_prompt() {
# Calculate image height in terminal cells.
if [[ "$image_backend" != "ascii" ]]; then
if [[ "$image_backend" == "image" ]]; then
get_term_padding 2>/dev/null
# Calculate image height in terminal cells.
lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))"
fi
@ -2798,9 +2799,15 @@ old_functions() {
old_flags() {
[[ -n "$osx_buildversion" ]] && err "Config: \$osx_buildversion is deprecated, use \$distro_shorthand instead."
[[ -n "$osx_codename" ]] && err "Config: \$osx_codename is deprecated, use \$distro_shorthand instead."
[[ -n "$progress_char" ]] && err "Config: \$progress_char is deprecated, use \$progress_char_elapsed and \$progress_char_total instead."
[[ "$cpu_cores" == "on" ]] && err "Config: \$cpu_cores='on' is deprecated, use \$cpu_cores='logical|physical|off' instead."
[[ -n "$image" ]] && { err "Config: \$image is deprecated, use \$image_source instead."; image_source="$image"; }
# All progress_ variables were changed to bar_
[[ -n "$progress_char" ]] && err "Config: \$progress_char is deprecated, use \$bar_char_elapsed and \$bar_char_total instead."
[[ -n "$progress_border" ]] && err "Config: \$progress_border is deprecated, use \$bar_border instead."
[[ -n "$progress_length" ]] && err "Config: \$progress_length is deprecated, use \$bar_length instead."
[[ -n "$progress_color_elapsed" ]] && err "Config: \$progress_color_elapsed is deprecated, use \$bar_color_elapsed instead."
[[ -n "$progress_color_total" ]] && err "Config: \$progress_color_total is deprecated, use \$bar_color_total instead."
}
cache_uname() {
@ -2875,8 +2882,8 @@ usage() { printf "%s" "
Progress Bars:
--progress_char 'elapsed char' 'total char'
Characters to use when drawing progress bars.
--progress_border on/off Whether or not to surround the bar with '[]'
--progress_length num Length in spaces to make the progress bars.
--bar_border on/off Whether or not to surround the bar with '[]'
--bar_length num Length in spaces to make the progress bars.
--progress_colors num num Colors to make the progress bar.
Set in this order: elapsed, total
--cpu_display mode Progress bar mode.
@ -3012,14 +3019,14 @@ get_args() {
# Progress Bars
--progress_char)
progress_char_elapsed="$2"
progress_char_total="$3"
bar_char_elapsed="$2"
bar_char_total="$3"
;;
--progress_border) progress_border="$2" ;;
--progress_length) progress_length="$2" ;;
--bar_border) bar_border="$2" ;;
--bar_length) bar_length="$2" ;;
--progress_colors)
progress_color_elapsed="$2"
progress_color_total="$3"
bar_color_elapsed="$2"
bar_color_total="$3"
;;
--cpu_display) cpu_display="$2" ;;
--memory_display) memory_display="$2" ;;
@ -3111,8 +3118,8 @@ main() {
cache_uname
get_os
get_default_config 2>/dev/null
old_flags
get_args "$@"
old_flags
get_distro
bold
get_distro_colors