本文整理匯總了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)