Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround the cursor placement bug #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lsix
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ autodetect() {
# SIXEL SCROLLING (~DECSDM) is now presumed to be enabled.
# See https://github.com/hackerb9/lsix/issues/41 for details.

# SIXEL CURSOR PLACEMENT BUG WORKAROUND
case "$TERM" in
vt340*|contour*)
# These terminals are correct.
sixelcursorbug=""
;;
xterm*|mlterm|yaft*|*)
# These terminals have not yet been fixed. Use -n for echo.
sixelcursorbug="-n"
;;
esac

# TERMINAL COLOR AUTODETECTION.
# Find out how many color registers the terminal has
IFS=";" read -a REPLY -s -t ${timeout} -d "S" -p $'\e[?1;1;0S' >&2
Expand Down Expand Up @@ -241,8 +253,15 @@ main() {
onerow[len++]="file://$1"
shift
done
montage "${onerow[@]}" $imoptions gif:- \
| convert - -colors $numcolors sixel:-
output=$(montage "${onerow[@]}" $imoptions gif:- \
| convert - -colors $numcolors sixel:-)

# Workaround bug in ImageMagick that erroneously sends a
# graphics newline (-) before the end of the image (Esc backslash).
output=${output%-??}$'\e\\'

# Go to next line, unless terminal is quirky.
echo $sixelcursorbug "$output"
done
}

Expand Down