home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
-
-
- //
- // Text Utilities
- //
- //
-
-
- function DoCommand()
- {
- alert("The textUtilities script only contains funtions\nthat can be used by other scripts");
- }
-
- // Use this method to insert text that
- // needs to be reformatted
- function InsertStringAndReformat(editor, string)
- {
- if (editor)
- {
- var selection = editor.getSelection();
-
- var range = editor.insert(selection.endLineIndex, selection.endCharIndex, string);
- for (var i = range.startLineIndex; i <= range.endLineIndex; i++)
- {
- var indent = editor.getSmartIndentLevel(i);
- editor.setIndentLevel(i, indent);
- }
- return selection.endLineIndex;
- }
- return 0;
- }
-
- // Use this method to insert preformated text that
- // only needs to be tabbed to the correct indent level
- function InsertString(editor, string)
- {
- if (editor)
- {
- var selection = editor.getSelection();
-
- var indent = editor.getIndentLevel(selection.startLineIndex);
- var range = editor.insert(selection.endLineIndex, selection.endCharIndex, string);
- IndentRange(editor, indent, range);
- return selection.endLineIndex;
- }
- return 0;
- }
-
- // Indent a range of text by count tabs
- function IndentRange(editor, count, range)
- {
- if (count < 1)
- {
- return;
- }
-
- var tabs = "";
- for (var j = 1; j <= count; j++)
- {
- tabs += "\t";
- }
-
- for (var i = range.startLineIndex + 1; i <= range.endLineIndex; i++)
- {
- editor.insert(i, 0, tabs);
- }
- }
-
-
- !!/Script
-
-