text

Name

text -- A widget for multi line formatted text editing.

Synopsis

text [-option value...]

Screenshot

Options

-scrollbar

type: always, never, automatic (default: automatic)

When to show scrollbars. If the value is a list of two elements, the first value is for the horizontal scrollbar and the second value for the vertical scrollbar.

-pixelsInsideWrap

type: integer

Pixels between lines after wrap.

-pixelsBelowLines

type: integer

Pixels below lines.

-pixelsAboveLines

type: integer

Pixels above lines.

-editable

type: boolean (default: 1)

Whether the text in the widget is editable.

-wrapMode

type: ONEOF none, char, word

Wrap mode used for the rendering of the cells.

-justify

type: ONEOF left, right, center, fill

Justification of the lines in one cell.

-leftMargin

type: integer

-rightMargin

type: integer

-indent

type: integer

-cursorVisible

type: boolean (default: 1)

Whether the cursor is visible.

-hasFocus

type: 1

This sets the focus to the widget. To unset the focus it must be set to another widet.

-sensitive

type: boolean (default: 1)

Whether or not the item is sensitve to user input.

-visible

type: boolean (default: 1)

Whether or not the item is visible.

-name

type: string

Name of the widget, can be used to set options in an rc file.

-onShowHelp

type: string (default: "")

Tcl command which is executed in the global scope if the "show-help" signal is recieved, which is normally the case if the user presses F1 or Ctrl-F1. Before evaluation the following percent strings are substituated TABLE %% | % %w | widget name %h | help type: either "whatsThis" or "tooltip" TABLE

-tooltip

type: string

Message that appear next to this widget when the mouse pointer is held over it for a short amount of time.

Description

A text widget is used to input and show formatted text. Some text commands need an index as parameter. An index can be either a list of the row and the column, both starting at 0, for example "1 7", or a keyword like end, cursor, selectionStart, selectionEnd with an (without space) appended character offset, for example "selectionStart+3".

Commands

id delete

Deletes the widget and the associated tcl command.

id configure [-option value...]

Configures the widget. Option may have any of the values accepted on creation of the widget.

id erase startIndex ?endIndex?

Removes all text between startIndex and endIndex. endIndex defaults to end.

id select startIndex ?endIndex?

Select the text between startIndex and endIndex. endIndex defaults to end.

id get startIndex ?endIndex?

Returns the text between startIndex and endIndex. endIndex defaults to end.

id cut

Copies all text to the clipboard and removes it from the widget.

id copy

Copies all text to the clipboard.

id paste

Pastes text from the clipboard at the current cursor position.

id getLength

Returns the number of characters in the widget.

id getCursor

Returns the position position of the cursor as list of its row and column.

id setCursor index

Sets the cursor to position index.

id insert index text ?-tags taglist?

Inserts and position indext the text text. If taglist is given the text is taged with each element of the list.

id tag create tagName [-option value...]

Creates a tag with name tagName and configures it dependent of the options given. The options are the same as with tag configure.

id scrollToPosition index [-option value...]

Scrolls the widget so that the specified index is visible.

Options

-align

type: a list of the horizontal and vertical alignment or one of topLeft, top, topRight, left, center, right, bottomLeft, bottom, or bottomRight

Specifies where the index shall be shown.

-margin

type: 0 lt float lt 1

Specifies the margin.

id tag configure tagName [-option value...]

Configures the existing tag tagName.

Options

-background

type: color

Background color of the text.

-foreground

type: color

Foreground color of the text.

-font

type: FONT

Font of the text.

-fontFamily

Font family of the text.

-fontStyle

type: ONEOF normal, oblique, italic (default: normal)

Font style of the text.

-fontVariant

type: ONEOF normal, smallCaps (default: normal)

Font variant of the text.

-fontWeight

type: ONEOF ultralight, light, normal, bold, ultrabold, heavy (default: normal)

Font weight of the text.

-fontRise

type: integer (default: 0)

How many pixels the text should be risen.

-fontStretch

type: ONEOF ultraCondensed, extraCondensed, condensed, semiCondensed, normal, semiExpanded, expanded, extraExpanded, ultraExpanded (default: normal)

Font stretch of the text.

-fontSize

type: integer

Font size of the text.

-fontScale

type: float ORONEOF xx-small, x-small, small, medium, large, x-large, xx-large (default: normal)

Font scale used.

-wrapMode

type: ONEOF none, char, word

Wrap mode used.

-justify

type: ONEOF left, right, center, fill

Justification of the lines.

-strikethrough

type: boolean (default: 0)

Whether the text is struck through.

-underline

type: ONEOF none, single, double, low (default: none)

How the text should be underlined.

-editable

type: boolean (default: 0)

Whether the text can be edited.

-invisible

type: boolean (default: 0)

Whether the text is invisible.

Example

set text [gnocl::text]
$text tag create bold -fontWeight bold -foreground blue
$text insert end "This is "
$text insert end "Gnocl" -tags bold
$text insert end "!"
gnocl::window -title "Text" -child $text

results in

See also

entry, label, GtkTextBuffer, GtkTextView