32
32
import processing .app .tools .Tool ;
33
33
34
34
35
+
35
36
/**
36
37
* Example Tools menu entry.
37
38
*/
@@ -69,8 +70,9 @@ public void run() {
69
70
70
71
71
72
protected void mangleSelection () {
72
- if (editor .isSelectionActive ()) {
73
- String selection = editor .getSelectedText ();
73
+ //Check if there is selected text
74
+ if (editor .getCurrentTab ().getSelectedText () != null ) {
75
+ String selection = editor .getCurrentTab ().getSelectedText ();
74
76
char [] stuff = selection .toCharArray ();
75
77
// Randomly swap a bunch of characters in the text
76
78
for (int i = 0 ; i < stuff .length / 10 ; i ++) {
@@ -82,13 +84,12 @@ protected void mangleSelection() {
82
84
stuff [a ] = selection .charAt (b );
83
85
stuff [b ] = selection .charAt (a );
84
86
}
85
- editor .startCompoundEdit ();
86
- editor .setSelectedText (new String (stuff ));
87
- editor .stopCompoundEdit ();
87
+ editor .getCurrentTab ().setSelectedText (new String (stuff ));
88
88
editor .statusNotice ("Now that feels better, doesn't it?" );
89
89
90
90
} else {
91
- editor .statusError ("No selection, no dice." );
91
+ //When there is no selected text
92
+ editor .statusError ("No selection, no dice." );
92
93
}
93
94
}
94
95
}
0 commit comments