本文整理汇总了Python中pyqode.core.api.utils.TextHelper.goto_line方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.goto_line方法的具体用法?Python TextHelper.goto_line怎么用?Python TextHelper.goto_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.utils.TextHelper
的用法示例。
在下文中一共展示了TextHelper.goto_line方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_selected_text
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [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: test_do_home_key
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [as 别名]
def test_do_home_key(editor):
QTest.qWait(2000)
helper = TextHelper(editor)
helper.goto_line(336, 29)
assert editor.textCursor().positionInBlock() == 29
assert TextHelper(editor).line_indent() == 4
editor._do_home_key()
assert editor.textCursor().positionInBlock() == 4
editor._do_home_key()
assert editor.textCursor().positionInBlock() == 0
示例3: test_cut_no_selection
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [as 别名]
def test_cut_no_selection(editor):
assert isinstance(editor, CodeEdit)
editor.setPlainText('''Line 1
Line 2
Line 3''', '', '')
helper = TextHelper(editor)
# eat empty line
helper.goto_line(0)
assert helper.line_count() == 3
editor.cut()
assert helper.line_count() == 2
示例4: test_matched_selection
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [as 别名]
def test_matched_selection(editor):
line, column, text = 233, 14, ''' editor.textCursor(), 'import', QtGui.QTextDocument.FindCaseSensitively'''
cursor = editor.textCursor()
assert not cursor.hasSelection()
helper = TextHelper(editor)
helper.goto_line(line, column)
assert helper.cursor_position()[0] == line
assert helper.cursor_position()[1] == column
cursor = editor.textCursor()
helper.match_select()
cursor = editor.textCursor()
assert cursor.hasSelection()
assert text in cursor.selectedText()
示例5: test_matched_selection
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [as 别名]
def test_matched_selection(editor):
line, column, text = 297, 14, '''__file__'''
cursor = editor.textCursor()
assert not cursor.hasSelection()
helper = TextHelper(editor)
helper.goto_line(line, column)
assert helper.cursor_position()[0] == line
assert helper.cursor_position()[1] == column
cursor = editor.textCursor()
helper.match_select()
cursor = editor.textCursor()
assert cursor.hasSelection()
assert text in cursor.selectedText()
示例6: test_extended_selection
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [as 别名]
def test_extended_selection(editor):
for line, column, text in [(8, 15, 'pyqode.core.api.utils'),
(8, 1, 'from')]:
editor.file.open(__file__)
QTest.qWait(1000)
cursor = editor.textCursor()
assert not cursor.hasSelection()
helper = TextHelper(editor)
helper.goto_line(line, column)
assert helper.cursor_position()[0] == line
assert helper.cursor_position()[1] == column
cursor = editor.textCursor()
assert text in cursor.block().text()
helper.select_extended_word()
cursor = editor.textCursor()
assert cursor.hasSelection()
assert cursor.selectedText() == text
示例7: goto_line
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [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)
示例8: test_copy_no_selection
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import goto_line [as 别名]
def test_copy_no_selection(editor):
"""
Tests the select_line_on_copy_empty option that toggles the
"whole line selection on copy with empty selection"-feature
"""
assert isinstance(editor, CodeEdit)
editor.setPlainText('''Line 1
Line 2
Line 3''', '', '')
helper = TextHelper(editor)
helper.goto_line(0)
editor.textCursor().clearSelection()
editor.select_line_on_copy_empty = False
editor.copy()
assert editor.textCursor().hasSelection() is False
editor.textCursor().clearSelection()
editor.select_line_on_copy_empty = True
editor.copy()
assert editor.textCursor().hasSelection()