The [findBar] command.

Introduction

The findBar command lets you interact with the Find Bar available for each pane of a document window.
The document window can be specified by the -w option. If this option is not present, the command applies to the currently active document window.
When the document window is split into several panes, all the subcommands apply to the current pane.

Synopsis

The formal syntax of the [findBar] command is:
findBar subcommand ?options?
The possible subcommands are described below. Depending on the subcommand, some options may be specified.

The [hide] subcommand

This subcommand hides the Find Bar. The complete syntax is:
    findBar hide ?-w win? 

The [configure] subcommand

This subcommand lets you get or set the values of some parameters. The complete syntax can take two forms:
    findBar configure option
    findBar configure option ?value? ?option value...?
The first form returns the value of an option. The second form lets you modify the value of one or several options. This command does not implement the -w option because it affects the Find Bar globally: by design, all the find bars use the same settings.
The possible options are:
-match
the -match option is an integer value indicating the type of search anchor an action should use to find a match. The value is an integer between 0 and 2 with the following meaning:
DescriptionValue
Contains0
Starts With1
Full Word2
-nocase
the -nocase option is a boolean value indicating if the search should be case insensitive or not.
-replaceString
the value of the -replaceString option corresponds to the string in the replace field.
-searchString
the value of the -searchString option corresponds to the string in the search field.
The matching and casing options are displayed in the popup menu represented by a magnifying glass at the left of the search field.
Note: the system uses a dedicated pasteboard (known as the Find pasteboard) to hold information about the current state of the Find Bar and in particular the search string. In order to manipulate programmatically the search string, you could also use the [pasteboard read] and [pasteboard write] commands with a -name find option.

The [perform] subcommand

This subcommand lets some actions be performed. The complete syntax is:
    findBar perform ?-w win? action
The action argument is an integer representing the action to perform. The possible values are:
DescriptionCode
Show Find Interface1
Next Match2
Previous Match3
Replace All4
Replace5
Replace and Find6
Set Search String7
Replace All In Selection8
Select All Matches9
Select All in Selection10
Hide Find Interface11
Show Replace Interface12
Hide Replace Interface13
The Set Search String action mentionned in the previous table installs in the search field the string that is currently selected in the text. In order to install another search string programmatically, use the [findBar configure] command.

The [show] subcommand

This subcommand displays the Find Bar. The complete syntax is:
    findBar show ?-w win? 

The [visible] subcommand

This subcommand tells whether the Find Bar is visible in the current pane of the specified window. The complete syntax is:
    findBar visible ?-w win? 
If the -w option is not specified and if there is no opened document window, the command just returns 0.

Examples

Here are some examples of use of the findBar command. Open the Tcl Shell (with ⌘Y) and enter the following commands, one by one:
«» findBar show
«» findBar visible
1
«» findBar configure -searchString foobar -nocase 1
«» findBar configure -searchString
foobar
«» findBar perform 2  ; # Find next match
«» findBar perform 3  ; # Find previous match
«» selection set 0 5  ; # Select the text between positions 0:5
«» findBar perform 7  ; # Install the selection in the find bar
«» findBar perform 12 ; # Display the Replace field
«» findBar hide


Last updated 2019-10-17 13:29:46