Merge pull request #299 from dylanaraps/prompt
Fix prompt location issues in image mode
This commit is contained in:
commit
edf6ba0e60
1 changed files with 13 additions and 13 deletions
22
neofetch
22
neofetch
|
@ -2310,6 +2310,7 @@ getimage () {
|
||||||
|
|
||||||
# Calculate font size
|
# Calculate font size
|
||||||
font_width="$((term_width / columns))"
|
font_width="$((term_width / columns))"
|
||||||
|
font_height="$((term_height / lines))"
|
||||||
|
|
||||||
# Image size is half of the terminal
|
# Image size is half of the terminal
|
||||||
case "$image_size" in
|
case "$image_size" in
|
||||||
|
@ -3355,26 +3356,25 @@ printf "\033[?7l"
|
||||||
# Print the info
|
# Print the info
|
||||||
printinfo
|
printinfo
|
||||||
|
|
||||||
# Dynamic prompt location.
|
# Dynamic prompt location {{{
|
||||||
case "$image" in
|
|
||||||
"ascii")
|
|
||||||
# Get cursor position
|
# 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)"
|
info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)"
|
||||||
|
|
||||||
# Set cursor position dynamically based on height of ascii/text.
|
|
||||||
[ "${lines:-0}" -lt "${info_height:-0}" ] && lines="$info_height"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"off") ;;
|
|
||||||
|
|
||||||
# Calculate image height in terminal cells.
|
# Calculate image height in terminal cells.
|
||||||
*) lines="$((${width:-1} / ${font_width:-1} / 2 + 3))" ;;
|
# The '+ 3' adds a gap between the prompt and the content.
|
||||||
|
[ "$image" != "ascii" ] && [ "$image" != "off" ] && \
|
||||||
|
lines="$((${height:-1} / ${font_height:-1} + 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
|
# Set the prompt location
|
||||||
[ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H"
|
[ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H"
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
# Re-enable line wrap
|
# Re-enable line wrap
|
||||||
printf "%b%s" "\033[?7h"
|
printf "%b%s" "\033[?7h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue