Enfore max line length in 'prin'

This commit is contained in:
Dylan Araps 2016-08-02 23:44:10 +10:00
parent 91b9fae44d
commit 59147b9974

View file

@ -46,7 +46,6 @@ printinfo () {
info "CPU" cpu info "CPU" cpu
info "GPU" gpu info "GPU" gpu
info "Memory" memory info "Memory" memory
prin "sdddddddddddddddddddddddddddddddddddddasdasdasdasd"
# info "CPU Usage" cpu_usage # info "CPU Usage" cpu_usage
# info "Disk" disk # info "Disk" disk
@ -2521,16 +2520,20 @@ info () {
# Prin {{{ # Prin {{{
prin () { prin () {
if [ -z "$2" ]; then string="$1${2:+: $2}"
string="${info_color}${1}"
length="${#1}"
else # Fix rendering issues with w3m and lines that
string="${subtitle_color}${bold}${1}\033[0m" # wrap to the next line by adding a max line
string+="${colon_color}: ${info_color}${2}" # length.
length="$((${#subtitle} + ${#2} + 1))" if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then
padding_num="${padding/\\033\[}"
string="$(printf "%.$((columns - ${padding_num/C} - gap))s" "$string")"
fi fi
# Format the output
string="${string/:/"\033[0m"${colon_color}:${info_color}}"
string="${subtitle_color}${bold}${string}"
# Trim whitespace # Trim whitespace
string="$(trim "$string")" string="$(trim "$string")"
@ -3147,7 +3150,6 @@ while [ "$1" ]; do
# Text Formatting # Text Formatting
--underline) underline_enabled="$2" ;; --underline) underline_enabled="$2" ;;
--underline_char) underline_char="$2" ;; --underline_char) underline_char="$2" ;;
--line_wrap) line_wrap="$2" ;;
--bold) bold="$2" ;; --bold) bold="$2" ;;
# Color Blocks # Color Blocks