class Gtk::TextView

Overview

A widget that displays the contents of a Gtk::TextBuffer.

An example Gtk::Textview

You may wish to begin by reading the conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.

CSS nodes

textview.view
├── border.top
├── border.left
├── text
│ ╰── [selection]
├── border.right
├── border.bottom
╰── [window.popup]

Gtk::TextView has a main css node with name textview and style class .view, and subnodes for each of the border windows, and the main text area, with names border and text, respectively. The border nodes each get one of the style classes .left, .right, .top or .bottom.

A node representing the selection will appear below the text node.

If a context menu is opened, the window node will appear as a subnode of the main node.

Accessibility

Gtk::TextView uses the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role.

Included Modules

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/text_view.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::Scrollable

border : Gtk::Border border, hadjustment : Gtk::Adjustment? hadjustment, hadjustment=(hadjustment : Gtk::Adjustment?) : Nil hadjustment=, hscroll_policy : Gtk::ScrollablePolicy hscroll_policy, hscroll_policy=(policy : Gtk::ScrollablePolicy) : Nil hscroll_policy=, to_unsafe to_unsafe, vadjustment : Gtk::Adjustment? vadjustment, vadjustment=(vadjustment : Gtk::Adjustment?) : Nil vadjustment=, vscroll_policy : Gtk::ScrollablePolicy vscroll_policy, vscroll_policy=(policy : Gtk::ScrollablePolicy) : Nil vscroll_policy=

Class methods inherited from module Gtk::Scrollable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _?) : Bool activate_action, activate_default : Nil activate_default, add_controller(controller : Gtk::EventController) : Nil add_controller, add_css_class(css_class : String) : Nil add_css_class, add_mnemonic_label(label : Gtk::Widget) : Nil add_mnemonic_label, add_tick_callback(callback : Gtk::TickCallback) : UInt32 add_tick_callback, allocate(width : Int32, height : Int32, baseline : Int32, transform : Gsk::Transform?) : Nil allocate, allocated_baseline : Int32 allocated_baseline, allocated_height : Int32 allocated_height, allocated_width : Int32 allocated_width, allocation : Gdk::Rectangle allocation, ancestor(widget_type : UInt64) : Gtk::Widget? ancestor, can_focus : Bool can_focus, can_focus=(can_focus : Bool) : Nil can_focus=, can_focus? : Bool can_focus?, can_target : Bool can_target, can_target=(can_target : Bool) : Nil can_target=, can_target? : Bool can_target?, child_focus(direction : Gtk::DirectionType) : Bool child_focus, child_visible : Bool child_visible, child_visible=(child_visible : Bool) : Nil child_visible=, clipboard : Gdk::Clipboard clipboard, compute_bounds(target : Gtk::Widget) : Graphene::Rect compute_bounds, compute_expand(orientation : Gtk::Orientation) : Bool compute_expand, compute_point(target : Gtk::Widget, point : Graphene::Point) : Graphene::Point compute_point, compute_transform(target : Gtk::Widget) : Graphene::Matrix compute_transform, contains(x : Float64, y : Float64) : Bool contains, create_pango_context : Pango::Context create_pango_context, create_pango_layout(text : String?) : Pango::Layout create_pango_layout, css_classes : Enumerable(String) css_classes, css_classes=(classes : Enumerable(String)) : Nil css_classes=, css_name : String css_name, css_name=(value : String) : String css_name=, cursor : Gdk::Cursor? cursor, cursor=(cursor : Gdk::Cursor?) : Nil cursor=, cursor_from_name=(name : String?) : Nil cursor_from_name=, destroy_signal destroy_signal, direction : Gtk::TextDirection direction, direction=(dir : Gtk::TextDirection) : Nil direction=, direction_changed_signal direction_changed_signal, display : Gdk::Display display, dispose_template(widget_type : UInt64) : Nil dispose_template, drag_check_threshold(start_x : Int32, start_y : Int32, current_x : Int32, current_y : Int32) : Bool drag_check_threshold, error_bell : Nil error_bell, first_child : Gtk::Widget? first_child, focus_child : Gtk::Widget? focus_child, focus_child=(child : Gtk::Widget?) : Nil focus_child=, focus_on_click : Bool focus_on_click, focus_on_click=(focus_on_click : Bool) : Nil focus_on_click=, focus_on_click? : Bool focus_on_click?, focusable : Bool focusable, focusable=(focusable : Bool) : Nil focusable=, focusable? : Bool focusable?, font_map : Pango::FontMap? font_map, font_map=(font_map : Pango::FontMap?) : Nil font_map=, font_options : Cairo::FontOptions? font_options, font_options=(options : Cairo::FontOptions?) : Nil font_options=, frame_clock : Gdk::FrameClock? frame_clock, grab_focus : Bool grab_focus, halign : Gtk::Align halign, halign=(align : Gtk::Align) : Nil halign=, has_css_class(css_class : String) : Bool has_css_class, has_default : Bool has_default, has_default? : Bool has_default?, has_focus : Bool has_focus, has_focus? : Bool has_focus?, has_tooltip : Bool has_tooltip, has_tooltip=(has_tooltip : Bool) : Nil has_tooltip=, has_tooltip? : Bool has_tooltip?, has_visible_focus : Bool has_visible_focus, height : Int32 height, height_request : Int32 height_request, height_request=(value : Int32) : Int32 height_request=, hexpand : Bool hexpand, hexpand=(expand : Bool) : Nil hexpand=, hexpand? : Bool hexpand?, hexpand_set : Bool hexpand_set, hexpand_set=(set : Bool) : Nil hexpand_set=, hexpand_set? : Bool hexpand_set?, hide : Nil hide, hide_signal hide_signal, in_destruction : Bool in_destruction, init_template : Nil init_template, insert_action_group(name : String, group : Gio::ActionGroup?) : Nil insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget?) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget?) : Nil insert_before, is_ancestor(ancestor : Gtk::Widget) : Bool is_ancestor, is_drawable : Bool is_drawable, is_focus : Bool is_focus, is_sensitive : Bool is_sensitive, is_visible : Bool is_visible, keynav_failed(direction : Gtk::DirectionType) : Bool keynav_failed, keynav_failed_signal keynav_failed_signal, last_child : Gtk::Widget? last_child, layout_manager : Gtk::LayoutManager? layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager?) : Nil layout_manager=, list_mnemonic_labels : GLib::List list_mnemonic_labels, map : Nil map, map_signal map_signal, mapped : Bool mapped, margin_bottom : Int32 margin_bottom, margin_bottom=(margin : Int32) : Nil margin_bottom=, margin_end : Int32 margin_end, margin_end=(margin : Int32) : Nil margin_end=, margin_start : Int32 margin_start, margin_start=(margin : Int32) : Nil margin_start=, margin_top : Int32 margin_top, margin_top=(margin : Int32) : Nil margin_top=, measure(orientation : Gtk::Orientation, for_size : Int32) : Nil measure, mnemonic_activate(group_cycling : Bool) : Bool mnemonic_activate, mnemonic_activate_signal mnemonic_activate_signal, move_focus_signal move_focus_signal, name : String name, name=(name : String) : Nil name=, native : Gtk::Native? native, next_sibling : Gtk::Widget? next_sibling, observe_children : Gio::ListModel observe_children, observe_controllers : Gio::ListModel observe_controllers, opacity : Float64 opacity, opacity=(opacity : Float64) : Nil opacity=, overflow : Gtk::Overflow overflow, overflow=(overflow : Gtk::Overflow) : Nil overflow=, pango_context : Pango::Context pango_context, parent : Gtk::Widget? parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget? pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget? prev_sibling, primary_clipboard : Gdk::Clipboard primary_clipboard, query_tooltip_signal query_tooltip_signal, queue_allocate : Nil queue_allocate, queue_draw : Nil queue_draw, queue_resize : Nil queue_resize, realize : Nil realize, realize_signal realize_signal, realized : Bool realized, receives_default : Bool receives_default, receives_default=(receives_default : Bool) : Nil receives_default=, receives_default? : Bool receives_default?, remove_controller(controller : Gtk::EventController) : Nil remove_controller, remove_css_class(css_class : String) : Nil remove_css_class, remove_mnemonic_label(label : Gtk::Widget) : Nil remove_mnemonic_label, remove_tick_callback(id : UInt32) : Nil remove_tick_callback, request_mode : Gtk::SizeRequestMode request_mode, root : Gtk::Root? root, scale_factor : Int32 scale_factor, sensitive : Bool sensitive, sensitive=(sensitive : Bool) : Nil sensitive=, sensitive? : Bool sensitive?, set_size_request(width : Int32, height : Int32) : Nil set_size_request, set_state_flags(flags : Gtk::StateFlags, clear : Bool) : Nil set_state_flags, settings : Gtk::Settings settings, should_layout : Bool should_layout, show : Nil show, show_signal show_signal, size(orientation : Gtk::Orientation) : Int32 size, size_allocate(allocation : Gdk::Rectangle, baseline : Int32) : Nil size_allocate, size_request : Nil size_request, snapshot_child(child : Gtk::Widget, snapshot : Gtk::Snapshot) : Nil snapshot_child, state_flags : Gtk::StateFlags state_flags, state_flags_changed_signal state_flags_changed_signal, style_context : Gtk::StyleContext style_context, tooltip_markup : String? tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(markup : String?) : Nil
tooltip_markup=
, tooltip_text : String? tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(text : String?) : Nil
tooltip_text=
, translate_coordinates(dest_widget : Gtk::Widget, src_x : Float64, src_y : Float64) : Bool translate_coordinates, trigger_tooltip_query : Nil trigger_tooltip_query, unmap : Nil unmap, unmap_signal unmap_signal, unparent : Nil unparent, unrealize : Nil unrealize, unrealize_signal unrealize_signal, unset_state_flags(flags : Gtk::StateFlags) : Nil unset_state_flags, valign : Gtk::Align valign, valign=(align : Gtk::Align) : Nil valign=, vexpand : Bool vexpand, vexpand=(expand : Bool) : Nil vexpand=, vexpand? : Bool vexpand?, vexpand_set : Bool vexpand_set, vexpand_set=(set : Bool) : Nil vexpand_set=, vexpand_set? : Bool vexpand_set?, visible : Bool visible, visible=(visible : Bool) : Nil visible=, visible? : Bool visible?, width : Int32 width, width_request : Int32 width_request, width_request=(value : Int32) : Int32 width_request=

Constructor methods inherited from class Gtk::Widget

new
new(*, accessible_role : Gtk::AccessibleRole? = nil, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, layout_manager : Gtk::LayoutManager? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, sensitive : Bool? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, width_request : Int32? = nil)
new

Class methods inherited from class Gtk::Widget

default_direction : Gtk::TextDirection default_direction, default_direction=(dir : Gtk::TextDirection) : Nil default_direction=, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

Constructor methods inherited from class GObject::InitiallyUnowned

new new

Class methods inherited from class GObject::InitiallyUnowned

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new : self #

Creates a new Gtk::TextView.

If you don’t call Gtk::TextView#buffer= before using the text view, an empty default buffer will be created for you. Get the buffer with Gtk::TextView#buffer. If you want to specify your own buffer, consider Gtk::TextView#new_with_buffer.


def self.new(*, accepts_tab : Bool? = nil, accessible_role : Gtk::AccessibleRole? = nil, bottom_margin : Int32? = nil, buffer : Gtk::TextBuffer? = nil, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, cursor_visible : Bool? = nil, editable : Bool? = nil, extra_menu : Gio::MenuModel? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, hadjustment : Gtk::Adjustment? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, hscroll_policy : Gtk::ScrollablePolicy? = nil, im_module : String? = nil, indent : Int32? = nil, input_hints : Gtk::InputHints? = nil, input_purpose : Gtk::InputPurpose? = nil, justification : Gtk::Justification? = nil, layout_manager : Gtk::LayoutManager? = nil, left_margin : Int32? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, monospace : Bool? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, overwrite : Bool? = nil, parent : Gtk::Widget? = nil, pixels_above_lines : Int32? = nil, pixels_below_lines : Int32? = nil, pixels_inside_wrap : Int32? = nil, receives_default : Bool? = nil, right_margin : Int32? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, sensitive : Bool? = nil, tabs : Pango::TabArray? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, top_margin : Int32? = nil, vadjustment : Gtk::Adjustment? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, vscroll_policy : Gtk::ScrollablePolicy? = nil, width_request : Int32? = nil, wrap_mode : Gtk::WrapMode? = nil) #

def self.new_with_buffer(buffer : Gtk::TextBuffer) : self #

Creates a new Gtk::TextView widget displaying the buffer @buffer.

One buffer can be shared among many widgets. @buffer may be nil to create a default buffer, in which case this function is equivalent to Gtk::TextView.new. The text view adds its own reference count to the buffer; it does not take over an existing reference.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def accepts_tab : Bool #

Returns whether pressing the Tab key inserts a tab characters.

See Gtk::TextView#accepts_tab=.


def accepts_tab=(accepts_tab : Bool) : Nil #

Sets the behavior of the text widget when the Tab key is pressed.

If @accepts_tab is true, a tab character is inserted. If @accepts_tab is false the keyboard focus is moved to the next widget in the focus chain.


def accepts_tab? : Bool #

def add_child_at_anchor(child : Gtk::Widget, anchor : Gtk::TextChildAnchor) : Nil #

Adds a child widget in the text buffer, at the given @anchor.


def add_overlay(child : Gtk::Widget, xpos : Int32, ypos : Int32) : Nil #

Adds @child at a fixed coordinate in the Gtk::TextView's text window.

The @xpos and @ypos must be in buffer coordinates (see Gtk::TextView#iter_location to convert to buffer coordinates).

@child will scroll with the text view.

If instead you want a widget that will not move with the Gtk::TextView contents see Gtk::Overlay.


def backspace_signal #

def backward_display_line(iter : Gtk::TextIter) : Bool #

Moves the given @iter backward by one display (wrapped) line.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.


def backward_display_line_start(iter : Gtk::TextIter) : Bool #

Moves the given @iter backward to the next display line start.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.


def bottom_margin : Int32 #

Gets the bottom margin for text in the @text_view.


def bottom_margin=(bottom_margin : Int32) : Nil #

Sets the bottom margin for text in @text_view.

Note that this function is confusingly named. In CSS terms, the value set here is padding.


def buffer : Gtk::TextBuffer #

Returns the Gtk::TextBuffer being displayed by this text view.

The reference count on the buffer is not incremented; the caller of this function won’t own a new reference.


def buffer=(buffer : Gtk::TextBuffer?) : Nil #

Sets @buffer as the buffer being displayed by @text_view.

The previous buffer displayed by the text view is unreferenced, and a reference is added to @buffer. If you owned a reference to @buffer before passing it to this function, you must remove that reference yourself; Gtk::TextView will not “adopt” it.


def buffer_to_window_coords(win : Gtk::TextWindowType, buffer_x : Int32, buffer_y : Int32) : Nil #

Converts buffer coordinates to window coordinates.


def copy_clipboard_signal #

def cursor_locations(iter : Gtk::TextIter?) : Gdk::Rectangle #

Determine the positions of the strong and weak cursors if the insertion point is at @iter.

The position of each cursor is stored as a zero-width rectangle. The strong cursor location is the location where characters of the directionality equal to the base direction of the paragraph are inserted. The weak cursor location is the location where characters of the directionality opposite to the base direction of the paragraph are inserted.

If @iter is nil, the actual cursor position is used.

Note that if @iter happens to be the actual cursor position, and there is currently an IM preedit sequence being entered, the returned locations will be adjusted to account for the preedit cursor’s offset within the preedit sequence.

The rectangle position is in buffer coordinates; use Gtk::TextView#buffer_to_window_coords to convert these coordinates to coordinates for one of the windows in the text view.


def cursor_visible : Bool #

Find out whether the cursor should be displayed.


def cursor_visible=(setting : Bool) : Nil #

Toggles whether the insertion point should be displayed.

A buffer with no editable text probably shouldn’t have a visible cursor, so you may want to turn the cursor off.

Note that this property may be overridden by the [property@Gtk::Settings:gtk-keynav-use-caret] setting.


def cursor_visible? : Bool #

def cut_clipboard_signal #

def delete_from_cursor_signal #

def editable : Bool #

Returns the default editability of the Gtk::TextView.

Tags in the buffer may override this setting for some ranges of text.


def editable=(setting : Bool) : Nil #

Sets the default editability of the Gtk::TextView.

You can override this default setting with tags in the buffer, using the “editable” attribute of tags.


def editable? : Bool #

def extend_selection_signal #

def extra_menu : Gio::MenuModel #

Gets the menu model that gets added to the context menu or nil if none has been set.


def extra_menu=(model : Gio::MenuModel?) : Nil #

Sets a menu model to add when constructing the context menu for @text_view.

You can pass nil to remove a previously set extra menu.


def forward_display_line(iter : Gtk::TextIter) : Bool #

Moves the given @iter forward by one display (wrapped) line.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.


def forward_display_line_end(iter : Gtk::TextIter) : Bool #

Moves the given @iter forward to the next display line end.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.


def gutter(win : Gtk::TextWindowType) : Gtk::Widget? #

Gets a Gtk::Widget that has previously been set as gutter.

See Gtk::TextView#gutter=.

@win must be one of %GTK_TEXT_WINDOW_LEFT, %GTK_TEXT_WINDOW_RIGHT, %GTK_TEXT_WINDOW_TOP, or %GTK_TEXT_WINDOW_BOTTOM.


def im_context_filter_keypress(event : Gdk::Event) : Bool #

Allow the Gtk::TextView input method to internally handle key press and release events.

If this function returns true, then no further processing should be done for this key event. See Gtk::IMContext#filter_keypress.

Note that you are expected to call this function from your handler when overriding key event handling. This is needed in the case when you need to insert your own key handling between the input method and the default key event handling of the Gtk::TextView.

WARNING ⚠️ The following code is in c ⚠️

static gboolean
gtk_foo_bar_key_press_event (Gtk::Widget *widget,
                             Gdk::Event  *event)
{
  guint keyval;

  gdk_event_get_keyval ((Gdk::Event*)event, &keyval);

  if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
    {
      if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (widget), event))
        return TRUE;
    }

  // Do some stuff

  return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event);
}

def im_module : String #

def im_module=(value : String) : String #

def indent : Int32 #

Gets the default indentation of paragraphs in @text_view.

Tags in the view’s buffer may override the default. The indentation may be negative.


def indent=(indent : Int32) : Nil #

Sets the default indentation for paragraphs in @text_view.

Tags in the buffer may override the default.


def input_hints : Gtk::InputHints #

Gets the input-hints of the Gtk::TextView.


def input_hints=(hints : Gtk::InputHints) : Nil #

Sets the input-hints of the Gtk::TextView.

The input-hints allow input methods to fine-tune their behaviour.


def input_purpose : Gtk::InputPurpose #

Gets the input-purpose of the Gtk::TextView.


def input_purpose=(purpose : Gtk::InputPurpose) : Nil #

Sets the input-purpose of the Gtk::TextView.

The input-purpose can be used by on-screen keyboards and other input methods to adjust their behaviour.


def insert_at_cursor_signal #

def insert_emoji_signal #

def iter_at_location(x : Int32, y : Int32) : Gtk::TextIter #

Retrieves the iterator at buffer coordinates @x and @y.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with Gtk::TextView#window_to_buffer_coords.


def iter_at_position(x : Int32, y : Int32) : Gtk::TextIter #

Retrieves the iterator pointing to the character at buffer coordinates @x and @y.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with Gtk::TextView#window_to_buffer_coords.

Note that this is different from Gtk::TextView#iter_at_location, which returns cursor locations, i.e. positions between characters.


def iter_location(iter : Gtk::TextIter) : Gdk::Rectangle #

Gets a rectangle which roughly contains the character at @iter.

The rectangle position is in buffer coordinates; use Gtk::TextView#buffer_to_window_coords to convert these coordinates to coordinates for one of the windows in the text view.


def justification : Gtk::Justification #

Gets the default justification of paragraphs in @text_view.

Tags in the buffer may override the default.


def justification=(justification : Gtk::Justification) : Nil #

Sets the default justification of text in @text_view.

Tags in the view’s buffer may override the default.


def left_margin : Int32 #

Gets the default left margin size of paragraphs in the @text_view.

Tags in the buffer may override the default.


def left_margin=(left_margin : Int32) : Nil #

Sets the default left margin for text in @text_view.

Tags in the buffer may override the default.

Note that this function is confusingly named. In CSS terms, the value set here is padding.


def line_at_y(y : Int32, line_top : Int32) : Gtk::TextIter #

Gets the Gtk::TextIter at the start of the line containing the coordinate @y.

@y is in buffer coordinates, convert from window coordinates with Gtk::TextView#window_to_buffer_coords. If non-nil, @line_top will be filled with the coordinate of the top edge of the line.


def line_yrange(iter : Gtk::TextIter, y : Int32, height : Int32) : Nil #

Gets the y coordinate of the top of the line containing @iter, and the height of the line.

The coordinate is a buffer coordinate; convert to window coordinates with Gtk::TextView#buffer_to_window_coords.


def ltr_context : Pango::Context #

Gets the Pango::Context that is used for rendering LTR directed text layouts.

The context may be replaced when CSS changes occur.


def monospace : Bool #

Gets whether the Gtk::TextView uses monospace styling.


def monospace=(monospace : Bool) : Nil #

Sets whether the Gtk::TextView should display text in monospace styling.


def monospace? : Bool #

def move_cursor_signal #

def move_mark_onscreen(mark : Gtk::TextMark) : Bool #

Moves a mark within the buffer so that it's located within the currently-visible text area.


def move_overlay(child : Gtk::Widget, xpos : Int32, ypos : Int32) : Nil #

Updates the position of a child.

See Gtk::TextView#add_overlay.


def move_viewport_signal #

def move_visually(iter : Gtk::TextIter, count : Int32) : Bool #

Move the iterator a given number of characters visually, treating it as the strong cursor position.

If @count is positive, then the new strong cursor position will be @count positions to the right of the old cursor position. If @count is negative then the new strong cursor position will be @count positions to the left of the old cursor position.

In the presence of bi-directional text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off of the end of a run.


def overwrite : Bool #

Returns whether the Gtk::TextView is in overwrite mode or not.


def overwrite=(overwrite : Bool) : Nil #

Changes the Gtk::TextView overwrite mode.


def overwrite? : Bool #

def paste_clipboard_signal #

def pixels_above_lines : Int32 #

Gets the default number of pixels to put above paragraphs.

Adding this function with Gtk::TextView#pixels_below_lines is equal to the line space between each paragraph.


def pixels_above_lines=(pixels_above_lines : Int32) : Nil #

Sets the default number of blank pixels above paragraphs in @text_view.

Tags in the buffer for @text_view may override the defaults.


def pixels_below_lines : Int32 #

Gets the default number of pixels to put below paragraphs.

The line space is the sum of the value returned by this function and the value returned by Gtk::TextView#pixels_above_lines.


def pixels_below_lines=(pixels_below_lines : Int32) : Nil #

Sets the default number of pixels of blank space to put below paragraphs in @text_view.

May be overridden by tags applied to @text_view’s buffer.


def pixels_inside_wrap : Int32 #

Gets the default number of pixels to put between wrapped lines inside a paragraph.


def pixels_inside_wrap=(pixels_inside_wrap : Int32) : Nil #

Sets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.

May be overridden by tags in @text_view’s buffer.


def place_cursor_onscreen : Bool #

Moves the cursor to the currently visible region of the buffer.


def preedit_changed_signal #

def remove(child : Gtk::Widget) : Nil #

Removes a child widget from @text_view.


def reset_cursor_blink : Nil #

Ensures that the cursor is shown.

This also resets the time that it will stay blinking (or visible, in case blinking is disabled).

This function should be called in response to user input (e.g. from derived classes that override the textview's event handlers).


def reset_im_context : Nil #

Reset the input method context of the text view if needed.

This can be necessary in the case where modifying the buffer would confuse on-going input method behavior.


def right_margin : Int32 #

Gets the default right margin for text in @text_view.

Tags in the buffer may override the default.


def right_margin=(right_margin : Int32) : Nil #

Sets the default right margin for text in the text view.

Tags in the buffer may override the default.

Note that this function is confusingly named. In CSS terms, the value set here is padding.


def rtl_context : Pango::Context #

Gets the Pango::Context that is used for rendering RTL directed text layouts.

The context may be replaced when CSS changes occur.


def scroll_mark_onscreen(mark : Gtk::TextMark) : Nil #

Scrolls @text_view the minimum distance such that @mark is contained within the visible area of the widget.


def scroll_to_iter(iter : Gtk::TextIter, within_margin : Float64, use_align : Bool, xalign : Float64, yalign : Float64) : Bool #

Scrolls @text_view so that @iter is on the screen in the position indicated by @xalign and @yalign.

An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If @use_align is false, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size @within_margin.

Note that this function uses the currently-computed height of the lines in the text buffer. Line heights are computed in an idle handler; so this function may not have the desired effect if it’s called before the height computations. To avoid oddness, consider using Gtk::TextView#scroll_to_mark which saves a point to be scrolled to after line validation.


def scroll_to_mark(mark : Gtk::TextMark, within_margin : Float64, use_align : Bool, xalign : Float64, yalign : Float64) : Nil #

Scrolls @text_view so that @mark is on the screen in the position indicated by @xalign and @yalign.

An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If @use_align is false, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size @within_margin.


def select_all_signal #

def set_anchor_signal #

def set_gutter(win : Gtk::TextWindowType, widget : Gtk::Widget?) : Nil #

Places @widget into the gutter specified by @win.

@win must be one of %GTK_TEXT_WINDOW_LEFT, %GTK_TEXT_WINDOW_RIGHT, %GTK_TEXT_WINDOW_TOP, or %GTK_TEXT_WINDOW_BOTTOM.


def starts_display_line(iter : Gtk::TextIter) : Bool #

Determines whether @iter is at the start of a display line.

See Gtk::TextView#forward_display_line for an explanation of display lines vs. paragraphs.


def tabs : Pango::TabArray? #

Gets the default tabs for @text_view.

Tags in the buffer may override the defaults. The returned array will be nil if “standard” (8-space) tabs are used. Free the return value with Pango::TabArray#free.


def tabs=(tabs : Pango::TabArray) : Nil #

Sets the default tab stops for paragraphs in @text_view.

Tags in the buffer may override the default.


def tabs=(value : Pango::TabArray?) : Pango::TabArray? #

def toggle_cursor_visible_signal #

def toggle_overwrite_signal #

def top_margin : Int32 #

Gets the top margin for text in the @text_view.


def top_margin=(top_margin : Int32) : Nil #

Sets the top margin for text in @text_view.

Note that this function is confusingly named. In CSS terms, the value set here is padding.


def visible_rect : Gdk::Rectangle #

Fills @visible_rect with the currently-visible region of the buffer, in buffer coordinates.

Convert to window coordinates with Gtk::TextView#buffer_to_window_coords.


def window_to_buffer_coords(win : Gtk::TextWindowType, window_x : Int32, window_y : Int32) : Nil #

Converts coordinates on the window identified by @win to buffer coordinates.


def wrap_mode : Gtk::WrapMode #

Gets the line wrapping for the view.


def wrap_mode=(wrap_mode : Gtk::WrapMode) : Nil #

Sets the line wrapping for the view.