home *** CD-ROM | disk | FTP | other *** search
- !!script
- // Copyright ⌐ 1997-2000 - Modelworks Software
-
- /**
- @Tool: findInOpenProject~finds a findWhat expression in the current project.
- @EndTool:
- @Summary: findInOpenProject~finds a findWhat expression in the current project
- */
-
- var gOutput = getOutput("Find In Files 1");
-
- function DoCommand()
- {
- var findParameters = getGlobal("FindParameters", null);
-
- var findData = chooseFindParameters("Find in open project", findParameters.findWhat,
- findParameters.caseSensitive, findParameters.wholeWord,
- findParameters.regularExpression, findParameters.searchDown);
-
- if (findData)
- {
- findParameters.findWhat = findData.key;
- findParameters.caseSensitive = findData.caseSensitive;
- findParameters.wholeWord = findData.wholeWord;
- findParameters.regularExpression = findData.regularExpression;
- findParameters.searchDown = findData.searchDown;
- findParameters.updateHistory();
-
- gOutput.clear();
- gOutput.writeLine("Searching for: " + findData.key);
-
- var count = 0;
- var project = getCurrentProject();
- if (project)
- {
- var list = project.getPackageList();
- if (list)
- {
- var position = list.getHeadPosition();
- while (position && position.valid)
- {
- var pkg = list.getNext(position);
- var filelist = pkg.getFileList(false);
- var index = filelist.getHeadPosition();
- while (index && index.valid)
- {
- var file = filelist.getNext(index);
- var editor = openEditor(file.path);
- if (editor)
- {
- count += FindInEditor(editor, findData);
- }
- }
- }
- }
- }
-
- gOutput.writeLine("Found " + count + " items");
- }
- }
-
- function FindInEditor(editor, findData)
- {
- var fileName = editor.path;
- var count = 0;
- var lineIndex = -1;
-
- if (findData.searchDown)
- {
- findData.startCharIndex = 0;
- findData.startLineIndex = 0;
- }
- else
- {
- findData.startLineIndex = editor.getLineCount() - 1;
- findData.startCharIndex = 32000;
- }
-
- editor.findNext(findData);
- while (findData && findData.found)
- {
- var range = findData.range;
-
- // Only print out one message per line
- if (lineIndex != range.startLineIndex)
- {
- lineIndex = range.startLineIndex;
- gOutput.writeMessage(fileName, lineIndex, editor.copy(lineIndex));
- count += 1;
- }
-
- editor.findNext(findData);
- }
-
- return count;
- }
-
- !!/script
-
-