From a39592cdc544d608519796bdd1916ac68bb74832 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 2 Aug 2016 23:11:00 +1000 Subject: [PATCH 1/7] Line wrap changes --- config/config | 4 ---- neofetch | 13 ++++++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/config b/config/config index 6a491572..c6d5b8c8 100644 --- a/config/config +++ b/config/config @@ -212,10 +212,6 @@ colors=(distro) # Text Options {{{ -# Toggle line wrapping -# --line_wrap on/off -line_wrap="off" - # Toggle bold text # --bold on/off bold="on" diff --git a/neofetch b/neofetch index f84d71e1..25a4e7f0 100755 --- a/neofetch +++ b/neofetch @@ -217,10 +217,6 @@ colors=(distro) # Text Options {{{ -# Toggle line wrapping -# --line_wrap on/off -line_wrap="off" - # Toggle bold text # --bold on/off bold="on" @@ -2486,6 +2482,14 @@ info () { # Trim whitespace output="$(trim "$output")" + # Fix rendering issues with w3m and lines that + # wrap to the next line by adding a max line + # length. + if [ "$image" != "off" ] && [ "$image" != "ascii" ] && [ "$1" != "cols" ]; then + padding_num="${padding/\\033\[}" + output="$(printf "%.$((columns - ${padding_num/C} - gap - ${#subtitle}))s" "$output")" + fi + case "$1" in title) string="${title_color}${bold}${output}" @@ -2999,7 +3003,6 @@ usage () { cat << EOF title, @, underline, subtitle, colon, info --underline on/off enable/disable the underline. --underline_char char Character to use when underlining title - --line_wrap on/off Enable/Disable line wrapping --bold on/off Enable/Disable bold text From 7015860c996177376b93a9307001b376330bf44b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 2 Aug 2016 23:19:17 +1000 Subject: [PATCH 2/7] Remove line wrap docs --- README.md | 29 ----------------------------- neofetch.1 | 3 --- 2 files changed, 32 deletions(-) diff --git a/README.md b/README.md index fac7350f..fb984bdf 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,6 @@ Here's what my fetch alias looks like: ```sh alias fetch2="fetch \ --block_range 1 8 \ ---line_wrap off \ --bold off \ --uptime_shorthand on \ --gtk_shorthand on \ @@ -395,7 +394,6 @@ alias fetch2="fetch \ title, @, underline, subtitle, colon, info --underline on/off enable/disable the underline. --underline_char char Character to use when underlining title - --line_wrap on/off Enable/Disable line wrapping --bold on/off Enable/Disable bold text @@ -518,33 +516,6 @@ know where it's stored then adding support won't be a problem!
## Issues and Workarounds -#### The text is too long for my terminal window and wraps to the next line - -There are a few ways to fix this. - -* Disable line wrapping with `line_wrap=off` in the script or with the launch flag `--line_wrap off` -* The uptime and gtk info lines each have a shorthand option that makes their output smaller. You can
- enable them by changing these variables or using these flags. - -```sh -# Config options -uptime_shorthand="on" -gtk_shorthand="on" -gpu_shorthand="on" -birthday_shorthand="on" - -# Launch flags ---uptime_shorthand on ---gtk_shorthand on ---gpu_shorthand on ---birthday_shorthand on - -``` - -* Edit the config to make the subtitles shorter -* Resizing the terminal so that the lines don't wrap. - - #### The text is pushed over too far to the right The easiest way to fix this is to change the value of `--gap` or `$gap`
diff --git a/neofetch.1 b/neofetch.1 index cb4e0b17..a456ba03 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -105,9 +105,6 @@ enable/disable the underline. .B \--underline_char 'char' Character to use when underlining title .TP -.B \--line_wrap 'on/off' -Enable/Disable line wrapping -.TP .B \--bold 'on/off' Enable/Disable bold text .TP From 91b9fae44daf3dc741b156ff4b3f896a31fda58e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 2 Aug 2016 23:21:49 +1000 Subject: [PATCH 3/7] Remove checks for $line_wrap --- neofetch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 25a4e7f0..75116e6c 100755 --- a/neofetch +++ b/neofetch @@ -46,6 +46,7 @@ printinfo () { info "CPU" cpu info "GPU" gpu info "Memory" memory + prin "sdddddddddddddddddddddddddddddddddddddasdasdasdasd" # info "CPU Usage" cpu_usage # info "Disk" disk @@ -3345,7 +3346,7 @@ if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then fi # Disable line wrap -[ "$line_wrap" == "off" ] && printf "\033[?7l" +printf "\033[?7l" # Move cursor to the top [ "$image" != "off" ] && printf "\033[0H" @@ -3374,7 +3375,7 @@ esac [ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H" # Re-enable line wrap -[ "$line_wrap" == "off" ] && printf "%b%s" "\033[?7h" +printf "%b%s" "\033[?7h" # If enabled take a screenshot if [ "$scrot" == "on" ]; then From 59147b9974c34d2284e8a90fe957245ca399c856 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 2 Aug 2016 23:44:10 +1000 Subject: [PATCH 4/7] Enfore max line length in 'prin' --- neofetch | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index 75116e6c..a20e614e 100755 --- a/neofetch +++ b/neofetch @@ -46,7 +46,6 @@ printinfo () { info "CPU" cpu info "GPU" gpu info "Memory" memory - prin "sdddddddddddddddddddddddddddddddddddddasdasdasdasd" # info "CPU Usage" cpu_usage # info "Disk" disk @@ -2521,16 +2520,20 @@ info () { # Prin {{{ prin () { - if [ -z "$2" ]; then - string="${info_color}${1}" - length="${#1}" + string="$1${2:+: $2}" - else - string="${subtitle_color}${bold}${1}\033[0m" - string+="${colon_color}: ${info_color}${2}" - length="$((${#subtitle} + ${#2} + 1))" + # Fix rendering issues with w3m and lines that + # wrap to the next line by adding a max line + # length. + if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then + padding_num="${padding/\\033\[}" + string="$(printf "%.$((columns - ${padding_num/C} - gap))s" "$string")" fi + # Format the output + string="${string/:/"\033[0m"${colon_color}:${info_color}}" + string="${subtitle_color}${bold}${string}" + # Trim whitespace string="$(trim "$string")" @@ -3147,7 +3150,6 @@ while [ "$1" ]; do # Text Formatting --underline) underline_enabled="$2" ;; --underline_char) underline_char="$2" ;; - --line_wrap) line_wrap="$2" ;; --bold) bold="$2" ;; # Color Blocks From 68f6524a574595bf8e0398a245402a7d08ea1b4a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 2 Aug 2016 23:50:05 +1000 Subject: [PATCH 5/7] Keep old format behaviour --- neofetch | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neofetch b/neofetch index a20e614e..46cd051c 100755 --- a/neofetch +++ b/neofetch @@ -2530,6 +2530,12 @@ prin () { string="$(printf "%.$((columns - ${padding_num/C} - gap))s" "$string")" fi + # If $2 doesn't exist we format $1 as info + if [ -z "$2" ]; then + subtitle_color="$info_color" + bold= + fi + # Format the output string="${string/:/"\033[0m"${colon_color}:${info_color}}" string="${subtitle_color}${bold}${string}" From 62e52dd2f6c1ed2b0e1ee375ab217345635cce91 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 4 Aug 2016 08:34:52 +1000 Subject: [PATCH 6/7] Eval colors in custom ascii files --- neofetch | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/neofetch b/neofetch index f84d71e1..64f21e0d 100755 --- a/neofetch +++ b/neofetch @@ -2215,18 +2215,11 @@ getascii () { ascii="$script_dir/ascii/distro/${ascii/ *}" fi - - # We only use eval in the distro ascii files. - print="$(eval printf "$(<"$ascii")")" - else - case "${ascii_colors[0]}" in - "distro") ascii_color="$c1" ;; - *) ascii_color="\033[38;5;${ascii_colors[0]}m" ;; - esac - - print="${ascii_color}$(<"$ascii")" fi + # Eval colors + print="$(eval printf "$(<"$ascii")")" + # Set locale to get correct padding export LC_ALL="$SYS_LOCALE" From 2b41dafe668cdadcdfd9e2621ce410c37cf32be6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 4 Aug 2016 09:20:42 +1000 Subject: [PATCH 7/7] Fix issues with prompt location calculation in image mode --- neofetch | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/neofetch b/neofetch index 64f21e0d..368bd493 100755 --- a/neofetch +++ b/neofetch @@ -2314,6 +2314,7 @@ getimage () { # Calculate font size font_width="$((term_width / columns))" + font_height="$((term_height / lines))" # Image size is half of the terminal case "$image_size" in @@ -3343,26 +3344,25 @@ fi # Print the info printinfo -# Dynamic prompt location. -case "$image" in - "ascii") - # Get cursor position - info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)" +# Dynamic prompt location {{{ - # Set cursor position dynamically based on height of ascii/text. - [ "${lines:-0}" -lt "${info_height:-0}" ] && lines="$info_height" - ;; +# Get cursor position +info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)" - "off") ;; +# Calculate image height in terminal cells. +# The '+ 3' adds a gap between the prompt and the content. +[ "$image" != "ascii" ] && [ "$image" != "off" ] && \ + lines="$((${height:-1} / ${font_height:-1} + 3))" - # Calculate image height in terminal cells. - *) lines="$((${width:-1} / ${font_width:-1} / 2 + 3))" ;; - -esac +# If the info is higher than the ascii/image place the prompt +# based on the info height instead of the ascii/image height. +[ "${lines:-0}" -lt "${info_height:-0}" ] && lines="$info_height" # Set the prompt location [ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H" +# }}} + # Re-enable line wrap [ "$line_wrap" == "off" ] && printf "%b%s" "\033[?7h"