home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
-
- /**
- @Tool: swapCharacters~swaps the beginning and ending characters in a selection.
- @EndTool:
- @Summary: swapCharacters~swaps the beginning and ending characters
- */
-
- function DoCommand()
- {
- var editor = getActiveEditor();
- if (editor)
- {
- var selection = editor.getSelection();
-
- // Get the beginning and ending characters
- var beginChar = editor.copy(selection.startLineIndex, selection.startCharIndex,
- selection.startLineIndex, selection.startCharIndex + 1);
- var endChar = editor.copy(selection.endLineIndex, selection.endCharIndex - 1,
- selection.endLineIndex, selection.endCharIndex);
-
- if (beginChar && endChar)
- {
- // Swap
- editor.replace(beginChar, selection.endLineIndex, selection.endCharIndex - 1,
- selection.endLineIndex, selection.endCharIndex);
- editor.replace(endChar, selection.startLineIndex, selection.startCharIndex,
- selection.startLineIndex, selection.startCharIndex + 1);
- }
-
- editor.setActive("Swap Characters");
- }
- }
-
- !!/Script
-