Skip to content

Add Input option to disable terminal start/stop #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion curtsies/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Input(object):
"""Keypress and control event generator"""
def __init__(self, in_stream=None, keynames='curtsies',
paste_threshold=events.MAX_KEYPRESS_SIZE+1, sigint_event=False,
signint_callback_provider=None):
signint_callback_provider=None,
disable_terminal_start_stop=False):
"""Returns an Input instance.

Args:
Expand All @@ -56,6 +57,9 @@ def __init__(self, in_stream=None, keynames='curtsies',
represent to be combined into a single paste event
sigint_event (bool): Whether SIGINT signals from the OS
should be intercepted and returned as SigIntEvent objects
disable_terminal_start_stop (bool): If True, disable terminal
start/stop using Ctrl-s/Ctrl-q, thus enabling these keys
to be read as input by curtsies
"""
if in_stream is None:
in_stream = sys.__stdin__
Expand All @@ -64,6 +68,7 @@ def __init__(self, in_stream=None, keynames='curtsies',
self.keynames = keynames
self.paste_threshold = paste_threshold
self.sigint_event = sigint_event
self.disable_terminal_start_stop = disable_terminal_start_stop
self.sigints = []

self.readers = []
Expand All @@ -79,6 +84,12 @@ def __enter__(self):
self.original_stty = termios.tcgetattr(self.in_stream)
tty.setcbreak(self.in_stream, termios.TCSANOW)

if self.disable_terminal_start_stop:
attrs = termios.tcgetattr(self.in_stream)
attrs[-1][termios.VSTOP] = 0 # Ctrl-s
attrs[-1][termios.VSTART] = 0 # Ctrl-q
termios.tcsetattr(self.in_stream, termios.TCSANOW, attrs)

if sys.platform == 'darwin':
attrs = termios.tcgetattr(self.in_stream)
VDSUSP = termios.VSUSP + 1
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy