當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。