Class SearchAgent

Searches the content of a math editor for regions that match a target pattern described by a Clip.

Example: Find all occurrences of a selection

view.type("2x+x");
view.pressKey(micd.Keystroke.ShiftArrowLeft);
let pattern = micd.Clip.from(editor);
let agent = new micd.SearchAgent(editor, pattern);
agent.start();
while ((match = agent.find()) != null) {
    console.log(match);
}

Hierarchy

  • SearchAgent

Index

Constructors

Properties

Methods

Constructors

constructor

  • Creates a new search agent that will search the specified editor.

    Parameters

    • editor: Editor

      The editor that will be searched for pattern matches.

    • Optional pattern: Clip

      An optional pattern to search for.

    Returns SearchAgent

Properties

pattern

pattern: Clip

Gets or sets the pattern to search for. This can be set to null, in which case it will have no matches.

Methods

find

  • find(): string
  • Finds and returns the next match in the search.

    Returns string

    A range describing the next match, or null if there are no more matches.

start

  • Starts a new search. After calling this, the find method can be called repeatedly to iterate through all available matches.

    Parameters

    • Optional options: SearchOptions

      Options that modify search behaviour.

    Returns SearchAgent

    This agent.

This API is still under development and is subject to change. Copyright © Math I Can Do Solutions Incorporated and/or its licensors.