The [text] command.

Introduction

The text command lets you interact programmatically with the text buffer of a document window.

Synopsis

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

The [bounds] subcommand

This subcommand returns the bounding rectangle enclosing the specified range of characters. The complete syntax is:
    text bounds ?-w win? start end
If the window specified by the -w option is split, it applies to the current pane. The returned rectangle is expressed in text view coordinates (the text origin is the top left corner of the text view). It is suitable for use with the -rect option of the [popover] command.

The [check] subcommand

This subcommand forces a default text checking on the entire document. The complete syntax is:
    text check ?-w win?
Depending on the features which have been enabled on the document (like link detection, spelling correction, grammar checking, etc.), the document is entirely checked.

The [copy] subcommand

This subcommand copies in the pasteboard the currently selected text. The complete syntax is:
    text copy ?-w win? ?-all?
The command copies to the pasteboard the text selected in the current document window. In case of multiple selection, the option -all lets copy all the selected chunks of text, otherwise only the first one is copied.

The [cut] subcommand

This subcommand cuts and sends to the pasteboard the currently selected text. The complete syntax is:
    text cut ?-w win? ?-all?
The command cuts the text selected in the current document window (if it is not in read-only mode) and sends a copy to the pasteboard. The option
-all has the same meaning as with the [text copy] command.

The [delete] subcommand

This subcommand deletes the chunk of text between the specified positions. The complete syntax is:
    text delete ?-w win? pos1 pos2

The [get] subcommand

This subcommand returns the chunk of text between the specified positions. The complete syntax is:
    text get ?-w win? pos1 pos2

The [insert] subcommand

This subcommand inserts text in the buffer. The complete syntax is:
    text insert ?-w win? ?-pos num? ?--? text…
The
-pos option indicates the position where the text is to be inserted. If it is not specified, the current position (of the current pane) is assumed. The -- argument indicates the end of the options. The remaining arguments are one or more strings which are concatenated before being inserted.

The [paste] subcommand

This subcommand inserts the contents of the pasteboard at the current position. The complete syntax is:
    text paste ?-w win? ?-all? ?-separator str?
The command inserts at the current position the text contained in the pasteboard (if any). In case there are multiple text items in the pasteboard, the option
-all lets paste all of them: they are, by default, separated by a single space, but a different separator string can be specified with the -separator option.
The command returns a two-elements list containing the start and end positions of the pasted text.

The [replace] subcommand

This subcommand replaces a chunk of text by another one. The complete syntax is:
    text replace ?-w win? pos1 pos2 string
The chunk of text contained between the specified positions is replaced by the string argument.

The [visible] subcommand

This subcommand makes a chunk of text visible. The complete syntax is:
    text visible ?-w win? pos1 ?pos2?
The command scrolls the text in the current pane in order to make the specified range visible. If the pos2 argument is not specified, it is equal to pos1.

Examples



Last updated 2016-11-14 20:30:35