MCPcopy Index your code
hub / github.com/processing/processing / paste

Method paste

app/src/processing/app/syntax/JEditTextArea.java:1766–1830  ·  view source on GitHub ↗

Inserts the clipboard contents into the text.

()

Source from the content-addressed store, hash-verified

1764 * Inserts the clipboard contents into the text.
1765 */
1766 public void paste() {
1767// System.out.println("focus owner is: " + isFocusOwner());
1768 if (editable) {
1769 Clipboard clipboard = getToolkit().getSystemClipboard();
1770 try {
1771 String selection =
1772 ((String) clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor));
1773
1774 if (selection.contains("\r\n")) {
1775 selection = selection.replaceAll("\r\n", "\n");
1776
1777 } else if (selection.contains("\r")) {
1778 // The Mac OS MRJ doesn't convert \r to \n, so do it here
1779 selection = selection.replace('\r','\n');
1780 }
1781
1782 // Remove tabs and replace with spaces
1783 // http://code.google.com/p/processing/issues/detail?id=69
1784 if (selection.contains("\t")) {
1785 int tabSize = Preferences.getInteger("editor.tabs.size");
1786 char[] c = new char[tabSize];
1787 Arrays.fill(c, ' ');
1788 String tabString = new String(c);
1789 selection = selection.replaceAll("\t", tabString);
1790 }
1791
1792 // Replace unicode x00A0 (non-breaking space) with just a plain space.
1793 // Seen often on Mac OS X when pasting from Safari. [fry 030929]
1794 selection = selection.replace('\u00A0', ' ');
1795
1796 // Remove ASCII NUL characters. Reported when pasting from
1797 // Acrobat Reader and PDF documents. [fry 130719]
1798 // https://github.com/processing/processing/issues/1973
1799 if (selection.indexOf('\0') != -1) {
1800 //System.out.println("found NUL charaacters");
1801 //int before = selection.length();
1802 selection = selection.replaceAll("\0", "");
1803 //int after = selection.length();
1804 //System.out.println(before + " " + after);
1805 }
1806
1807 int repeatCount = inputHandler.getRepeatCount();
1808 StringBuilder sb = new StringBuilder();
1809 for (int i = 0; i < repeatCount; i++) {
1810 sb.append(selection);
1811 }
1812 selection = sb.toString();
1813 setSelectedText(selection);
1814
1815 } catch (Exception e) {
1816 getToolkit().beep();
1817 System.err.println("Clipboard does not contain a string");
1818 DataFlavor[] flavors = clipboard.getAvailableDataFlavors();
1819 for (DataFlavor f : flavors) {
1820 try {
1821 Object o = clipboard.getContents(this).getTransferData(f);
1822 System.out.println(f + " = " + o);
1823 } catch (Exception ex) {

Callers 3

actionPerformedMethod · 0.80
actionPerformedMethod · 0.80
handlePasteMethod · 0.80

Calls 14

getIntegerMethod · 0.95
setSelectedTextMethod · 0.95
getSystemClipboardMethod · 0.80
getTransferDataMethod · 0.80
getRepeatCountMethod · 0.80
beepMethod · 0.80
containsMethod · 0.45
replaceAllMethod · 0.45
replaceMethod · 0.45
fillMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected