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


Python TextHelper.selectionEnd方法代码示例

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


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

示例1: _on_key_pressed

# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import selectionEnd [as 别名]
 def _on_key_pressed(self, event):
     """
     Override key press to select the current scope if the user wants
     to deleted a folded scope (without selecting it).
     """
     delete_request = event.key() in [QtCore.Qt.Key_Backspace,
                                      QtCore.Qt.Key_Delete]
     if event.text() or delete_request:
         cursor = self.editor.textCursor()
         if cursor.hasSelection():
             # change selection to encompass the whole scope.
             positions_to_check = cursor.selectionStart(), cursor.selectionEnd()
         else:
             positions_to_check = (cursor.position(), )
         for pos in positions_to_check:
             block = self.editor.document().findBlock(pos)
             th = TextBlockHelper()
             if th.is_fold_trigger(block) and th.is_collapsed(block):
                 self.toggle_fold_trigger(block)
                 if delete_request and cursor.hasSelection():
                     scope = FoldScope(self.find_parent_scope(block))
                     tc = TextHelper(self.editor).select_lines(*scope.get_range())
                     if tc.selectionStart() > cursor.selectionStart():
                         start = cursor.selectionStart()
                     else:
                         start = tc.selectionStart()
                     if tc.selectionEnd() < cursor.selectionEnd():
                         end = cursor.selectionEnd()
                     else:
                         end = tc.selectionEnd()
                     tc.setPosition(start)
                     tc.setPosition(end, tc.KeepAnchor)
                     self.editor.setTextCursor(tc)
开发者ID:must40,项目名称:pyqode.core,代码行数:35,代码来源:folding.py

示例2: test_select_whole_line

# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import selectionEnd [as 别名]
def test_select_whole_line(editor):
    cursor = TextHelper(editor).select_whole_line(2)
    assert isinstance(cursor, QtGui.QTextCursor)
    assert cursor.hasSelection()
    assert cursor.selectionStart() == 28
    assert cursor.selectionEnd() == 99
开发者ID:dtonal,项目名称:pyqode.core,代码行数:8,代码来源:test_text.py


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