當前位置: 首頁>>代碼示例>>Python>>正文


Python TextHelper.word_under_cursor方法代碼示例

本文整理匯總了Python中pyqode.core.api.TextHelper.word_under_cursor方法的典型用法代碼示例。如果您正苦於以下問題:Python TextHelper.word_under_cursor方法的具體用法?Python TextHelper.word_under_cursor怎麽用?Python TextHelper.word_under_cursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyqode.core.api.TextHelper的用法示例。


在下文中一共展示了TextHelper.word_under_cursor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_decoration

# 需要導入模塊: from pyqode.core.api import TextHelper [as 別名]
# 或者: from pyqode.core.api.TextHelper import word_under_cursor [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

示例2: test_clear_decoration

# 需要導入模塊: from pyqode.core.api import TextHelper [as 別名]
# 或者: from pyqode.core.api.TextHelper import word_under_cursor [as 別名]
def test_clear_decoration(editor):
    # should work even when there are no more decorations
    helper = TextHelper(editor)
    editor.decorations.clear()
    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)
    editor.decorations.clear()
    assert editor.decorations.append(deco)
    assert editor.decorations.remove(deco)
開發者ID:SirmoGames,項目名稱:pyqode.core,代碼行數:15,代碼來源:test_decoration.py

示例3: test_remove_decoration

# 需要導入模塊: from pyqode.core.api import TextHelper [as 別名]
# 或者: from pyqode.core.api.TextHelper import word_under_cursor [as 別名]
def test_remove_decoration(editor):
    helper = TextHelper(editor)
    TextHelper(editor).goto_line(1, 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 editor.decorations.remove(deco)
    # already removed, return False
    assert not editor.decorations.remove(deco)
    assert editor.decorations.append(deco)
    # keep editor clean for next tests
    editor.decorations.clear()
開發者ID:SirmoGames,項目名稱:pyqode.core,代碼行數:16,代碼來源:test_decoration.py

示例4: _auto_import

# 需要導入模塊: from pyqode.core.api import TextHelper [as 別名]
# 或者: from pyqode.core.api.TextHelper import word_under_cursor [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


注:本文中的pyqode.core.api.TextHelper.word_under_cursor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。