SelectionSearch:
PROC [pattern: Pattern,
whichDir: SearchDir ← forwards, interrupt:
REF
BOOL ←
NIL,
startBoundaryNode, endBoundaryNode: Ref ←
NIL,
startBoundaryOffset:
INT ← 0, endBoundaryOffset:
INT ←
LAST[
INT]]
RETURNS [found:
BOOL];
startBoundaryNode and startBoundaryOffset limit how far backwards the search will go. if startBoundaryNode=NIL, search will go to start of document
endBoundaryNode and endBoundaryOffset limit how far forwards the search will go. if endBoundaryNode=NIL, search will go to end of document.
NodeSearch:
PROC [pattern: Pattern,
whichDir: SearchDir ← forwards,
startLoc, endLoc: Location, interrupt:
REF
BOOL ←
NIL,
startBoundaryNode, endBoundaryNode: Ref ←
NIL,
startBoundaryOffset:
INT ← 0, endBoundaryOffset:
INT ←
LAST[
INT]]
RETURNS [found:
BOOL, start, end: Location];
Similar to SelectionSearch, but doesn't change the selection. Just returns the result.
startLoc and endLoc args serve to determine where to start the search just as primary selection serves in LookForPattern. This can be used to search in documents that are not currently being displayed in a viewer.
SearchDir: TYPE = { forwards, backwards, anywhere };
CreateSimplePattern:
PROC [
target:
ROPE,
-- node from which to get the pattern
case:
BOOL ←
TRUE,
-- if true, match case
literal:
BOOL ←
FALSE,
-- if true, treat target literally rather than as a pattern
word:
BOOL ←
FALSE,
-- if true, match words only
addBounds:
BOOL ←
FALSE]
-- if true, add |'s to both ends of pattern
RETURNS [pattern: Pattern];
CreateGeneralPattern:
PROC [
target: Ref,
-- node from which to get the pattern
text:
BOOL ←
TRUE,
-- if true, match target text
looks:
BOOL ←
FALSE,
-- if true, match target looks
format:
BOOL ←
FALSE,
-- if true, match target format
style:
BOOL ←
FALSE,
-- if true, match target style
comment:
BOOL ←
FALSE,
-- if true, match target comment property
case:
BOOL ←
TRUE,
-- if true, match case
literal:
BOOL ←
FALSE,
-- if true, treat target literally rather than as a pattern
word:
BOOL ←
FALSE,
-- if true, match words only
subset:
BOOL ←
TRUE,
-- if true, use subset for looks test, else use equality
addBounds:
BOOL ←
FALSE]
-- if true, add |'s to both ends of pattern
RETURNS [pattern: Pattern];
CreateSimplePattern and CreateGeneralPattern can result in MalformedPattern being raised.
MalformedPattern: ERROR [ec: PatternErrorCode];
PatternErrorCode:
TYPE = {
toobig, -- pattern too long
endquote, -- pattern ends with '
endtilda, -- pattern ends with ~
boundary, -- pattern has | inside rather than at beginning or end
missingNameEnd, -- pattern has < without matching >
unmatchedNameEnd, -- pattern has > without previous <
other -- other unspecified error in pattern
};
Pattern: TYPE = REF PatternRec;
PatternRec:
TYPE =
RECORD [
finder: Finder,
text: BOOL,
looks: BOOL,
looksExact: BOOL,
word: BOOL,
commentControl: CommentControl,
checkFormat: BOOL,
format: ROPE,
checkStyle: BOOL,
style: ROPE,
searchLooks: ROPE
];
Finder: TYPE = REF FinderRec;
CommentControl: TYPE = { includeComments, excludeComments, commentsOnly };