Beispiel #1
0
    def cut_line(self):
        """
        If no text selected, cut whole
        current line to clipboard.
        """
        textCursor = self.editor.textCursor()
        if textCursor.hasSelection():
            return

        textCursor.select(QtGui.QTextCursor.LineUnderCursor)
        text = textCursor.selectedText()
        textCursor.insertText('')

        QtGui.QClipboard().setText(text)
Beispiel #2
0
    def copy_block_or_selection(self):
        """
        If there's no text selected,
        copy the current block.
        """
        textCursor = self.editor.textCursor()
        selection = textCursor.selection()
        text = selection.toPlainText()
        if not text:
            textCursor.select(QtGui.QTextCursor.BlockUnderCursor)
            selection = textCursor.selection()
            text = selection.toPlainText()

        QtGui.QClipboard().setText(text)
Beispiel #3
0
 def copy_tab_file_path(self, index):
     """
     Copy the current tab's file path
     (if it has one) to the clipboard.
     """
     data = self.tabData(index)
     path = data.get('path')
     if path is None or not path.strip():
         print('No file path for "{0}".'.format(data['name']))
         return
     clipboard = QtGui.QClipboard()
     clipboard.setText(path)
     print('Path copied to clipboard:')
     print(path)