mirror of
https://github.com/jarun/nnn.git
synced 2024-12-02 19:36:51 +00:00
Merge pull request #1051 from luukvbaal/preview-tui
Fix preview-tui job control
This commit is contained in:
commit
f681a5b3f1
|
@ -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
|
||||||
|
kill "$(cat "$IMGPID")"
|
||||||
|
kill "$(cat "$PAGERPID")"
|
||||||
[ -p "$FIFO_UEBERZUG" ] && ueberzug_remove
|
[ -p "$FIFO_UEBERZUG" ] && ueberzug_remove
|
||||||
preview_file "$selection"
|
preview_file "$selection"
|
||||||
printf "%s" "$selection" > "$CURSEL"
|
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