Fix issues with prompt location calculation in image mode
This commit is contained in:
parent
62e52dd2f6
commit
2b41dafe66
1 changed files with 13 additions and 13 deletions
22
neofetch
22
neofetch
|
@ -2314,6 +2314,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
|
||||||
|
@ -3343,26 +3344,25 @@ fi
|
||||||
# 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
|
||||||
[ "$line_wrap" == "off" ] && printf "%b%s" "\033[?7h"
|
[ "$line_wrap" == "off" ] && printf "%b%s" "\033[?7h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue