summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Rose <grinch@grinchcentral.com>2015-02-02 23:09:40 -0500
committerErik Rose <grinch@grinchcentral.com>2015-02-02 23:09:40 -0500
commit006ab36939d7d4b3b92556345662163c4b587a07 (patch)
treed0bb2e2e24f32e18fc03cd5f462a524b9de19957
parent327e31595fd1c79f9bb4c4d209e753cbde1e0c60 (diff)
downloadblessings-006ab36939d7d4b3b92556345662163c4b587a07.tar.gz
Rename _intr_continue kwarg to "interruptable".
jquast said there's no reason for the leading underscore.
-rwxr-xr-xbin/on_resize.py6
-rw-r--r--blessed/terminal.py13
-rw-r--r--blessed/tests/test_keyboard.py12
3 files changed, 16 insertions, 15 deletions
diff --git a/bin/on_resize.py b/bin/on_resize.py
index 7398260..2481d05 100755
--- a/bin/on_resize.py
+++ b/bin/on_resize.py
@@ -4,8 +4,8 @@ This is an example application for the 'blessed' Terminal library for python.
Window size changes are caught by the 'on_resize' function using a traditional
signal handler. Meanwhile, blocking keyboard input is displayed to stdout.
-If a resize event is discovered, an empty string is returned by term.inkey()
-when _intr_continue is False, as it is here.
+If a resize event is discovered, an empty string is returned by
+term.keystroke() when interruptable is False, as it is here.
"""
import signal
from blessed import Terminal
@@ -31,5 +31,5 @@ with term.raw():
print("press 'X' to stop.\r")
inp = None
while inp != 'X':
- inp = term.inkey(_intr_continue=False)
+ inp = term.inkey(interruptable=False)
print(repr(inp) + u'\r')
diff --git a/blessed/terminal.py b/blessed/terminal.py
index 10ca201..60fecbe 100644
--- a/blessed/terminal.py
+++ b/blessed/terminal.py
@@ -548,7 +548,7 @@ class Terminal(object):
byte = os.read(self.keyboard_fd, 1)
return self._keyboard_decoder.decode(byte, final=False)
- def _char_is_ready(self, timeout=None, _intr_continue=True):
+ def _char_is_ready(self, timeout=None, interruptable=True):
"""T._char_is_ready([timeout=None]) -> bool
Returns True if a keypress has been detected on keyboard.
@@ -574,7 +574,7 @@ class Terminal(object):
ready_r, ready_w, ready_x = select.select(
check_r, check_w, check_x, timeout)
except InterruptedError:
- if not _intr_continue:
+ if not interruptable:
return u''
if timeout is not None:
# subtract time already elapsed,
@@ -651,8 +651,8 @@ class Terminal(object):
finally:
self.stream.write(self.rmkx)
- def keystroke(self, timeout=None, esc_delay=0.35, _intr_continue=True):
- """T.keystroke(timeout=None, [esc_delay, [_intr_continue]]) -> Keystroke
+ def keystroke(self, timeout=None, esc_delay=0.35, interruptable=True):
+ """T.keystroke(timeout=None, [esc_delay, [interruptable]]) -> Keystroke
Receive next keystroke from keyboard (stdin), blocking until a
keypress is received or ``timeout`` elapsed, if specified.
@@ -676,7 +676,7 @@ class Terminal(object):
installment of SIGWINCH, this function will ignore this interruption
and continue to poll for input up to the ``timeout`` specified. If
you'd rather this function return ``u''`` early, specify ``False`` for
- ``_intr_continue``.
+ ``interruptable``.
"""
# TODO(jquast): "meta sends escape", where alt+1 would send '\x1b1',
# what do we do with that? Surely, something useful.
@@ -723,7 +723,8 @@ class Terminal(object):
# so long as the most immediately received or buffered keystroke is
# incomplete, (which may be a multibyte encoding), block until until
# one is received.
- while not ks and self._char_is_ready(time_left(stime, timeout), _intr_continue):
+ while not ks and self._char_is_ready(time_left(stime, timeout),
+ interruptable):
ucs += self._next_char()
ks = resolve(text=ucs)
diff --git a/blessed/tests/test_keyboard.py b/blessed/tests/test_keyboard.py
index b43fc69..a3a81e1 100644
--- a/blessed/tests/test_keyboard.py
+++ b/blessed/tests/test_keyboard.py
@@ -127,8 +127,8 @@ def test_char_is_ready_interrupted_nonetype():
assert math.floor(time.time() - stime) == 1.0
-def test_char_is_ready_interrupted_no_continue():
- "_char_is_ready() may be interrupted when _intr_continue=False."
+def test_char_is_ready_interrupted_interruptable():
+ "_char_is_ready() may be interrupted when interruptable=False."
pid, master_fd = pty.fork()
if pid is 0:
try:
@@ -149,7 +149,7 @@ def test_char_is_ready_interrupted_no_continue():
read_until_semaphore(sys.__stdin__.fileno(), semaphore=SEMAPHORE)
os.write(sys.__stdout__.fileno(), SEMAPHORE)
with term.keystroke_input(raw=True):
- term.keystroke(timeout=1.05, _intr_continue=False)
+ term.keystroke(timeout=1.05, interruptable=False)
os.write(sys.__stdout__.fileno(), b'complete')
assert got_sigwinch is True
if cov is not None:
@@ -171,8 +171,8 @@ def test_char_is_ready_interrupted_no_continue():
assert math.floor(time.time() - stime) == 0.0
-def test_char_is_ready_interrupted_nonetype_no_continue():
- "_char_is_ready() may be interrupted when _intr_continue=False with timeout None."
+def test_char_is_ready_interrupted_nonetype_interruptable():
+ "_char_is_ready() may be interrupted when interruptable=False with timeout None."
pid, master_fd = pty.fork()
if pid is 0:
try:
@@ -193,7 +193,7 @@ def test_char_is_ready_interrupted_nonetype_no_continue():
read_until_semaphore(sys.__stdin__.fileno(), semaphore=SEMAPHORE)
os.write(sys.__stdout__.fileno(), SEMAPHORE)
with term.keystroke_input(raw=True):
- term.keystroke(timeout=None, _intr_continue=False)
+ term.keystroke(timeout=None, interruptable=False)
os.write(sys.__stdout__.fileno(), b'complete')
assert got_sigwinch is True
if cov is not None: