From 580b5fd3f0d76121d29708fc93a413519103b48a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 11:12:29 +1000 Subject: [PATCH 1/9] Neofetch no longer clears the screen in ascii/off modes --- neofetch | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 9a743aaf..058a97a7 100755 --- a/neofetch +++ b/neofetch @@ -3121,7 +3121,10 @@ main() { trap 'printf "\033[?25h"' EXIT # Clear the screen - clear + case "$image" in + "ascii" | "off") ;; + *) clear ;; + esac # Hide the cursor and disable line wrap printf "\033[?25l\033[?7l" @@ -3142,8 +3145,14 @@ main() { displayimage fi - # Move cursor to the top - printf "\033[0H" + printf "\033[$((${lines:-0} - 4))A" + printf "\0337" + + # Move cursor to top of ascii art + case "$image" in + "ascii" | "off") printf "\0338" ;; + *) printf "\033[0H" ;; + esac # Print the info printinfo From c4e881c9f1bc4887ed450e5c63cf6c1194846750 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 11:35:23 +1000 Subject: [PATCH 2/9] No longer clear screen --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 058a97a7..a55a2057 100755 --- a/neofetch +++ b/neofetch @@ -3144,8 +3144,8 @@ main() { # Display the image if enabled displayimage fi - printf "\033[$((${lines:-0} - 4))A" + printf "\033[9999999D" printf "\0337" # Move cursor to top of ascii art From 823cce58933e400dcfb0d5b31a5cba73fbc86391 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 11:42:18 +1000 Subject: [PATCH 3/9] Add comments --- neofetch | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neofetch b/neofetch index a55a2057..d76267d0 100755 --- a/neofetch +++ b/neofetch @@ -3144,8 +3144,14 @@ main() { # Display the image if enabled displayimage fi + + # Set cursor position next to ascii art printf "\033[$((${lines:-0} - 4))A" + + # Reset horizontal cursor position printf "\033[9999999D" + + # Save cursor position printf "\0337" # Move cursor to top of ascii art From 402abf90a83226caeedff1672c4e32315b3e9bff Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 12:28:21 +1000 Subject: [PATCH 4/9] Remove cursor pos line --- neofetch | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index d76267d0..200cdf08 100755 --- a/neofetch +++ b/neofetch @@ -2327,6 +2327,9 @@ info() { # Print the string printf "%b%s\n" "${padding}${string}${reset}" + + # Calculate info height + info_height="$((info_height + 1))" } # }}} @@ -2359,6 +2362,9 @@ prin() { # Print the info printf "%b%s\n" "${padding}${string}${reset}" + + # Calculate info height + info_height="$((info_height + 1))" } # }}} @@ -2769,20 +2775,21 @@ kdeconfigdir() { # Dynamic prompt location {{{ dynamicprompt() { - # Get cursor position - info_height="$(IFS=';' builtin read -srdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}")" - # 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))" + lines="$((${height:-1} / ${font_height:-1} + 4))" # 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" + if [ "${lines:-0}" -lt "${info_height:-0}" ]; then + lines="$((info_height - lines - 2))" + else + lines="$((lines - info_height - 2))" + fi # Set the prompt location - [ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H" + [ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}B" } # }}} From 70fa77b64be04e275ddaec1355537603ac526eb1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 12:30:59 +1000 Subject: [PATCH 5/9] Faster math --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 200cdf08..0ebaa591 100755 --- a/neofetch +++ b/neofetch @@ -2329,7 +2329,7 @@ info() { printf "%b%s\n" "${padding}${string}${reset}" # Calculate info height - info_height="$((info_height + 1))" + info_height="$((info_height+=1))" } # }}} @@ -2364,7 +2364,7 @@ prin() { printf "%b%s\n" "${padding}${string}${reset}" # Calculate info height - info_height="$((info_height + 1))" + info_height="$((info_height+=1))" } # }}} From b112ac97154da0a92d3c1720a985ddeab52bd950 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 12:33:30 +1000 Subject: [PATCH 6/9] Cleanup --- neofetch | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 0ebaa591..82405814 100755 --- a/neofetch +++ b/neofetch @@ -2776,7 +2776,7 @@ kdeconfigdir() { dynamicprompt() { # Calculate image height in terminal cells. - # The '+ 3' adds a gap between the prompt and the content. + # The '+ 4' adds a gap between the prompt and the content. [ "$image" != "ascii" ] && [ "$image" != "off" ] && \ lines="$((${height:-1} / ${font_height:-1} + 4))" @@ -3158,12 +3158,9 @@ main() { # Reset horizontal cursor position printf "\033[9999999D" - # Save cursor position - printf "\0337" - # Move cursor to top of ascii art case "$image" in - "ascii" | "off") printf "\0338" ;; + "ascii" | "off") ;; *) printf "\033[0H" ;; esac From 2b7ff346db941e323947c3dfea1e57d98068732b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 12:55:31 +1000 Subject: [PATCH 7/9] Fix garbage in prompt --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 82405814..269ce346 100755 --- a/neofetch +++ b/neofetch @@ -2789,7 +2789,7 @@ dynamicprompt() { fi # Set the prompt location - [ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}B" + [ "$image" != "off" ] && printf "\033[${lines/-*/0}B" } # }}} From 070843d2bfd8bd1dbad4a1ad40800c59e4811a73 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 1 Oct 2016 12:57:54 +1000 Subject: [PATCH 8/9] Clear screen later --- neofetch | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 269ce346..54e4bf29 100755 --- a/neofetch +++ b/neofetch @@ -2085,6 +2085,8 @@ getimage() { [ "${#term_size}" -le 5 ] && err "Your terminal doesn't support \\\033[14t, falling back to ascii mode." return + else + clear fi # Get terminal lines and columns @@ -3127,12 +3129,6 @@ main() { # If the script exits for any reason, unhide the cursor. trap 'printf "\033[?25h"' EXIT - # Clear the screen - case "$image" in - "ascii" | "off") ;; - *) clear ;; - esac - # Hide the cursor and disable line wrap printf "\033[?25l\033[?7l" From 75a7d2c1b43e42a9eba85a171861b171ea6a9c32 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 2 Oct 2016 12:23:12 +1100 Subject: [PATCH 9/9] swap case for ifs --- neofetch | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 54e4bf29..58104d5b 100755 --- a/neofetch +++ b/neofetch @@ -3155,10 +3155,8 @@ main() { printf "\033[9999999D" # Move cursor to top of ascii art - case "$image" in - "ascii" | "off") ;; - *) printf "\033[0H" ;; - esac + [ "$image" != "ascii" ] && [ "$image" != "off" ] && \ + printf "\033[0H" # Print the info printinfo