当前位置: 首页>>代码示例>>Python>>正文


Python TextHelper.goto_line方法代码示例

本文整理汇总了Python中pyqode.core.api.TextHelper.goto_line方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.goto_line方法的具体用法?Python TextHelper.goto_line怎么用?Python TextHelper.goto_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyqode.core.api.TextHelper的用法示例。


在下文中一共展示了TextHelper.goto_line方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _on_item_clicked

# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import goto_line [as 别名]
 def _on_item_clicked(self, item):
     """
     Go to the item position in the editor.
     """
     if item:
         name = item.data(0, QtCore.Qt.UserRole)
         if name:
             go = name.block.blockNumber()
             helper = TextHelper(self._editor)
             if helper.current_line_nbr() != go:
                 helper.goto_line(go, column=name.column)
             self._editor.setFocus()
开发者ID:sopak,项目名称:cadquery-freecad-module,代码行数:14,代码来源:outline.py

示例2: test_add_decoration

# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import goto_line [as 别名]
def test_add_decoration(editor):
    helper = TextHelper(editor)
    helper.goto_line(2, 2)
    cursor = helper.word_under_cursor(select_whole_word=True)
    deco = TextDecoration(cursor)
    deco.set_as_bold()
    deco.set_as_underlined(QtGui.QColor("#FF0000"))
    editor.decorations.append(deco)
    assert not editor.decorations.append(deco)
    assert deco.contains_cursor(cursor)
    # keep editor clean for next tests
    editor.decorations.clear()
开发者ID:SirmoGames,项目名称:pyqode.core,代码行数:14,代码来源:test_decoration.py

示例3: _on_bt_toggled

# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import goto_line [as 别名]
 def _on_bt_toggled(self, *ar):
     if not self._lock:
         self._lock = True
         for w in self._widgets:
             if w == self.sender():
                 break
         if self._toggled:
             self._toggled.setChecked(False)
         self._toggled = w
         th = TextHelper(self.editor)
         line = w.scope.blockNumber()
         th.goto_line(line, column=th.line_indent(line))
         self._lock = False
         self.editor.setFocus()
开发者ID:SirmoGames,项目名称:hackedit,代码行数:16,代码来源:navigation.py

示例4: test_dynamic_folding_insert_section

# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import goto_line [as 别名]
def test_dynamic_folding_insert_section():
    # test insert section under empty data division
    # data division (which is not a fold trigger initially) block will become a fold trigger
    editor = CobolCodeEdit()
    editor.setPlainText(section_code, '', '')
    th = TextHelper(editor)
    block = editor.document().findBlockByNumber(2)
    assert TextBlockHelper.is_fold_trigger(block) is False
    cursor = th.goto_line(2, column=len('       DATA DIVISION.'))
    cursor.insertText('\n       WORKING-STORAGE SECTION.')
    assert TextBlockHelper.is_fold_trigger(block) is True
开发者ID:SirmoGames,项目名称:pyqode.cobol,代码行数:13,代码来源:test_folding.py

示例5: _auto_import

# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import goto_line [as 别名]
 def _auto_import(self):
     helper = TextHelper(self.editor)
     name = helper.word_under_cursor(select_whole_word=True).selectedText()
     if name:
         import_stmt = 'import %s' % name
     else:
         import_stmt = ''
     import_stmt, status = QtWidgets.QInputDialog.getText(
         self.editor, _('Add import'), _('Import statement:'),
         QtWidgets.QLineEdit.Normal, import_stmt)
     if status:
         sh = self.editor.syntax_highlighter
         line_number = sh.import_statements[0].blockNumber()
         for stmt in sh.import_statements:
             if stmt.text() == import_stmt:
                 # same import already exists
                 return
         l, c = helper.cursor_position()
         cursor = helper.goto_line(line_number)
         cursor.insertText(import_stmt + '\n')
         helper.goto_line(l + 1, c)
开发者ID:SirmoGames,项目名称:hackedit-python,代码行数:23,代码来源:add_import.py

示例6: test_dynamic_folding_insert_end_if

# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import goto_line [as 别名]
def test_dynamic_folding_insert_end_if():
    # test insert section under empty data division
    # data division (which is not a fold trigger initially) block will become a fold trigger
    editor = CobolCodeEdit()
    editor.setPlainText(end_if_code, '', '')
    th = TextHelper(editor)
    block = editor.document().findBlockByNumber(4)
    first, last = FoldScope(block).get_range()
    assert first == 4
    assert last == 5
    cursor = th.goto_line(5, column=len('          DISPLAY "FOO"'))
    cursor.insertText('\n       END-IF')
    first, last = FoldScope(block).get_range()
    assert first == 4
    assert last == 6
    editor.close()
开发者ID:SirmoGames,项目名称:pyqode.cobol,代码行数:18,代码来源:test_folding.py


注:本文中的pyqode.core.api.TextHelper.goto_line方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。