home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 270 cm19990226 - changed to add '//' at the indent level
- // @Modified build 272 cm19990301 - fixed case where the caret is not at the beginning of the line
-
- /**
- @Tool: slashSlashComment~comments a selection using the
- Java/JavaScript line comment style. To use select one or more lines
- and then run this script.
- @EndTool:
- @Summary: slashSlashComment~comments a selection
- */
-
- function DoCommand()
- {
- var editor = getActiveEditor();
- if (editor)
- {
- var range = editor.getSelection();
-
- // Clear selection
- editor.select(range.startLineIndex, range.startCharIndex,
- range.startLineIndex, range.startCharIndex);
-
- // Select at lease one line
- if (range.empty())
- {
- range.startCharIndex = 0;
- range.endCharIndex = 0;
- range.endLineIndex = range.startLineIndex + 1;
- }
-
- // Don't include the last line if no characters are selected on the line
- if (range.endCharIndex != 0)
- {
- range.endLineIndex += 1;
- }
-
- indentLevel = editor.getIndentLevel(range.startLineIndex);
-
- for (var i = range.startLineIndex; i < range.endLineIndex; i++)
- {
- var level = editor.getIndentLevel(i);
- if (i < indentLevel)
- {
- editor.setIndentLevel(i, indentLevel);
- }
- editor.insert(i, indentLevel, "//");
- }
-
- range.startCharIndex = 0;
- range.endCharIndex = 0;
-
- editor.select(range);
- editor.setActive();
- }
- }
-
- !!/Script
-