### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: docs/content-docs/reference/Gtk3/TextView.md
### ----------------------------------------------------
### -- Chunk 2 of 2
_input_hints ( --> GtkInputHints  )

[[gtk_] text_view_] set_monospace
---------------------------------

Sets the *monospace* property, which indicates that the text view should use monospace fonts.

Since: 3.16

    method gtk_text_view_set_monospace ( Int $monospace )

  * Int $monospace; `1` to request monospace styling

[[gtk_] text_view_] get_monospace
---------------------------------

Gets the value of the *monospace* property.

Return: `1` if monospace fonts are desired

Since: 3.16

    method gtk_text_view_get_monospace ( --> Int  )

Signals
=======

There are two ways to connect to a signal. The first option you have is to use `register-signal()` from **Gnome::GObject::Object**. The second option is to use `g_signal_connect_object()` directly from **Gnome::GObject::Signal**.

First method
------------

The positional arguments of the signal handler are all obligatory as well as their types. The named attributes `:$widget` and user data are optional.

    # handler method
    method mouse-event ( N-GdkEvent $event, :$widget ) { ... }

    # connect a signal on window object
    my Gnome::Gtk3::Window $w .= new( ... );
    $w.register-signal( self, 'mouse-event', 'button-press-event');

Second method
-------------

    my Gnome::Gtk3::Window $w .= new( ... );
    my Callable $handler = sub (
      N-GObject $native, N-GdkEvent $event, OpaquePointer $data
    ) {
      ...
    }

    $w.connect-object( 'button-press-event', $handler);

Also here, the types of positional arguments in the signal handler are important. This is because both methods `register-signal()` and `g_signal_connect_object()` are using the signatures of the handler routines to setup the native call interface.

Supported signals
-----------------

### move-cursor

Applications should not connect to it, but may emit it with `g_signal_emit_by_name()` if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifer does not. There are too many key combinations to list them all here. - Arrow keys move by individual characters/lines - Ctrl-arrow key combinations move by words/paragraphs - Home/End keys move to the ends of the buffer - PageUp/PageDown keys move vertically by pages - Ctrl-PageUp/PageDown keys move horizontally by pages

    method handler (
      Unknown type GTK_TYPE_MOVEMENT_STEP $step,
      Int $count,
      Int $extend_selection,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

  * $step; the granularity of the move, as a **Gnome::Gtk3::MovementStep**

  * $count; the number of *step* units to move

  * $extend_selection; `1` if the move should extend the selection

### move-viewport

The *move-viewport* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which can be bound to key combinations to allow the user to move the viewport, i.e. change what part of the text view is visible in a containing scrolled window.

There are no default bindings for this signal.

    method handler (
      Unknown type GTK_TYPE_SCROLL_STEP $step,
      Int $count,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

  * $step; the granularity of the movement, as a **Gnome::Gtk3::ScrollStep**

  * $count; the number of *step* units to move

### set-anchor

The *set-anchor* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted when the user initiates setting the "anchor" mark. The "anchor" mark gets placed at the same position as the "insert" mark.

This signal has no default bindings.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### insert-at-cursor

The *insert-at-cursor* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted when the user initiates the insertion of a fixed string at the cursor.

This signal has no default bindings.

    method handler (
      Str $string,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

  * $string; the string to insert

### delete-from-cursor

The *delete-from-cursor* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted when the user initiates a text deletion.

If the *type* is `GTK_DELETE_CHARS`, GTK+ deletes the selection if there is one, otherwise it deletes the requested number of characters.

The default bindings for this signal are Delete for deleting a character, Ctrl-Delete for deleting a word and Ctrl-Backspace for deleting a word backwords.

    method handler (
      Unknown type GTK_TYPE_DELETE_TYPE $type,
      Int $count,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

  * $type; the granularity of the deletion, as a **Gnome::Gtk3::DeleteType**

  * $count; the number of *type* units to delete

### backspace

The *backspace* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted when the user asks for it.

The default bindings for this signal are Backspace and Shift-Backspace.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### cut-clipboard

The *cut-clipboard* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted to cut the selection to the clipboard.

The default bindings for this signal are Ctrl-x and Shift-Delete.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### copy-clipboard

The *copy-clipboard* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted to copy the selection to the clipboard.

The default bindings for this signal are Ctrl-c and Ctrl-Insert.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### paste-clipboard

The *paste-clipboard* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted to paste the contents of the clipboard into the text view.

The default bindings for this signal are Ctrl-v and Shift-Insert.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### toggle-overwrite

The *toggle-overwrite* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted to toggle the overwrite mode of the text view.

The default bindings for this signal is Insert.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### populate-popup

The *populate-popup* signal gets emitted before showing the context menu of the text view.

If you need to add items to the context menu, connect to this signal and append your items to the *popup*, which will be a **Gnome::Gtk3::Menu** in this case.

If *populate-all* is `1`, this signal will also be emitted to populate touch popups. In this case, *popup* will be a different container, e.g. a **Gnome::Gtk3::Toolbar**.

The signal handler should not make assumptions about the type of *widget*, but check whether *popup* is a **Gnome::Gtk3::Menu** or **Gnome::Gtk3::Toolbar** or another kind of container.

    method handler (
      N-GObject $popup,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; The text view on which the signal is emitted

  * $popup; the container that is being populated

### select-all

The *select-all* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted to select or unselect the complete contents of the text view.

The default bindings for this signal are Ctrl-a and Ctrl-/ for selecting and Shift-Ctrl-a and Ctrl-\ for unselecting.

    method handler (
      Int $select,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

  * $select; `1` to select, `0` to unselect

### toggle-cursor-visible

The *toggle-cursor-visible* signal is a [keybinding signal][**Gnome::Gtk3::BindingSignal**] which gets emitted to toggle the *cursor-visible* property.

The default binding for this signal is F7.

    method handler (
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

### preedit-changed

If an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.

This signal is only emitted if the text at the given position is actually editable.

Since: 2.20

    method handler (
      Str $preedit,
      Int :$_handler_id,
      Gnome::GObject::Object :_widget($text_view),
      *%user-options
    );

  * $text_view; the object which received the signal

  * $preedit; the current preedit string

Properties
==========

An example of using a string type property of a **Gnome::Gtk3::Label** object. This is just showing how to set/read a property, not that it is the best way to do it. This is because a) The class initialization often provides some options to set some of the properties and b) the classes provide many methods to modify just those properties. In the case below one can use **new(:label('my text label'))** or **gtk_label_set_text('my text label')**.

    my Gnome::Gtk3::Label $label .= new;
    my Gnome::GObject::Value $gv .= new(:init(G_TYPE_STRING));
    $label.g-object-get-property( 'label', $gv);
    $gv.g-value-set-string('my text label');

Supported properties
--------------------

### Pixels Above Lines

The **Gnome::GObject::Value** type of property *pixels-above-lines* is `G_TYPE_INT`.

### Pixels Below Lines

The **Gnome::GObject::Value** type of property *pixels-below-lines* is `G_TYPE_INT`.

### Pixels Inside Wrap

The **Gnome::GObject::Value** type of property *pixels-inside-wrap* is `G_TYPE_INT`.

### Editable

Whether the text can be modified by the user Default value: True

The **Gnome::GObject::Value** type of property *editable* is `G_TYPE_BOOLEAN`.

### Wrap Mode

Whether to wrap lines never, at word boundaries_COMMA_ or at character boundaries Default value: False

The **Gnome::GObject::Value** type of property *wrap-mode* is `G_TYPE_ENUM`.

### Justification

Left, right_COMMA_ or center justification Default value: False

The **Gnome::GObject::Value** type of property *justification* is `G_TYPE_ENUM`.

### Left Margin

The default left margin for text in the text view. Tags in the buffer may override the default. Note that this property is confusingly named. In CSS terms, the value set here is padding, and it is applied in addition to the padding from the theme. Don't confuse this property with *margin-left*.

The **Gnome::GObject::Value** type of property *left-margin* is `G_TYPE_INT`.

### Right Margin

The default right margin for text in the text view. Tags in the buffer may override the default. Note that this property is confusingly named. In CSS terms, the value set here is padding, and it is applied in addition to the padding from the theme. Don't confuse this property with *margin-right*.

The **Gnome::GObject::Value** type of property *right-margin* is `G_TYPE_INT`.

### Top Margin

The top margin for text in the text view. Note that this property is confusingly named. In CSS terms, the value set here is padding, and it is applied in addition to the padding from the theme. Don't confuse this property with *margin-top*. Since: 3.18

The **Gnome::GObject::Value** type of property *top-margin* is `G_TYPE_INT`.

### Bottom Margin

The bottom margin for text in the text view. Note that this property is confusingly named. In CSS terms, the value set here is padding, and it is applied in addition to the padding from the theme. Don't confuse this property with *margin-bottom*. Since: 3.18

The **Gnome::GObject::Value** type of property *bottom-margin* is `G_TYPE_INT`.

### Indent

The **Gnome::GObject::Value** type of property *indent* is `G_TYPE_INT`.

### Tabs

The **Gnome::GObject::Value** type of property *tabs* is `G_TYPE_BOXED`.

### Cursor Visible

If the insertion cursor is shown Default value: True

The **Gnome::GObject::Value** type of property *cursor-visible* is `G_TYPE_BOOLEAN`.

### Buffer

The buffer which is displayed Widget type: GTK_TYPE_TEXT_BUFFER

The **Gnome::GObject::Value** type of property *buffer* is `G_TYPE_OBJECT`.

### Overwrite mode

Whether entered text overwrites existing contents Default value: False

The **Gnome::GObject::Value** type of property *overwrite* is `G_TYPE_BOOLEAN`.

### Accepts tab

Whether Tab will result in a tab character being entered Default value: True

The **Gnome::GObject::Value** type of property *accepts-tab* is `G_TYPE_BOOLEAN`.

### IM module

Which IM (input method) module should be used for this text_view. See **Gnome::Gtk3::IMContext**. Setting this to a non-`Any` value overrides the system-wide IM module setting. See the **Gnome::Gtk3::Settings** *gtk-im-module* property. Since: 2.16

The **Gnome::GObject::Value** type of property *im-module* is `G_TYPE_STRING`.

### Purpose

The purpose of this text field. This property can be used by on-screen keyboards and other input methods to adjust their behaviour. Since: 3.6 Widget type: GTK_TYPE_INPUT_PURPOSE

The **Gnome::GObject::Value** type of property *input-purpose* is `G_TYPE_ENUM`.

### hints

Additional hints (beyond *input-purpose*) that allow input methods to fine-tune their behaviour. Since: 3.6

The **Gnome::GObject::Value** type of property *input-hints* is `G_TYPE_FLAGS`.

### Populate all

If *populate-all* is `1`, the *populate-popup* signal is also emitted for touch popups. Since: 3.8

The **Gnome::GObject::Value** type of property *populate-all* is `G_TYPE_BOOLEAN`.

### Monospace

If `1`, set the `GTK_STYLE_CLASS_MONOSPACE` style class on the text view to indicate that a monospace font is desired. Since: 3.16

The **Gnome::GObject::Value** type of property *monospace* is `G_TYPE_BOOLEAN`.



