home *** CD-ROM | disk | FTP | other *** search
- !!Script
-
- /**
- @Tool: hilightDelimiter~selects the matching opening delimiter.
- Defined for all file types. To activate type a closing delimiter
- or place the caret after a closing delimiter and type a tab.
- @EndTool:
- @Summary: hilightDelimiter~hilight matching opening delimitor
- */
-
- function DoCommand()
- {
- var path = File.getToolsPath() + "\\Smartkeys\\hilightDelimiter.script";
- Application.registerSmartKeyHandler("*", "}\t", path,
- "Hilight: }<tab> with hilight of matching delimiter");
- Application.registerSmartKeyHandler("*", "]\t", path,
- "Hilight: ]<tab> with hilight of matching delimiter");
- Application.registerSmartKeyHandler("*", ")\t", path,
- "Hilight: )<tab> with hilight of matching delimiter");
- }
-
- function OnEvent(editor,lineBuffer)
- {
- var range = editor.getSelection();
- var origIndex=range.startLineIndex;
-
- range.startCharIndex -= 1;
-
- var delimiterRange = editor.findMatchingDelimiter(range);
- if (delimiterRange)
- {
- editor.select(delimiterRange);
-
- // Scroll if needed
- var lineIndex = -1;
- if (!editor.lineVisible(delimiterRange.startLineIndex))
- {
- lineIndex = editor.getScrollPosition();
- editor.scrollTo(delimiterRange.startLineIndex - 5);
- wait(500, true);
- }
- else
- {
- wait(100, true);
- }
-
- // we scroll first, and the re-position cursor, otherwise
- // the cursor will be out of place
- if (lineIndex > -1)
- {
- // scroll back
- editor.scrollTo(lineIndex);
- }
- // so that we are not highlighting the original close brace
- range.startCharIndex += 1;
- // essentially unhighlight here
- editor.select(range);
- }
- return true; // Ignore the tab
- }
-
-
- !!/Script
-
-