当前位置: 首页>>代码示例>>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;未经允许,请勿转载。