Skip to content

Commit

Permalink
adopt resolution of livibetter/pipes.sh#12, some keys halt on exiting
Browse files Browse the repository at this point in the history
The screen is also saved and restored.
  • Loading branch information
livibetter committed Apr 9, 2015
1 parent 0600773 commit 4902f88
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ CHANGES
Development
===========

* drop Bash 3- support

The last commit for Bash 3- is ``0600773a30038cf552b417442c1a443297773323``
or before version 1.0.0.

* fix keys like arrow keys or ``Ctrl+Alt+A`` halt on exiting
(livibetter/pipes.sh#12)


Version 0.1.1 (2014-03-19T03:26:51Z)
====================================
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ that is piping at an angle.
.. _pipes.sh: https://github.com/livibetter/pipes.sh


Requirements
============

* Bash 4+ since version 1.0.0.


Installation
============

Expand Down
21 changes: 13 additions & 8 deletions pipesX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,27 @@ done
# set to default values if not by options
((${#T[@]})) || T=(0)

[[ $BASH_VERSION = [1-3]* ]] && SLEEP="sleep $I" || SLEEP="read -t $I -n 1"

do_exit() {
# Show cursor and echo stdin
echo -ne "\e[?25h"
# clear up standard input
read -t 0.001 && cat </dev/stdin>/dev/null

# terminal has no smcup and rmcup capabilities
((FORCE_RESET)) && reset && exit 0

tput rmcup
tput cnorm
stty echo
clear
echo -ne "\e[0m"
((NOCOLOR)) && echo -ne '\e[0m'
exit 0
}
trap do_exit HUP TERM
trap 'break 2' INT

# No echo stdin and hide the cursor
stty -echo
echo -ne "\e[?25l"
tput smcup || FORCE_RESET=1
tput civis
tput clear

# maze geneartion
while [[ $MAZE ]] && clear; do
Expand All @@ -130,7 +135,7 @@ for ((n = 0; n < N; n++)); do
done

clear
while REPLY=; $SLEEP; [[ -z $REPLY ]] ; do
while REPLY=; read -t $I -n 1; [[ -z $REPLY ]] ; do
for ((n = 0; n < N; n++, CC = 0)); do
x=${X[n]} y=${Y[n]}
d=${D[n]} c=${C[n]}
Expand Down

0 comments on commit 4902f88

Please sign in to comment.