本文整理汇总了Python中pyqode.core.api.utils.TextHelper.current_line_nbr方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.current_line_nbr方法的具体用法?Python TextHelper.current_line_nbr怎么用?Python TextHelper.current_line_nbr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.utils.TextHelper
的用法示例。
在下文中一共展示了TextHelper.current_line_nbr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: request_completion
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_nbr [as 别名]
def request_completion(self):
"""
Requests a code completion at the current cursor position.
"""
_logger().debug('request code completion')
self._col = self.editor.textCursor().positionInBlock() - len(
self.completion_prefix)
helper = TextHelper(self.editor)
if not self._request_cnt:
# only check first byte
tc = self.editor.textCursor()
while tc.atBlockEnd() and not tc.atBlockStart() and \
tc.position():
tc.movePosition(tc.Left)
disabled_zone = TextHelper(self.editor).is_comment_or_string(
tc)
if disabled_zone:
_logger().debug(
"cc: cancel request, cursor is in a disabled zone")
return False
self._request_cnt += 1
self._collect_completions(self.editor.toPlainText(),
helper.current_line_nbr(),
helper.current_column_nbr() -
len(self.completion_prefix),
self.editor.file.path,
self.editor.file.encoding,
self.completion_prefix)
return True
return False
示例2: goto_line
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_nbr [as 别名]
def goto_line(self):
"""
Shows the *go to line dialog* and go to the selected line.
"""
helper = TextHelper(self)
line, result = DlgGotoLine.get_line(self, helper.current_line_nbr(), helper.line_count())
if not result:
return
return helper.goto_line(line, move=True)
示例3: __swapLine
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_nbr [as 别名]
def __swapLine(self, up: bool):
helper = TextHelper(self)
text = helper.current_line_text()
line_nbr = helper.current_line_nbr()
if up:
swap_line_nbr = line_nbr - 1
else:
swap_line_nbr = line_nbr + 1
swap_text = helper.line_text(swap_line_nbr)
if (swap_line_nbr < helper.line_count()
and line_nbr < helper.line_count()):
helper.set_line_text(line_nbr, swap_text)
helper.set_line_text(swap_line_nbr, text)
示例4: CodeCompletionMode
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_nbr [as 别名]
#.........这里部分代码省略.........
debug("completion results (completions=%r), prefix=%s",
results, self.completion_prefix)
context = results[0]
results = results[1:]
line, column, request_id = context
debug('request context: %r', context)
debug('latest context: %r', (self._last_cursor_line,
self._last_cursor_column,
self._request_id))
self._last_request_id = request_id
if (line == self._last_cursor_line and
column == self._last_cursor_column):
if self.editor:
all_results = []
for res in results:
all_results += res
self._show_completions(all_results)
else:
debug('outdated request, dropping')
#
# Helper methods
#
def _is_popup_visible(self):
return self._completer.popup().isVisible()
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
}
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')