本文整理汇总了Python中curses.BUTTON1_PRESSED属性的典型用法代码示例。如果您正苦于以下问题:Python curses.BUTTON1_PRESSED属性的具体用法?Python curses.BUTTON1_PRESSED怎么用?Python curses.BUTTON1_PRESSED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类curses
的用法示例。
在下文中一共展示了curses.BUTTON1_PRESSED属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dir_and_path_with_cr
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def test_dir_and_path_with_cr(self):
#self.setMovieMode(True)
self.runWithFakeInputs([
self.displayCheck(0, 0, [u" ci "]),
self.displayCheck(2, 7, [u" "]), CTRL_O,
self.displayCheck(0, 0, [u" ci Open File "]), CTRL_A,
self.writeText(self.pathToSample(u"")),
self.displayCheck(3, 0, [u"./ ", u"../ "]),
self.displayCheck(5, 0, [u"._ A name with cr\\r/"]),
self.mouseEvent(0, 5, 0, curses.BUTTON1_PRESSED),
self.displayCheck(5, 0, [u"example"]),
self.displayFindCheck(u"/._ A name with ",
u"cr\\r/"), KEY_ESCAPE, curses.ERR,
self.displayCheck(0, 0, [u" ci "]),
self.displayCheck(2, 7, [u" "]), CTRL_O,
self.displayCheck(0, 0, [u" ci Open File "]), CTRL_A,
self.writeText(self.pathToSample(u"._ A name")), CTRL_I,
self.displayCheck(5, 0, [u"example"]),
self.displayFindCheck(u"/._ A name with ", u"cr\\r/"), CTRL_Q,
CTRL_Q
])
示例2: addMouseInfo
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def addMouseInfo(self, timeStamp, mouseRow, mouseCol, bState):
"""
bState may be a logical or of:
curses.BUTTON1_PRESSED;
curses.BUTTON1_RELEASED;
...
curses.BUTTON_SHIFT
curses.BUTTON_CTRL
curses.BUTTON_ALT
"""
assert isinstance(timeStamp, int)
assert isinstance(mouseRow, int)
assert isinstance(mouseCol, int)
assert isinstance(bState, int)
# Note that the mouse info is x,y (col, row).
info = (timeStamp, mouseCol, mouseRow, 0, bState)
def createEvent(display, cmdIndex):
curses.addMouseEvent(info)
return None
return createEvent
示例3: test_prediction
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def test_prediction(self):
#self.setMovieMode(True)
sys.argv = []
self.runWithFakeInputs([
self.displayCheck(0, 0, [u" ci "]),
self.displayCheck(2, 7, [u" "]),
CTRL_P,
self.displayCheck(0, 0, [u" ci "]),
self.displayCheck(2, 2, [u"- Type|Name "]),
#self.displayCheckNot(3, 0, [u" open <new file> "]),
self.findTextAndClick(1000, u"[x]open", curses.BUTTON1_PRESSED),
self.displayCheckNot(3, 0, [u" open <new file> "]),
self.displayCheck(2, 2, [u"- Type|Name "]),
self.findTextAndClick(2000, u"[ ]open", curses.BUTTON1_PRESSED),
# TODO(dschuyler): Look into why this fails:
#self.displayCheck(3, 0, [" open <new file> "]),
CTRL_Q
])
示例4: set_mouse_tracking
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def set_mouse_tracking(self, enable=True):
"""
Enable mouse tracking.
After calling this function get_input will include mouse
click events along with keystrokes.
"""
enable = bool(enable)
if enable == self._mouse_tracking_enabled:
return
if enable:
curses.mousemask(0
| curses.BUTTON1_PRESSED | curses.BUTTON1_RELEASED
| curses.BUTTON2_PRESSED | curses.BUTTON2_RELEASED
| curses.BUTTON3_PRESSED | curses.BUTTON3_RELEASED
| curses.BUTTON4_PRESSED | curses.BUTTON4_RELEASED
| curses.BUTTON1_DOUBLE_CLICKED | curses.BUTTON1_TRIPLE_CLICKED
| curses.BUTTON2_DOUBLE_CLICKED | curses.BUTTON2_TRIPLE_CLICKED
| curses.BUTTON3_DOUBLE_CLICKED | curses.BUTTON3_TRIPLE_CLICKED
| curses.BUTTON4_DOUBLE_CLICKED | curses.BUTTON4_TRIPLE_CLICKED
| curses.BUTTON_SHIFT | curses.BUTTON_ALT
| curses.BUTTON_CTRL)
else:
raise NotImplementedError()
self._mouse_tracking_enabled = enable
示例5: init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def init_curses(self):
os.environ.setdefault('ESCDELAY', '25')
self.stdscr = curses.initscr()
self.stdscr.clear()
curses.noecho()
curses.curs_set(0)
curses.mousemask(curses.REPORT_MOUSE_POSITION
| curses.BUTTON1_PRESSED | curses.BUTTON1_RELEASED
| curses.BUTTON2_PRESSED | curses.BUTTON2_RELEASED
| curses.BUTTON3_PRESSED | curses.BUTTON3_RELEASED
| curses.BUTTON4_PRESSED | curses.BUTTON4_RELEASED
| curses.BUTTON1_CLICKED | curses.BUTTON3_CLICKED
| curses.BUTTON1_DOUBLE_CLICKED
| curses.BUTTON1_TRIPLE_CLICKED
| curses.BUTTON2_DOUBLE_CLICKED
| curses.BUTTON2_TRIPLE_CLICKED
| curses.BUTTON3_DOUBLE_CLICKED
| curses.BUTTON3_TRIPLE_CLICKED
| curses.BUTTON4_DOUBLE_CLICKED
| curses.BUTTON4_TRIPLE_CLICKED
| curses.BUTTON_SHIFT | curses.BUTTON_ALT
| curses.BUTTON_CTRL)
self.stdscr.keypad(True) # Handle our own escape codes for now
# The first call to getch seems to clobber the statusbar.
# So we make a dummy first call.
self.stdscr.nodelay(True)
self.stdscr.getch()
self.stdscr.nodelay(False)
示例6: test_select_line_via_line_numbers
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def test_select_line_via_line_numbers(self):
self.runWithTestFile(kTestFile, [
self.displayCheck(0, 0, [
u" ci _file_with_unlikely_file_name~ . ",
u" ",
u" 1 "
]),
self.cursorCheck(2, 7), u'a', u'b', u'c', CTRL_J, u'd', u'e',
CTRL_J, u'f', u'g', u'h', u'i',
self.cursorCheck(4, 11),
self.mouseEvent(0, 3, 2, curses.BUTTON1_PRESSED),
CTRL_L, CTRL_Q, u'n'
])
示例7: test_show_hide_columns
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def test_show_hide_columns(self):
#self.setMovieMode(True)
self.runWithFakeInputs([
self.prefCheck(u'editor', u'filesShowSizes', True),
self.displayCheck(0, 0, [u" ci "]),
CTRL_O,
self.displayCheck(0, 0, [u" ci Open"]),
self.findTextAndClick(1000, u"[x]sizes", curses.BUTTON1_PRESSED),
CTRL_Q
])
示例8: get_event
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def get_event(self):
"""
Check for an event without waiting.
"""
# Spin through notifications until we find something we want.
key = 0
while key != -1:
# Get the next key
key = self._screen.getch()
if key == curses.KEY_RESIZE:
# Handle screen resize
self._re_sized = True
elif key == curses.KEY_MOUSE:
# Handle a mouse event
_, x, y, _, bstate = curses.getmouse()
buttons = 0
# Some Linux modes only report clicks, so check for any
# button down or click events.
if (bstate & curses.BUTTON1_PRESSED != 0 or
bstate & curses.BUTTON1_CLICKED != 0):
buttons |= MouseEvent.LEFT_CLICK
if (bstate & curses.BUTTON3_PRESSED != 0 or
bstate & curses.BUTTON3_CLICKED != 0):
buttons |= MouseEvent.RIGHT_CLICK
if bstate & curses.BUTTON1_DOUBLE_CLICKED != 0:
buttons |= MouseEvent.DOUBLE_CLICK
return MouseEvent(x, y, buttons)
elif key != -1:
# Handle any byte streams first
logger.debug("Processing key: %x", key)
if self._unicode_aware and key > 0:
if key & 0xC0 == 0xC0:
self._bytes_to_return = struct.pack(b"B", key)
self._bytes_to_read = bin(key)[2:].index("0") - 1
logger.debug("Byte stream: %d bytes left",
self._bytes_to_read)
continue
elif self._bytes_to_read > 0:
self._bytes_to_return += struct.pack(b"B", key)
self._bytes_to_read -= 1
if self._bytes_to_read > 0:
continue
else:
key = ord(self._bytes_to_return.decode("utf-8"))
# Handle a genuine key press.
logger.debug("Returning key: %x", key)
if key in self._KEY_MAP:
return KeyboardEvent(self._KEY_MAP[key])
elif key != -1:
return KeyboardEvent(key)
return None
示例9: _encode_mouse_event
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def _encode_mouse_event(self):
# convert to escape sequence
last = next = self.last_bstate
(id,x,y,z,bstate) = curses.getmouse()
mod = 0
if bstate & curses.BUTTON_SHIFT: mod |= 4
if bstate & curses.BUTTON_ALT: mod |= 8
if bstate & curses.BUTTON_CTRL: mod |= 16
l = []
def append_button( b ):
b |= mod
l.extend([ 27, ord('['), ord('M'), b+32, x+33, y+33 ])
if bstate & curses.BUTTON1_PRESSED and last & 1 == 0:
append_button( 0 )
next |= 1
if bstate & curses.BUTTON2_PRESSED and last & 2 == 0:
append_button( 1 )
next |= 2
if bstate & curses.BUTTON3_PRESSED and last & 4 == 0:
append_button( 2 )
next |= 4
if bstate & curses.BUTTON4_PRESSED and last & 8 == 0:
append_button( 64 )
next |= 8
if bstate & curses.BUTTON1_RELEASED and last & 1:
append_button( 0 + escape.MOUSE_RELEASE_FLAG )
next &= ~ 1
if bstate & curses.BUTTON2_RELEASED and last & 2:
append_button( 1 + escape.MOUSE_RELEASE_FLAG )
next &= ~ 2
if bstate & curses.BUTTON3_RELEASED and last & 4:
append_button( 2 + escape.MOUSE_RELEASE_FLAG )
next &= ~ 4
if bstate & curses.BUTTON4_RELEASED and last & 8:
append_button( 64 + escape.MOUSE_RELEASE_FLAG )
next &= ~ 8
if bstate & curses.BUTTON1_DOUBLE_CLICKED:
append_button( 0 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
if bstate & curses.BUTTON2_DOUBLE_CLICKED:
append_button( 1 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
if bstate & curses.BUTTON3_DOUBLE_CLICKED:
append_button( 2 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
if bstate & curses.BUTTON4_DOUBLE_CLICKED:
append_button( 64 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
if bstate & curses.BUTTON1_TRIPLE_CLICKED:
append_button( 0 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
if bstate & curses.BUTTON2_TRIPLE_CLICKED:
append_button( 1 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
if bstate & curses.BUTTON3_TRIPLE_CLICKED:
append_button( 2 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
if bstate & curses.BUTTON4_TRIPLE_CLICKED:
append_button( 64 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
self.last_bstate = next
return l
示例10: mouseButtonName
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def mouseButtonName(buttonState):
"""Curses debugging. Prints readable name for state of mouse buttons."""
result = u""
if buttonState & curses.BUTTON1_RELEASED:
result += u'BUTTON1_RELEASED'
if buttonState & curses.BUTTON1_PRESSED:
result += u'BUTTON1_PRESSED'
if buttonState & curses.BUTTON1_CLICKED:
result += u'BUTTON1_CLICKED'
if buttonState & curses.BUTTON1_DOUBLE_CLICKED:
result += u'BUTTON1_DOUBLE_CLICKED'
if buttonState & curses.BUTTON2_RELEASED:
result += u'BUTTON2_RELEASED'
if buttonState & curses.BUTTON2_PRESSED:
result += u'BUTTON2_PRESSED'
if buttonState & curses.BUTTON2_CLICKED:
result += u'BUTTON2_CLICKED'
if buttonState & curses.BUTTON2_DOUBLE_CLICKED:
result += u'BUTTON2_DOUBLE_CLICKED'
if buttonState & curses.BUTTON3_RELEASED:
result += u'BUTTON3_RELEASED'
if buttonState & curses.BUTTON3_PRESSED:
result += u'BUTTON3_PRESSED'
if buttonState & curses.BUTTON3_CLICKED:
result += u'BUTTON3_CLICKED'
if buttonState & curses.BUTTON3_DOUBLE_CLICKED:
result += u'BUTTON3_DOUBLE_CLICKED'
if buttonState & curses.BUTTON4_RELEASED:
result += u'BUTTON4_RELEASED'
if buttonState & curses.BUTTON4_PRESSED:
result += u'BUTTON4_PRESSED'
if buttonState & curses.BUTTON4_CLICKED:
result += u'BUTTON4_CLICKED'
if buttonState & curses.BUTTON4_DOUBLE_CLICKED:
result += u'BUTTON4_DOUBLE_CLICKED'
if buttonState & curses.REPORT_MOUSE_POSITION:
result += u'REPORT_MOUSE_POSITION'
if buttonState & curses.BUTTON_SHIFT:
result += u' SHIFT'
if buttonState & curses.BUTTON_CTRL:
result += u' CTRL'
if buttonState & curses.BUTTON_ALT:
result += u' ALT'
return result
示例11: test_find_esc_from_find
# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON1_PRESSED [as 别名]
def test_find_esc_from_find(self):
self.runWithFakeInputs([
# Check initial state.
self.displayCheck(-1, 0, [u" "]),
self.displayCheckStyle(-2, 0, 1, 10,
self.prg.color.get(u'status_line', 0)),
# Basic open and close.
CTRL_F,
self.displayCheck(-3, 0, [u"Find: "]),
KEY_ESCAPE,
curses.ERR,
self.displayCheck(-3, 0, [u" ", u" ", u" "]),
self.displayCheckStyle(-2, 0, 1, 10,
self.prg.color.get(u'status_line', 0)),
# Open, expand, and close.
CTRL_F,
self.displayCheck(-3, 0, [u"Find: "]),
CTRL_I,
self.displayCheck(-3, 0, [u"Find: ", u"Replace: ", u"["]),
KEY_ESCAPE,
curses.ERR,
self.displayCheck(-3, 0, [u" ", u" ", u" "]),
self.displayCheckStyle(-2, 0, 1, 10,
self.prg.color.get(u'status_line', 0)),
# Regression test one for
# https://github.com/google/ci_edit/issues/170.
CTRL_F,
self.displayCheck(-3, 0, [u"Find: ", u"Replace: ", u"["]),
CTRL_I,
CTRL_I,
self.displayCheck(-3, 0, [u"Find: ", u"Replace: ", u"["]),
KEY_ESCAPE,
curses.ERR,
self.displayCheck(-3, 0, [u" ", u" ", u" "]),
self.displayCheckStyle(-2, 0, 1, 10,
self.prg.color.get(u'status_line', 0)),
# Regression test two for
# https://github.com/google/ci_edit/issues/170.
CTRL_F,
self.displayCheck(-3, 0, [u"Find: ", u"Replace: ", u"["]),
self.mouseEvent(0, 2, 10, curses.BUTTON1_PRESSED),
#self.displayCheck(-3, 0, [" ", " ", " "]),
self.displayCheckStyle(-2, 0, 1, 10,
self.prg.color.get(u'status_line', 0)),
CTRL_Q
])