本文整理汇总了Python中pyqode.core.api.utils.TextHelper.word_under_cursor方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.word_under_cursor方法的具体用法?Python TextHelper.word_under_cursor怎么用?Python TextHelper.word_under_cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.utils.TextHelper
的用法示例。
在下文中一共展示了TextHelper.word_under_cursor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_selected_text
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import word_under_cursor [as 别名]
def test_selected_text(editor):
helper = TextHelper(editor)
helper.goto_line(2, 1, move=True)
QTest.qWait(100)
assert helper.word_under_cursor().selectedText() == 'T'
assert helper.word_under_cursor(
select_whole_word=True).selectedText() == 'This'
示例2: CodeCompletionMode
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import word_under_cursor [as 别名]
#.........这里部分代码省略.........
if self.editor:
# propagate changes to every clone
for clone in self.editor.clones:
try:
clone.modes.get(CodeCompletionMode).trigger_symbols = value
except KeyError:
# this should never happen since we're working with clones
pass
@property
def case_sensitive(self):
"""
True to performs case sensitive completion matching.
"""
return self._case_sensitive
@case_sensitive.setter
def case_sensitive(self, value):
self._case_sensitive = value
if self.editor:
# propagate changes to every clone
for clone in self.editor.clones:
try:
clone.modes.get(CodeCompletionMode).case_sensitive = value
except KeyError:
# this should never happen since we're working with clones
pass
@property
def completion_prefix(self):
"""
Returns the current completion prefix
"""
return self._helper.word_under_cursor(
select_whole_word=False).selectedText().strip()
@property
def show_tooltips(self):
"""
True to show tooltips next to the current completion.
"""
return self._show_tooltips
@show_tooltips.setter
def show_tooltips(self, value):
self._show_tooltips = value
if self.editor:
# propagate changes to every clone
for clone in self.editor.clones:
try:
clone.modes.get(CodeCompletionMode).show_tooltips = value
except KeyError:
# this should never happen since we're working with clones
pass
def __init__(self):
Mode.__init__(self)
QtCore.QObject.__init__(self)
self._current_completion = ""
self._trigger_key = QtCore.Qt.Key_Space
self._trigger_len = 1
self._trigger_symbols = ['.']
self._case_sensitive = False
self._completer = None
self._filter_mode = self.FILTER_FUZZY
self._last_cursor_line = -1
示例3: CodeCompletionMode
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import word_under_cursor [as 别名]
#.........这里部分代码省略.........
if self.editor:
# propagate changes to every clone
for clone in self.editor.clones:
try:
clone.modes.get(CodeCompletionMode).show_tooltips = value
except KeyError:
# this should never happen since we're working with clones
pass
@property
def case_sensitive(self):
"""
True to performs case sensitive completion matching.
"""
return self._case_sensitive
@case_sensitive.setter
def case_sensitive(self, value):
self._case_sensitive = value
if self.editor:
# propagate changes to every clone
for clone in self.editor.clones:
try:
clone.modes.get(CodeCompletionMode).case_sensitive = value
except KeyError:
# this should never happen since we're working with clones
pass
@property
def completion_prefix(self):
"""
Returns the current completion prefix
"""
return self._helper.word_under_cursor(
select_whole_word=False).selectedText().strip()
def __init__(self):
Mode.__init__(self)
QtCore.QObject.__init__(self)
self._current_completion = ""
# use to display a waiting cursor if completion provider takes too much
# time
self._job_runner = DelayJobRunner(delay=1000)
self._tooltips = {}
self._cursor_line = -1
self._cancel_next = False
self._request_cnt = 0
self._last_completion_prefix = ""
self._trigger_key = None
self._trigger_len = None
self._trigger_symbols = None
self._show_tooltips = None
self._case_sensitive = None
self._data = None
self._completer = None
self._col = 0
self._skip_next_backspace_released = False
self._init_settings()
def _init_settings(self):
self._trigger_key = QtCore.Qt.Key_Space
self._trigger_len = 1
self._trigger_symbols = ['.']
self._show_tooltips = True
self._case_sensitive = False