Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions build/shared/tools/Mangler/src/Mangler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import processing.app.tools.Tool;



/**
* Example Tools menu entry.
*/
Expand Down Expand Up @@ -69,8 +70,9 @@ public void run() {


protected void mangleSelection() {
if (editor.isSelectionActive()) {
String selection = editor.getSelectedText();
//Check if there is selected text
if (editor.getCurrentTab().getSelectedText() != null) {
String selection = editor.getCurrentTab().getSelectedText();
char[] stuff = selection.toCharArray();
// Randomly swap a bunch of characters in the text
for (int i = 0; i < stuff.length / 10; i++) {
Expand All @@ -82,13 +84,12 @@ protected void mangleSelection() {
stuff[a] = selection.charAt(b);
stuff[b] = selection.charAt(a);
}
editor.startCompoundEdit();
editor.setSelectedText(new String(stuff));
editor.stopCompoundEdit();
editor.getCurrentTab().setSelectedText(new String(stuff));
editor.statusNotice("Now that feels better, doesn't it?");

} else {
editor.statusError("No selection, no dice.");
//When there is no selected text
editor.statusError("No selection, no dice.");
}
}
}