本文整理汇总了Python中pyqode.core.api.utils.TextHelper.cursor_absolute_poition方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.cursor_absolute_poition方法的具体用法?Python TextHelper.cursor_absolute_poition怎么用?Python TextHelper.cursor_absolute_poition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.utils.TextHelper
的用法示例。
在下文中一共展示了TextHelper.cursor_absolute_poition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CodeCompletionMode
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import cursor_absolute_poition [as 别名]
#.........这里部分代码省略.........
def _reset_sync_data(self):
debug('reset sync data and hide popup')
self._last_cursor_line = -1
self._last_cursor_column = -1
self._hide_popup()
def request_completion(self):
line = self._helper.current_line_nbr()
column = self._helper.current_column_nbr() - \
len(self.completion_prefix)
same_context = (line == self._last_cursor_line and
column == self._last_cursor_column)
if same_context:
if self._request_id - 1 == self._last_request_id:
# context has not changed and the correct results can be
# directly shown
debug('request completion ignored, context has not '
'changed')
self._show_popup()
else:
# same context but result not yet available
pass
return True
else:
debug('requesting completion')
data = {
'code': self.editor.toPlainText(),
'line': line,
'column': column,
'path': self.editor.file.path,
'encoding': self.editor.file.encoding,
'prefix': self.completion_prefix,
'request_id': self._request_id,
'abs_pos' : self._helper.cursor_absolute_poition(),
'mime_type' : self.editor.current_mime_type
}
try:
self.editor.backend.send_request(
backend.CodeCompletionWorker, args=data,
on_receive=self._on_results_available)
except NotRunning:
_logger().exception('failed to send the completion request')
return False
else:
debug('request sent: %r', data)
self._last_cursor_column = column
self._last_cursor_line = line
self._request_id += 1
return True
def _is_shortcut(self, event):
"""
Checks if the event's key and modifiers make the completion shortcut
(Ctrl+Space)
:param event: QKeyEvent
:return: bool
"""
modifier = (QtCore.Qt.MetaModifier if sys.platform == 'darwin' else
QtCore.Qt.ControlModifier)
valid_modifier = int(event.modifiers() & modifier) == modifier
valid_key = event.key() == self._trigger_key
return valid_key and valid_modifier
def _hide_popup(self):