home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Smartkeys / completeBrace.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  1.1 KB  |  46 lines

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: completeBrace~inserts a closing bracket and places 
  6. the caret on the next line. Defined for all file types. 
  7. Typing <code>{<tab></code> results in:
  8. <code> 
  9. {
  10. <caret>
  11. }
  12. </code>
  13. @EndTool: 
  14. @Summary: completeBrace~inserts a closing brace 
  15. */
  16.  
  17. function DoCommand()
  18. {
  19.     var path = File.getToolsPath() + "\\Smartkeys\\completeBrace.script";
  20.     Application.registerSmartKeyHandler("*", "{\t", path, 
  21.         "Complete: {<tab> with {<new line><new line>}");
  22. }
  23.  
  24. function OnEvent(editor,lineBuffer)
  25. {
  26.     var selection = editor.getSelection();
  27.     editor.insert(selection.startLineIndex, selection.startCharIndex, 
  28.         "\n\n}");
  29.     
  30.     var currentIndentLevel = editor.getIndentLevel(selection.startLineIndex);
  31.     editor.setIndentLevel(selection.startLineIndex + 1, 
  32.         currentIndentLevel + 1);
  33.     editor.setIndentLevel(selection.startLineIndex + 2, 
  34.         currentIndentLevel);
  35.     
  36.     editor.select(selection.startLineIndex + 1, 32000, 
  37.         selection.startLineIndex + 1, 32000);
  38.     
  39.     editor.setActive("Complete Brace");
  40.     return true;
  41. }
  42.  
  43. !!/Script
  44.  
  45.  
  46.