Code:
- --- Came wiffling through the eclipsey wood ---
- /*
- * Menu: RPG > ToMixedCase
- * Kudos: Matt Tyler via Joe Pluta
- * License: EPL 1.0
- * DOM: http://download.eclipse.org/technology/das\
- h/update/org.eclipse.eclipsemonkey.lang.javascript
- */
-
- function main() {
- function popup(title, msg) {
- Packages.org.eclipse.jface.dialogs.MessageDia\
- log.openInformation(
- window.getShell(), title, msg
- );
- }
- String.prototype.toMixedCase = function()
- {
- function toUpper(sChar){ return sChar.toUpperC\
- ase(sChar); }
- return this.toLowerCase().replace(/\b([A-Za-z]\
- )/g,toUpper);
- }
-
- var editor = editors.activeEditor;
- // popup('The value of getId()',editor.Id);
- var range = editor.selectionRange;
- var offset = range.startingOffset;
- var offset2 = range.endingOffset;
- var result = editor.source.substring(offset, offs\
- et2).toMixedCase();
- editor.beginCompoundChange();
- editor.applyEdit(offset, range.endingOffset - off\
- set, result);
- editor.endCompoundChange();
- }
-
- --- And burbled as it ran! ---
-
|
|