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

View file

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