本文整理匯總了Python中curses.meta方法的典型用法代碼示例。如果您正苦於以下問題:Python curses.meta方法的具體用法?Python curses.meta怎麽用?Python curses.meta使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類curses
的用法示例。
在下文中一共展示了curses.meta方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import meta [as 別名]
def start(self):
"""
Initialize the screen and input mode.
"""
assert self._started == False
self.s = curses.initscr()
self.has_color = curses.has_colors()
if self.has_color:
curses.start_color()
if curses.COLORS < 8:
# not colourful enough
self.has_color = False
if self.has_color:
try:
curses.use_default_colors()
self.has_default_colors=True
except _curses.error:
self.has_default_colors=False
self._setup_colour_pairs()
curses.noecho()
curses.meta(1)
curses.halfdelay(10) # use set_input_timeouts to adjust
self.s.keypad(0)
if not self._signal_keys_set:
self._old_signal_keys = self.tty_signal_keys()
super(Screen, self).start()
示例2: get_and_use_key_press
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import meta [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()
示例3: setUpCurses
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import meta [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