本文整理汇总了Python中curses.raw方法的典型用法代码示例。如果您正苦于以下问题:Python curses.raw方法的具体用法?Python curses.raw怎么用?Python curses.raw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.raw方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_screen
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def _init_screen() -> 'curses._CursesWindow':
# set the escape delay so curses does not pause waiting for sequences
if sys.version_info >= (3, 9): # pragma: no cover
curses.set_escdelay(25)
else: # pragma: no cover
os.environ.setdefault('ESCDELAY', '25')
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
# <enter> is not transformed into '\n' so it can be differentiated from ^J
curses.nonl()
# ^S / ^Q / ^Z / ^\ are passed through
curses.raw()
stdscr.keypad(True)
with contextlib.suppress(curses.error):
curses.start_color()
curses.use_default_colors()
return stdscr
示例2: interact
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def interact(stdscr, broker):
curses.raw()
broker.interact()
示例3: load
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def load(self, *args):
"""Setup curses."""
# Log the terminal type
termname = curses.termname().decode("utf-8")
self.logger.debug("Loading UI for terminal: {0}".format(termname))
self.screen = curses.initscr()
self.setup_colors()
curses.raw()
curses.noecho()
try:
# Hide the default cursor
# Might fail on vt100 terminal emulators
curses.curs_set(0)
except:
self.logger.warning("curses.curs_set(0) failed!")
if "get_wch" not in dir(self.screen):
self.logger.warning("Using old curses! Some keys and special characters might not work.")
self.screen.keypad(1)
self.current_yx = self.screen.getmaxyx() # For checking resize
self.setup_mouse()
self.setup_windows()
示例4: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def __init__(self, this_plant, this_data):
'''Initialization'''
self.initialized = False
self.screen = curses.initscr()
curses.noecho()
curses.raw()
if curses.has_colors():
curses.start_color()
try:
curses.curs_set(0)
except curses.error:
# Not all terminals support this functionality.
# When the error is ignored the screen will look a little uglier, but that's not terrible
# So in order to keep botany as accesible as possible to everyone, it should be safe to ignore the error.
pass
self.screen.keypad(1)
self.plant = this_plant
self.visited_plant = None
self.user_data = this_data
self.plant_string = self.plant.parse_plant()
self.plant_ticks = str(int(self.plant.ticks))
self.exit = False
self.infotoggle = 0
self.maxy, self.maxx = self.screen.getmaxyx()
# Highlighted and Normal line definitions
if curses.has_colors():
self.define_colors()
self.highlighted = curses.color_pair(1)
else:
self.highlighted = curses.A_REVERSE
self.normal = curses.A_NORMAL
# Threaded screen update for live changes
screen_thread = threading.Thread(target=self.update_plant_live, args=())
screen_thread.daemon = True
screen_thread.start()
# Recusive lock to prevent both threads from drawing at the same time
self.screen_lock = threading.RLock()
self.screen.clear()
self.show(["water","look","garden","visit", "instructions"], title=' botany ', subtitle='options')
示例5: get_and_use_key_press
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def get_and_use_key_press(self):
global TEST_SETTINGS
if (TEST_SETTINGS['TEST_INPUT'] is None) and (TEST_SETTINGS['INPUT_GENERATOR'] is None):
curses.raw()
curses.cbreak()
curses.meta(1)
self.parent.curses_pad.keypad(1)
if self.parent.keypress_timeout:
curses.halfdelay(self.parent.keypress_timeout)
ch = self._get_ch()
if ch == -1:
return self.try_while_waiting()
else:
self.parent.curses_pad.timeout(-1)
ch = self._get_ch()
# handle escape-prefixed rubbish.
if ch == curses.ascii.ESC:
#self.parent.curses_pad.timeout(1)
self.parent.curses_pad.nodelay(1)
ch2 = self.parent.curses_pad.getch()
if ch2 != -1:
ch = curses.ascii.alt(ch2)
self.parent.curses_pad.timeout(-1) # back to blocking mode
#curses.flushinp()
elif (TEST_SETTINGS['INPUT_GENERATOR']):
self._last_get_ch_was_unicode = True
try:
ch = next(TEST_SETTINGS['INPUT_GENERATOR'])
except StopIteration:
if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']:
TEST_SETTINGS['INPUT_GENERATOR'] = None
return
else:
raise ExhaustedTestInput
else:
self._last_get_ch_was_unicode = True
try:
ch = TEST_SETTINGS['TEST_INPUT'].pop(0)
TEST_SETTINGS['TEST_INPUT_LOG'].append(ch)
except IndexError:
if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']:
TEST_SETTINGS['TEST_INPUT'] = None
return
else:
raise ExhaustedTestInput
self.handle_input(ch)
if self.check_value_change:
self.when_check_value_changed()
if self.check_cursor_move:
self.when_check_cursor_moved()
self.try_adjust_widgets()
示例6: start
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def start(self, element_layouts):
self.minor_frame_layout = MinorFrameLayout("raw", self)
self.element_layout_key_shortcuts['`'] = self.minor_frame_layout
self.subcom_layout = SubcomLayout("subcom", self)
self.element_layout_key_shortcuts['~'] = self.subcom_layout
print "Building history layout..."
history_length = 40
self.history_layout = HistoryLayout(name="history", ui=self, width=24, elements=[
('hps_1_temp_supercom', history_length),
('hps_2_temp_supercom', history_length),
('hps_1_tc', history_length),
#('hps_1_tcX', history_length),
('hps_2_tc', history_length),
#('hps_2_tcX', history_length),
('accelerometer', history_length),
]) # MAGIC
self.element_layout_key_shortcuts['h'] = self.history_layout
print "Building layouts..."
for element_layout in element_layouts:
name = element_layout[0]
shortcut = name[0]
if len(element_layout) >= 3:
shortcut = element_layout[2]
elements = []
for element_name in element_layout[1]:
element = self.engine.get_element(element_name, safe=False)
if element is None:
print "The element '%s' was not found for layout '%s'" % (element_name, name)
element = self.engine.get_element(element_name)
elements += [element]
layout = ElementsLayout(elements, name=name, ui=self)
self.element_layouts += [layout]
if shortcut not in self.element_layout_key_shortcuts.keys():
self.element_layout_key_shortcuts[shortcut] = layout
else:
print "ElementLayout '%s' already has shortcut key '%s'" % (self.element_layout_key_shortcuts[shortcut].name, shortcut)
self.scr = curses.initscr()
#curses.start_color() # FIXME
self.scr.timeout(self.timeout) # -1 for blocking
self.scr.keypad(1) # Otherwise app will end when pressing arrow keys
curses.noecho()
#curses.raw()
#curses.cbreak()
#curses.nl / curses.nonl
#self.scr.deleteln()
self.switch_layout(self.minor_frame_layout)
self.update()
#self.scr.refresh() # Done in 'update'
示例7: setUpCurses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import raw [as 别名]
def setUpCurses(self, cursesScreen):
self.cursesScreen = cursesScreen
curses.mousemask(-1)
curses.mouseinterval(0)
# Enable mouse tracking in xterm.
sys.stdout.write('\033[?1002;h')
#sys.stdout.write('\033[?1005;h')
curses.meta(1)
# Access ^c before shell does.
curses.raw()
# Enable Bracketed Paste Mode.
sys.stdout.write('\033[?2004;h')
# Push the escape codes out to the terminal. (Whether this is needed
# seems to vary by platform).
sys.stdout.flush()
try:
curses.start_color()
if not curses.has_colors():
userMessage("This terminal does not support color.")
self.quitNow()
else:
curses.use_default_colors()
except curses.error as e:
app.log.error(e)
app.log.startup(u"curses.COLORS", curses.COLORS)
if 0:
assert curses.COLORS == 256
assert curses.can_change_color() == 1
assert curses.has_colors() == 1
app.log.detail("color_content:")
for i in range(0, curses.COLORS):
app.log.detail("color", i, ": ", curses.color_content(i))
for i in range(16, curses.COLORS):
curses.init_color(i, 500, 500, i * 787 % 1000)
app.log.detail("color_content, after:")
for i in range(0, curses.COLORS):
app.log.detail("color", i, ": ", curses.color_content(i))
if 1:
#rows, cols = self.cursesScreen.getmaxyx()
cursesWindow = self.cursesScreen
cursesWindow.leaveok(1) # Don't update cursor position.
cursesWindow.scrollok(0)
cursesWindow.timeout(10)
cursesWindow.keypad(1)
app.window.mainCursesWindow = cursesWindow