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


Python JTextPane.setSelectionEnd方法代码示例

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


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

示例1: Console

# 需要导入模块: from javax.swing import JTextPane [as 别名]
# 或者: from javax.swing.JTextPane import setSelectionEnd [as 别名]

#.........这里部分代码省略.........
            style.addAttribute(StyleConstants.Foreground, color)

        self.document.insertString(self.document.getLength(), prefix + data, style)
        self.textpane.caretPosition = self.document.getLength()

    def enterAction(self, event=None):
        text = self.getText()
        self._buffer.append(text)
        source = '\n'.join(self._buffer)
        more = self.interp.runsource(source)

        if more:
            self.write(self.PS2, color=Color.black)
        else:
            self.resetbuffer()
            self.write(self.PS1)

        self.history.append(text)

    def deleteAction(self, event=None):
        if self.inLastLine():
            if self.textpane.getSelectedText():
                self.document.remove(self.textpane.getSelectionStart(),
                     self.textpane.getSelectionEnd() - self.textpane.getSelectionStart())

            elif self.textpane.getCaretPosition() < self.document.getLength():
                self.document.remove(self.textpane.getCaretPosition(), 1)

    def deleteEndLineAction(self, event=None):
        if self.inLastLine():
            position = self.textpane.getCaretPosition()
            self.textpane.setSelectionStart(position)
            _, end = self.__getLastLineOffsets()
            self.textpane.setSelectionEnd(end - 1)
            self.textpane.cut()

    def homeAction(self, event=None):
        if self.inLastLine():
            start, end = self.__getLastLineOffsets()
            self.textpane.caretPosition = start

    def endAction(self, event=None):
        if self.inLastLine():
            start, end = self.__getLastLineOffsets()
            self.textpane.caretPosition = end - 1

    def pasteAction(self, event=None):
        if self.inLastLine():
            clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
            clipboard.getContents(self.textpane)
            contents = clipboard.getData(DataFlavor.stringFlavor)

            lines = contents.splitlines()
            for i, line in enumerate(lines):
                self.insertText(line)
                if i < len(lines) - 1:
                    self.enterAction()

    def keyboardInterruptAction(self, event=None):
        self.interp.runsource('raise KeyboardInterrupt\n')
        self.resetbuffer()
        self.write(self.PS1)

    def backspaceListener(self, event=None):
        start, end = self.__getLastLineOffsets()
开发者ID:kingfs,项目名称:jython-burp-api,代码行数:69,代码来源:console.py


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