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?
It copies to the pasteboard the text selected in the current document window. It supports multiple selections and rectangular selections.

The [cut] subcommand

This subcommand cuts and sends to the pasteboard the currently selected text. The complete syntax is:
    text cut ?-w win?
It cuts the text selected in the current document window (if it is not in read-only mode) and sends a copy to the pasteboard. It supports multiple selections and rectangular selections.

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?
It inserts at the current position the text contained in the pasteboard (if any). It supports multiple selections and rectangular selections.

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?
It 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 2017-03-11 13:50:41