本文整理汇总了Python中pyqode.core.api.TextHelper.select_lines方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.select_lines方法的具体用法?Python TextHelper.select_lines怎么用?Python TextHelper.select_lines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.TextHelper
的用法示例。
在下文中一共展示了TextHelper.select_lines方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _compute_offsets
# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import select_lines [as 别名]
def _compute_offsets(self):
original_tc = self.editor.textCursor()
tc = self.editor.textCursor()
start = tc.selectionStart()
end = tc.selectionEnd()
tc.setPosition(start)
start_line = tc.blockNumber()
tc.setPosition(end)
end_line = tc.blockNumber()
th = TextHelper(self.editor)
th.select_lines(start=start_line, end=end_line, apply_selection=True)
source = th.selected_text()
results = get_field_infos(source, self.editor.free_format)
self.editor.setTextCursor(original_tc)
self.pic_infos_available.emit(results)
示例2: _computeOffsets
# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import select_lines [as 别名]
def _computeOffsets(self):
original_tc = self.editor.textCursor()
tc = self.editor.textCursor()
assert isinstance(tc, QTextCursor)
start = tc.selectionStart()
end = tc.selectionEnd()
tc.setPosition(start)
start_line = tc.blockNumber() + 1
tc.setPosition(end)
end_line = tc.blockNumber() + 1
th = TextHelper(self.editor)
th.select_lines(start=start_line, end=end_line, apply_selection=True)
source = th.selected_text()
self.picInfosAvailable.emit(get_field_infos(source))
self.editor.setTextCursor(original_tc)
示例3: _on_item_activated
# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import select_lines [as 别名]
def _on_item_activated(item, *args):
assert isinstance(item, QtWidgets.QTreeWidgetItem)
data = item.data(0, QtCore.Qt.UserRole)
try:
l = data['line']
except TypeError:
return # file item or root item
start = data['start']
lenght = data['end'] - start
if data is not None:
# open editor and go to line/column
e = editor.open_file(data['path'], data['line'], data['start'])
if e is None:
return
# select text
helper = TextHelper(e)
try:
cursor = helper.select_lines(start=l, end=l)
except AttributeError:
_logger().debug('failed to select occurent line in editor, not'
' a subclass of QPlainTextEdit')
else:
assert isinstance(cursor, QtGui.QTextCursor)
cursor.movePosition(cursor.StartOfBlock)
cursor.movePosition(cursor.Right, cursor.MoveAnchor, start)
cursor.movePosition(cursor.Right, cursor.KeepAnchor, lenght)
e.setTextCursor(cursor)
示例4: _on_occurrence_activated
# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import select_lines [as 别名]
def _on_occurrence_activated(item):
assert isinstance(item, QtWidgets.QTreeWidgetItem)
data = item.data(0, QtCore.Qt.UserRole)
try:
l = data['line']
except TypeError:
return # file item or root item
l = data['line']
start = data['start']
lenght = data['end'] - start
if data is not None:
# open editor and go to line/column
editor = api.editor.open_file(
data['path'], data['line'], data['start'])
if editor is None:
return
# select text
helper = TextHelper(editor)
cursor = helper.select_lines(start=l, end=l)
cursor.movePosition(cursor.StartOfBlock)
cursor.movePosition(cursor.Right, cursor.MoveAnchor, start)
cursor.movePosition(cursor.Right, cursor.KeepAnchor, lenght)
editor.setTextCursor(cursor)