本文整理汇总了Python中javax.swing.JTextPane.cut方法的典型用法代码示例。如果您正苦于以下问题:Python JTextPane.cut方法的具体用法?Python JTextPane.cut怎么用?Python JTextPane.cut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextPane
的用法示例。
在下文中一共展示了JTextPane.cut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Console
# 需要导入模块: from javax.swing import JTextPane [as 别名]
# 或者: from javax.swing.JTextPane import cut [as 别名]
#.........这里部分代码省略.........
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()
if self.textpane.getCaretPosition() <= start and \