home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
-
- /**
- @Tool: completeFor~completes a for structure and places
- the caret between the opening and closing parenthesis of the for statement.
- Defined for all file types.
- Typing <code>for<tab></code> results in:
- <pre>
- for(<caret>;;)
- {
- }
- </pre>
- @EndTool:
- @Summary: completeFor~complets a for statement
- */
-
- function DoCommand()
- {
- var path = File.getToolsPath() + "\\Smartkeys\\completeFor.script";
- Application.registerSmartKeyHandler(".*", "for\t", path,
- "Complete: for<tab> with for(;;){}");
- }
-
- function OnEvent(editor,lineBuffer)
- {
- var selection = editor.getSelection();
- editor.replace("(;;)", selection);
-
- var indentLevel = editor.getIndentLevel(selection.startLineIndex);
- var lineIndex = selection.startLineIndex;
-
- editor.insert(++lineIndex, 0, "{\n");
- editor.setIndentLevel(lineIndex, indentLevel);
-
- editor.insert(++lineIndex, 0, "}\n");
- editor.setIndentLevel(lineIndex, indentLevel);
-
- editor.select(selection.startLineIndex, selection.endCharIndex + 1,
- selection.startLineIndex, selection.endCharIndex + 1);
-
- editor.setActive("Complete for");
- return true;
- }
-
- !!/Script
-
-
-