mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Fix preview-tui job control
This commit is contained in:
parent
c205177ac6
commit
99e039d504
|
@ -144,7 +144,10 @@ toggle_preview() {
|
||||||
elif exists Bridge.exe; then
|
elif exists Bridge.exe; then
|
||||||
QLPATH="Bridge.exe"
|
QLPATH="Bridge.exe"
|
||||||
fi
|
fi
|
||||||
if pkill -P "$(cat "$FIFOPID")"; then
|
if kill "$(cat "$FIFOPID")"; then
|
||||||
|
kill "$(cat "$IMGPID")"
|
||||||
|
kill "$(cat "$PAGERPID")"
|
||||||
|
pkill -f "tail --follow $FIFO_UEBERZUG"
|
||||||
if [ -n "$QLPATH" ] && stat "$1"; then
|
if [ -n "$QLPATH" ] && stat "$1"; then
|
||||||
f="$(wslpath -w "$1")" && "$QLPATH" "$f" &
|
f="$(wslpath -w "$1")" && "$QLPATH" "$f" &
|
||||||
fi
|
fi
|
||||||
|
@ -324,6 +327,7 @@ generate_preview() {
|
||||||
printf "%s" "$!" > "$IMGPID"
|
printf "%s" "$!" > "$IMGPID"
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
exec >/dev/tty
|
||||||
image_preview "$1" "$2" "$3"
|
image_preview "$1" "$2" "$3"
|
||||||
return
|
return
|
||||||
fi ;;
|
fi ;;
|
||||||
|
@ -369,25 +373,26 @@ ueberzug_remove() {
|
||||||
|
|
||||||
winch_handler() {
|
winch_handler() {
|
||||||
clear
|
clear
|
||||||
kill "$(cat "$IMGPID")" "$(cat "$PAGERPID")"
|
kill "$(cat "$IMGPID")"
|
||||||
|
kill "$(cat "$PAGERPID")"
|
||||||
if [ -p "$FIFO_UEBERZUG" ]; then
|
if [ -p "$FIFO_UEBERZUG" ]; then
|
||||||
pkill -P "$$"
|
pkill -f "tail --follow $FIFO_UEBERZUG"
|
||||||
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser json &
|
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser json &
|
||||||
fi
|
fi
|
||||||
cat "$CURSEL" > "$NNN_FIFO"
|
|
||||||
preview_file "$(cat "$CURSEL")"
|
preview_file "$(cat "$CURSEL")"
|
||||||
preview_fifo &
|
|
||||||
wait "$!"
|
|
||||||
} 2>/dev/null
|
} 2>/dev/null
|
||||||
|
|
||||||
preview_fifo() {
|
preview_fifo() {
|
||||||
printf "%s" "$$" > "$FIFOPID"
|
|
||||||
while read -r selection; do
|
while read -r selection; do
|
||||||
kill "$(cat "$IMGPID")" "$(cat "$PAGERPID")"
|
if [ -n "$selection" ]; then
|
||||||
[ -p "$FIFO_UEBERZUG" ] && ueberzug_remove
|
kill "$(cat "$IMGPID")"
|
||||||
preview_file "$selection"
|
kill "$(cat "$PAGERPID")"
|
||||||
printf "%s" "$selection" > "$CURSEL"
|
[ -p "$FIFO_UEBERZUG" ] && ueberzug_remove
|
||||||
|
preview_file "$selection"
|
||||||
|
printf "%s" "$selection" > "$CURSEL"
|
||||||
|
fi
|
||||||
done < "$NNN_FIFO"
|
done < "$NNN_FIFO"
|
||||||
|
pkill -P "$$"
|
||||||
} 2>/dev/null
|
} 2>/dev/null
|
||||||
|
|
||||||
if [ "$PREVIEW_MODE" ]; then
|
if [ "$PREVIEW_MODE" ]; then
|
||||||
|
@ -396,10 +401,11 @@ if [ "$PREVIEW_MODE" ]; then
|
||||||
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser json &
|
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser json &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "%s" "$PWD/$1" > "$CURSEL"
|
|
||||||
preview_file "$PWD/$1"
|
preview_file "$PWD/$1"
|
||||||
preview_fifo &
|
preview_fifo &
|
||||||
trap 'winch_handler' WINCH
|
printf "%s" "$!" > "$FIFOPID"
|
||||||
|
printf "%s" "$PWD/$1" > "$CURSEL"
|
||||||
|
trap 'winch_handler; wait' WINCH
|
||||||
trap 'rm "$PAGERPID" "$IMGPID" "$CURSEL" "$FIFO_UEBERZUG" "$FIFOPID" 2>/dev/null' INT HUP EXIT
|
trap 'rm "$PAGERPID" "$IMGPID" "$CURSEL" "$FIFO_UEBERZUG" "$FIFOPID" 2>/dev/null' INT HUP EXIT
|
||||||
wait "$!" 2>/dev/null
|
wait "$!" 2>/dev/null
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue