|
|
|
@ -95,13 +95,21 @@ function has_typed_input() { |
|
|
|
emulate -L zsh |
|
|
|
emulate -L zsh |
|
|
|
zmodload zsh/zselect |
|
|
|
zmodload zsh/zselect |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Back up stty settings prior to disabling canonical mode |
|
|
|
|
|
|
|
# Consider that no input can be typed if stty fails |
|
|
|
|
|
|
|
# (this might happen if stdin is not a terminal) |
|
|
|
|
|
|
|
local termios |
|
|
|
|
|
|
|
termios=$(stty --save 2>/dev/null) || return 1 |
|
|
|
{ |
|
|
|
{ |
|
|
|
local termios=$(stty --save) |
|
|
|
# Disable canonical mode so that typed input counts |
|
|
|
|
|
|
|
# regardless of whether Enter was pressed |
|
|
|
stty -icanon |
|
|
|
stty -icanon |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Poll stdin (fd 0) for data ready to be read |
|
|
|
zselect -t 0 -r 0 |
|
|
|
zselect -t 0 -r 0 |
|
|
|
return $? |
|
|
|
return $? |
|
|
|
} always { |
|
|
|
} always { |
|
|
|
|
|
|
|
# Restore stty settings |
|
|
|
stty $termios |
|
|
|
stty $termios |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|