u'''Paste windows clipboard
505764
def paste(self,e):
        '''
        if self.enable_win32_clipboard:
                txt=clipboard.get_clipboard_text_and_convert(False)
                self.insert_text(txt)
785506
def do_paste(self, event):
        
        # find where the user has clicked
        col_ind = self.GetGridCursorCol()
        row_ind = self.GetGridCursorRow()
        # read in clipboard text
        text_df = pd.read_clipboard(header=None, sep='\t').fillna('')
        # add extra rows if need to accomadate clipboard text
        row_length_diff = len(text_df) - (len(self.row_labels) - row_ind)
        if row_length_diff > 0:
            for n in range(row_length_diff):
                self.add_row()
        # ignore excess columns if present
        col_length_diff = len(text_df.columns) - (len(self.col_labels) - col_ind)
        if col_length_diff > 0:
            text_df = text_df.iloc[:, :-col_length_diff].copy()
        # go through copied text and parse it into the grid rows
        for label, row_data in text_df.iterrows():
            col_range = list(range(col_ind, col_ind + len(row_data)))
            if len(row_data) > 1:
                cols = list(zip(col_range, row_data.index))
                for column in cols:
                    value = row_data[column[1]]
                    this_col = column[0]
                    self.SetCellValue(row_ind, this_col, str(value))
            else:
                value = row_data[0]
                self.SetCellValue(row_ind, col_ind, str(value))
            row_ind += 1
        # could instead use wxPython clipboard here
        # see old git history for that
        self.size_grid()
        event.Skip()
1185927
def _copyItemToClipboard(self):
        """"""
        if self._current_item is None:
            return
        dp = getattr(self._current_item, '_dp', None)
        if dp and dp.archived:
            path = dp.fullpath.replace(" ", "\\ ")
            QApplication.clipboard().setText(path, QClipboard.Clipboard)
            QApplication.clipboard().setText(path, QClipboard.Selection)
329814
def paste_clipboard_data(self, data, paste_mode=PasteMode.EMACS, count=1):
        
        assert isinstance(data, ClipboardData)
        assert paste_mode in (PasteMode.VI_BEFORE, PasteMode.VI_AFTER, PasteMode.EMACS)

        original_document = self.document
        self.document = self.document.paste_clipboard_data(data, paste_mode=paste_mode, count=count)

        # Remember original document. This assignment should come at the end,
        # because assigning to 'document' will erase it.
        self.document_before_paste = original_document
407301
def copy( self ):
        
        text = []
        for item in self.selectedItems():
            text.append(nativestring(item.text()))
        
        QApplication.clipboard().setText(','.join(text))
753059
def save_file_clipboard(self, fnames=None):
        """"""
        if fnames is None:
            fnames = self.get_selected_filenames()
        if not isinstance(fnames, (tuple, list)):
            fnames = [fnames]
        if len(fnames) >= 1:
            try:
                selected_item = osp.commonpath(fnames)
            except AttributeError:
                #  py2 does not have commonpath
                if len(fnames) > 1:
                    selected_item = osp.normpath(
                            osp.dirname(osp.commonprefix(fnames)))
                else:
                    selected_item = fnames[0]
            if osp.isfile(selected_item):
                parent_path = osp.dirname(selected_item)
            else:
                parent_path = osp.normpath(selected_item)
            cb_data = QApplication.clipboard().mimeData()
            if cb_data.hasUrls():
                urls = cb_data.urls()
                for url in urls:
                    source_name = url.toLocalFile()
                    base_name = osp.basename(source_name)
                    if osp.isfile(source_name):
                        try:
                            while base_name in os.listdir(parent_path):
                                file_no_ext, file_ext = osp.splitext(base_name)
                                end_number = re.search(r'\d+$', file_no_ext)
                                if end_number:
                                    new_number = int(end_number.group()) + 1
                                else:
                                    new_number = 1
                                left_string = re.sub(r'\d+$', '', file_no_ext)
                                left_string += str(new_number)
                                base_name = left_string + file_ext
                                destination = osp.join(parent_path, base_name)
                            else:
                                destination = osp.join(parent_path, base_name)
                            shutil.copy(source_name, destination)
                        except Exception as e:
                            QMessageBox.critical(self, _('Error pasting file'),
                                                 _("Unsupported copy operation"
                                                   ". The error was:\n\n")
                                                 + to_text_string(e))
                    else:
                        try:
                            while base_name in os.listdir(parent_path):
                                end_number = re.search(r'\d+$', base_name)
                                if end_number:
                                    new_number = int(end_number.group()) + 1
                                else:
                                    new_number = 1
                                left_string = re.sub(r'\d+$', '', base_name)
                                base_name = left_string + str(new_number)
                                destination = osp.join(parent_path, base_name)
                            else:
                                destination = osp.join(parent_path, base_name)
                            if osp.realpath(destination).startswith(
                                    osp.realpath(source_name) + os.sep):
                                QMessageBox.critical(self,
                                                     _('Recursive copy'),
                                                     _("Source is an ancestor"
                                                       " of destination"
                                                       " folder."))
                                continue
                            shutil.copytree(source_name, destination)
                        except Exception as e:
                            QMessageBox.critical(self,
                                                 _('Error pasting folder'),
                                                 _("Unsupported copy"
                                                   " operation. The error was:"
                                                   "\n\n") + to_text_string(e))
            else:
                QMessageBox.critical(self, _("No file in clipboard"),
                                     _("No file in the clipboard. Please copy"
                                       " a file to the clipboard first."))
        else:
            if QApplication.clipboard().mimeData().hasUrls():
                QMessageBox.critical(self, _('Blank area'),
                                     _("Cannot paste in the blank area."))
            else:
                pass
992830
def copy_to_clipboard(self):
        
        tree = self.treeview
        # get the selected item:
        selection = tree.selection()
        if selection:
            self.filter_remove(remember=True)
            root = ET.Element('selection')
            for item in selection:
                node = self.tree_node_to_xml('', item)
                root.append(node)
            # python2 issue
            try:
                text = ET.tostring(root, encoding='unicode')
            except LookupError:
                text = ET.tostring(root, encoding='UTF-8')
            tree.clipboard_clear()
            tree.clipboard_append(text)
            self.filter_restore()
963570
function pasteText(text) {
        text = editor.dom.encode(text).replace(/\r\n/g, '\n');

        var startBlock = editor.dom.getParent(editor.selection.getStart(), editor.dom.isBlock);

        // Create start block html for example <p attr="value">
        var forcedRootBlockName = editor.settings.forced_root_block;
        var forcedRootBlockStartHtml;
        if (forcedRootBlockName) {
          forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs);
          forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>';
        }

        if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
          text = Utils.filter(text, [
            [/\n/g, "<br>"]
          ]);
        } else {
          text = Utils.filter(text, [
            [/\n\n/g, "</p>" + forcedRootBlockStartHtml],
            [/^(.*<\/p>)(<p>)$/, forcedRootBlockStartHtml + '$1'],
            [/\n/g, "<br />"]
          ]);

          if (text.indexOf('<p>') != -1) {
            text = forcedRootBlockStartHtml + text;
          }
        }

        pasteHtml(text, false);
      }
108374
def paste_action_callback(self, *event):
        """"""
        if react_to_event(self.view, self.tree_view, event):
            sm_selection, _ = self.get_state_machine_selection()
            # only list specific elements are cut by widget
            if len(sm_selection.states) == 1:
                global_clipboard.paste(sm_selection.get_selected_state(), limited=['states', 'transitions', 'data_flows'])
            else:
                logger.warning("Please select only one state to paste.")
            return True
84407
def paste_format(self):
        

        row, col, tab = self.grid.actions.cursor

        selection = self.get_selection()
        if selection:
            # Use selection rather than cursor for top left cell if present
            row, col = [tl if tl is not None else 0
                        for tl in selection.get_bbox()[0]]

        cell_attributes = self.grid.code_array.cell_attributes

        string_data = self.grid.main_window.clipboard.get_clipboard()
        format_data = ast.literal_eval(string_data)

        ca = format_data["cell_attributes"]
        rh = format_data["row_heights"]
        cw = format_data["col_widths"]

        assert isinstance(ca, types.ListType)
        assert isinstance(rh, types.DictType)
        assert isinstance(cw, types.DictType)

        # Cell attributes

        for selection_params, tab, attrs in ca:
            base_selection = Selection(*selection_params)
            shifted_selection = base_selection.shifted(row, col)
            if "merge_area" not in attrs:
                # Do not paste merge areas because this may have
                # inintended consequences for existing merge areas
                new_cell_attribute = shifted_selection, tab, attrs
                cell_attributes.append(new_cell_attribute)

        # Row heights
        row_heights = self.grid.code_array.row_heights
        for __row, __tab in rh:
            row_heights[__row+row, tab] = rh[__row, __tab]

        # Column widths
        col_widths = self.grid.code_array.col_widths
        for __col, __tab in cw:
            col_widths[__col+col, tab] = cw[(__col, __tab)]
1106619
def create_clipboard(self, text, selection=Gdk.SELECTION_CLIPBOARD):
        
        clipboard = Gtk.Clipboard.get(selection)
        clipboard.set_text('\n'.join(text), -1)
        clipboard.store()
        return clipboard
1030882
public static void copyToClipboard(String string) {
        ClipboardContent content = new ClipboardContent();
        content.putString(string);
        Clipboard.getSystemClipboard().setContent(content);
        logger.info("copy '" + string + "' to clipboard");
    }
1336238
def paste_action_callback(self, *event):
        """"""
        if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None:
            _, dict_paths = self.get_view_selection()
            selected_data_list = rafcon.gui.clipboard.global_clipboard.get_semantic_dictionary_list()

            # enforce paste on root level if semantic data empty or nothing is selected
            if not dict_paths and not self.model.state.semantic_data:
                dict_paths = [[]]

            for target_dict_path_as_list in dict_paths:
                prev_value = self.model.state.semantic_data
                value = self.model.state.semantic_data
                for path_element in target_dict_path_as_list:
                    prev_value = value
                    value = value[path_element]
                if not isinstance(value, dict) and len(dict_paths) <= 1:  # if one selection take parent
                    target_dict_path_as_list.pop(-1)
                    value = prev_value
                if isinstance(value, dict):
                    for key_to_paste, value_to_add in selected_data_list:
                        self.model.state.add_semantic_data(target_dict_path_as_list, value_to_add, key_to_paste)
            self.reload_tree_store_data()
966541
def paste(location):
	""""""
	copyData = settings.getDataFile()
	if not location:
		location = "."
	try:
		data = pickle.load(open(copyData, "rb"))
		speech.speak("Pasting " + data["copyLocation"] + " to current directory.")
	except:
		speech.fail("It doesn't look like you've copied anything yet.")
		speech.fail("Type 'hallie copy <file>' to copy a file or folder.")
		return
	process, error = subprocess.Popen(["cp", "-r", data["copyLocation"], location], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()
	if "denied" in process:
		speech.fail("Unable to paste your file successfully. This is most likely due to a permission issue. You can try to run me as sudo!")
932532
def copy(self):
        """"""
        clipboard = QApplication.clipboard()
        clipl = []
        for idx in self.selectedIndexes():
            if not idx.isValid():
                continue
            obj = self.delegate.get_value(idx)
            # Check if we are trying to copy a numpy array, and if so make sure
            # to copy the whole thing in a tab separated format
            if isinstance(obj, (ndarray, MaskedArray)) \
              and ndarray is not FakeObject:
                if PY3:
                    output = io.BytesIO()
                else:
                    output = io.StringIO()
                try:
                    np_savetxt(output, obj, delimiter='\t')
                except:
                    QMessageBox.warning(self, _("Warning"),
                                        _("It was not possible to copy "
                                          "this array"))
                    return
                obj = output.getvalue().decode('utf-8')
                output.close()
            elif isinstance(obj, (DataFrame, Series)) \
              and DataFrame is not FakeObject:
                output = io.StringIO()
                try:
                    obj.to_csv(output, sep='\t', index=True, header=True)
                except Exception:
                    QMessageBox.warning(self, _("Warning"),
                                        _("It was not possible to copy "
                                          "this dataframe"))
                    return
                if PY3:
                    obj = output.getvalue()
                else:
                    obj = output.getvalue().decode('utf-8')
                output.close()
            elif is_binary_string(obj):
                obj = to_text_string(obj, 'utf8')
            else:
                obj = to_text_string(obj)
            clipl.append(obj)
        clipboard.setText('\n'.join(clipl))
1216346
def copyText( self ):
        
        view = self.currentWebView()
        QApplication.clipboard().setText(view.page().selectedText())
422667
def copy_path(self, fnames=None, method="absolute"):
        """"""
        cb = QApplication.clipboard()
        explorer_dir = self.fsmodel.rootPath()
        if fnames is None:
            fnames = self.get_selected_filenames()
        if not isinstance(fnames, (tuple, list)):
            fnames = [fnames]
        fnames = [_fn.replace(os.sep, "/") for _fn in fnames]
        if len(fnames) > 1:
            if method == "absolute":
                clipboard_files = ',\n'.join('"' + _fn + '"' for _fn in fnames)
            elif method == "relative":
                clipboard_files = ',\n'.join('"' +
                                             osp.relpath(_fn, explorer_dir).
                                             replace(os.sep, "/") + '"'
                                             for _fn in fnames)
        else:
            if method == "absolute":
                clipboard_files = fnames[0]
            elif method == "relative":
                clipboard_files = (osp.relpath(fnames[0], explorer_dir).
                                   replace(os.sep, "/"))
        copied_from = self.parent_widget.__class__.__name__
        if copied_from == 'ProjectExplorerWidget' and method == 'relative':
            clipboard_files = [path.strip(',"') for path in
                               clipboard_files.splitlines()]
            clipboard_files = ['/'.join(path.strip('/').split('/')[1:]) for
                               path in clipboard_files]
            if len(clipboard_files) > 1:
                clipboard_files = ',\n'.join('"' + _fn + '"' for _fn in
                                             clipboard_files)
            else:
                clipboard_files = clipboard_files[0]
        cb.setText(clipboard_files, mode=cb.Clipboard)