Fix cursor move issue on *BSD and remove ';;&' from printinfo

This commit is contained in:
Dylan 2016-01-19 09:54:03 +11:00
parent f3bc7145e4
commit c53235dc90
1 changed files with 24 additions and 18 deletions

42
fetch
View File

@ -367,7 +367,7 @@ getuptime () {
"Mac OS X" | "OpenBSD" | "BSD") "Mac OS X" | "OpenBSD" | "BSD")
# Get boot time in seconds # Get boot time in seconds
boot="$(sysctl -n kern.boottime)" boot="$(sysctl -n kern.boottime)"
boot=${boot/{ sec = /} boot="${boot/{ sec = /}"
boot=${boot/,*} boot=${boot/,*}
# Get current date in seconds # Get current date in seconds
@ -1140,6 +1140,17 @@ printinfo () {
function=${info#*: } function=${info#*: }
subtitle=${info%:*} subtitle=${info%:*}
# Update the var
case "$function" in
"get"*)
var=${function/get/}
typeset -n output=$var
# Call the function
[ -z "$output" ] && $function
;;
esac
case "$info" in case "$info" in
echo:*:*) echo:*:*)
info=${function#*: } info=${function#*: }
@ -1174,15 +1185,6 @@ printinfo () {
continue continue
;; ;;
*:*|*)
# Update the var
var=${function/get/}
typeset -n output=$var
# Call the function
[ -z "$output" ] && $function
;;&
gettitle) gettitle)
string="${bold}${title_color}${output}" string="${bold}${title_color}${output}"
string="${string/@/${at_color}@${title_color}}" string="${string/@/${at_color}@${title_color}}"
@ -1214,10 +1216,8 @@ printinfo () {
# Get lines and columns # Get lines and columns
termsize=$(printf "lines \n cols" | tput -S) lines=$(tput lines)
termsize=${termsize/$'\n'/ } columns=$(tput cols)
lines=${termsize% *}
columns=${termsize#* }
[ "$image" != "off" ] && getimage [ "$image" != "off" ] && getimage
@ -1228,7 +1228,7 @@ if [ "$clear_terminal" == "on" ]; then
fi fi
# Disable line wrap # Disable line wrap
[ "$line_wrap" == "off" ] && printf '\e[?7l' [ "$line_wrap" == "off" ] && printf "\e[?7l"
# Call functions and display info # Call functions and display info
colors colors
@ -1240,11 +1240,17 @@ printinfo
$w3m_img_path $w3m_img_path
# Move cursor to bottom and redisplay it. # Move cursor to bottom and redisplay it.
[ "$clear_terminal" == "on" ] && \ if [ "$clear_terminal" == "on" ]; then
printf "%b%s" "\e[${lines}H\e[${prompt_height}A\e[?25h" case "$os" in
"BSD") tput DO $lines ;;
*) tput cud $lines ;;
esac
printf "%b%s" "\e[${prompt_height}A\e[?25h"
fi
# Enable line wrap again # Enable line wrap again
[ "$line_wrap" == "off" ] && printf '\e[?7h' [ "$line_wrap" == "off" ] && printf "\e[?7h"
# If enabled take a screenshot # If enabled take a screenshot
[ "$scrot" == "on" ] && takescrot [ "$scrot" == "on" ] && takescrot