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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: demote~creates a parent - children relationship that can be opened and 
  6. closed. To use select two or more lines and then run this script. The first line 
  7. selected will become the parent and the remaining lines become 
  8. the children of the parent. If the control key is held down while running this 
  9. script the child lines will be folded. 
  10. @EndTool: 
  11. @Summary: demote~creates a range of lines that can be folded 
  12. */
  13.  
  14. function DoCommand()
  15. {
  16.   var editor = getActiveEditor();
  17.   if (editor)
  18.   {
  19.     var lines = editor.getLines();
  20.     var selection = editor.GetSelection();
  21.     var startLine = selection.startLineIndex;
  22.     var endLine = selection.endLineIndex;
  23.     if (selection.endCharIndex == 0)
  24.     {
  25.       endLine -= 1; // do not include the next line
  26.     }
  27.     var lineCount = endLine - startLine;
  28.     if (lineCount >= 2)
  29.     {
  30.       lines.demoteLines(startLine, endLine, isKeyDown("Control"));
  31.     }
  32.     lines.update("Demote Lines");
  33.   }
  34. }
  35.  
  36. !!/Script
  37.  
  38.