mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
convert tabs to spaces when pasting text (issue #69)
This commit is contained in:
@@ -20,6 +20,7 @@ import javax.swing.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
@@ -1824,8 +1825,26 @@ public class JEditTextArea extends JComponent
|
||||
if (editable) {
|
||||
Clipboard clipboard = getToolkit().getSystemClipboard();
|
||||
try {
|
||||
// The MacOS MRJ doesn't convert \r to \n, so do it here
|
||||
String selection = ((String)clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor)).replace('\r','\n');
|
||||
String selection =
|
||||
((String) clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor));
|
||||
|
||||
if (selection.contains("\r\n")) {
|
||||
selection = selection.replaceAll("\r\n", "\n");
|
||||
|
||||
} else if (selection.contains("\r")) {
|
||||
// The Mac OS MRJ doesn't convert \r to \n, so do it here
|
||||
selection = selection.replace('\r','\n');
|
||||
}
|
||||
|
||||
// Remove tabs and replace with spaces
|
||||
// http://code.google.com/p/processing/issues/detail?id=69
|
||||
if (selection.contains("\t")) {
|
||||
int tabSize = Preferences.getInteger("editor.tabs.size");
|
||||
char[] c = new char[tabSize];
|
||||
Arrays.fill(c, ' ');
|
||||
String tabString = new String(c);
|
||||
selection = selection.replaceAll("\t", tabString);
|
||||
}
|
||||
|
||||
// particularly on macosx when pasting from safari,
|
||||
// replace unicode x00A0 (non-breaking space)
|
||||
@@ -1834,12 +1853,13 @@ public class JEditTextArea extends JComponent
|
||||
|
||||
int repeatCount = inputHandler.getRepeatCount();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < repeatCount; i++)
|
||||
for (int i = 0; i < repeatCount; i++) {
|
||||
buf.append(selection);
|
||||
}
|
||||
selection = buf.toString();
|
||||
setSelectedText(selection);
|
||||
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
getToolkit().beep();
|
||||
System.err.println("Clipboard does not contain a string");
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ _ Linux file chooser is gross (presumably Windows too)
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1014
|
||||
|
||||
_ fix edge + 1 issue on stroke/fill for rectangles
|
||||
_ http://code.google.com/p/processing/issues/detail?id=509
|
||||
|
||||
_ add reference/docs for urlEncode() and urlDecode()
|
||||
|
||||
|
||||
@@ -13,10 +13,17 @@ X this is for fjen/js.. fix already contributed:
|
||||
X http://code.google.com/p/processing/issues/detail?id=718
|
||||
X ByteUnderflowException thrown and Font not reported
|
||||
X http://code.google.com/p/processing/issues/detail?id=442
|
||||
X convert tabs to spaces when pasting text
|
||||
X http://code.google.com/p/processing/issues/detail?id=69
|
||||
|
||||
fixed earlier
|
||||
X Export reports "Could not copy source file" (even though it works)
|
||||
X http://code.google.com/p/processing/issues/detail?id=638
|
||||
X Preferences window not visible on taskbar
|
||||
X http://code.google.com/p/processing/issues/detail?id=63
|
||||
X paste value into color picker tool does not update box-slider
|
||||
X http://code.google.com/p/processing/issues/detail?id=68
|
||||
X don't see this one having a problem on OS X 10.7
|
||||
|
||||
displays
|
||||
X ability to select monitor via preferences panel
|
||||
@@ -44,6 +51,11 @@ _ multiple sketch windows.. having a windows menu?
|
||||
_ examples button on toolbar? open / recent / sketchbook?
|
||||
_ add "recent files" list to open menu?
|
||||
o http://dev.processing.org/bugs/show_bug.cgi?id=1335
|
||||
_ Closing the last window doesn't cause PDE to save its position/contents/etc
|
||||
_ (when the pref for close last window = quit is set)
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=835
|
||||
_ not remembering window size/placement preferences
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=837
|
||||
|
||||
_ changing number of screens between run causes things to show up off-screen
|
||||
_ so when running, check to make sure that things are out of the area
|
||||
@@ -538,12 +550,6 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=1225
|
||||
_ fix regex documentation
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=1202
|
||||
|
||||
_ Closing the last window doesn't cause PDE to save its position/contents/etc
|
||||
_ (when the pref for close last window = quit is set)
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=835
|
||||
_ not remembering window size/placement preferences
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=837
|
||||
|
||||
_ make better version of the windows launcher for debugging
|
||||
|
||||
_ after deleting a tab code still get's preprocessed, pde file is not forgotten
|
||||
@@ -1086,8 +1092,6 @@ _ add auto-save to the editor
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=739
|
||||
_ dragging title bar while sketch running causes strange selection behavior
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=504
|
||||
_ convert tabs to spaces when pasting text
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=506
|
||||
_ unchecking 'use external editor' sketch should not set modified
|
||||
_ dangerous if a version that hasn't been re-loaded has possibility
|
||||
_ to overwrite. i.e. make a change and save in external editor,
|
||||
@@ -1584,6 +1588,8 @@ _ or at least a boolean for the whole folder?
|
||||
|
||||
WISH LIST
|
||||
|
||||
_ Replace current editor with more advanced version
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1032
|
||||
_ Resurrect the Eclipse plug-in project
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1031
|
||||
|
||||
|
||||
Reference in New Issue
Block a user