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 | Nil hadjustment, hadjustment=(hadjustment : Gtk::Adjustment | Nil) : Nil hadjustment=, hscroll_policy : Gtk::ScrollablePolicy hscroll_policy, hscroll_policy=(policy : Gtk::ScrollablePolicy) : Nil hscroll_policy=, to_unsafe to_unsafe, vadjustment : Gtk::Adjustment | Nil vadjustment, vadjustment=(vadjustment : Gtk::Adjustment | Nil) : Nil vadjustment=, vscroll_policy : Gtk::ScrollablePolicy vscroll_policy, vscroll_policy=(policy : Gtk::ScrollablePolicy) : Nil vscroll_policy=

Constructor methods inherited from module Gtk::Scrollable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Scrollable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, 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

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

==(other : self) ==, action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _ | Nil) : 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) : 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 | Nil 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=, children : Iterator(Widget) children, 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 | Nil) : 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=(value : Nil) : Nil
css_name=
, css_name? : String | Nil css_name?, cursor : Gdk::Cursor | Nil cursor, cursor=(cursor : Gdk::Cursor | Nil) : Nil cursor=, cursor_from_name=(name : String | Nil) : 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, 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 | Nil first_child, focus_child : Gtk::Widget | Nil focus_child, focus_child=(child : Gtk::Widget | Nil) : 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 | Nil font_map, font_map=(font_map : Pango::FontMap | Nil) : Nil font_map=, font_options : Cairo::FontOptions | Nil font_options, font_options=(options : Cairo::FontOptions | Nil) : Nil font_options=, frame_clock : Gdk::FrameClock | Nil 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, hash(hasher) hash, 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) : Nil insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget | Nil) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget | Nil) : 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 | Nil last_child, layout_manager : Gtk::LayoutManager | Nil layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager | Nil) : 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=(value : Nil) : Nil
name=
, name? : String | Nil name?, native : Gtk::Native | Nil native, next_sibling : Gtk::Widget | Nil 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 | Nil parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget | Nil pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget | Nil 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 | Nil 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(x : Int32, y : Int32, width : Int32, height : Int32, baseline : Int32)
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, template_child(widget_type : UInt64, name : String) : GObject::Object
template_child(name : String) : GObject::Object
template_child
, tooltip_markup : String | Nil tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(value : Nil) : Nil
tooltip_markup=(markup : String | Nil) : Nil
tooltip_markup=
, tooltip_markup? : String | Nil tooltip_markup?, tooltip_text : String | Nil tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(value : Nil) : Nil
tooltip_text=(text : String | Nil) : Nil
tooltip_text=
, tooltip_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 = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, focus_on_click : Bool | Nil = nil, focusable : Bool | Nil = nil, halign : Gtk::Align | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, parent : Gtk::Widget | Nil = nil, receives_default : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, sensitive : Bool | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visible : Bool | Nil = nil, width_request : Int32 | Nil = 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

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, 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

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class GObject::InitiallyUnowned

==(other : self) ==, hash(hasher) hash

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

==(other : self) ==, 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) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, 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) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil 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, 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

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : 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

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

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.


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

[View source]
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.


[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def accepts_tab : Bool #

Returns whether pressing the Tab key inserts a tab characters.

See Gtk::TextView#accepts_tab=.


[View source]
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.


[View source]
def accepts_tab? : Bool #

[View source]
def add_child_at_anchor(child : Gtk::Widget, anchor : Gtk::TextChildAnchor) : Nil #

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


[View source]
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.


[View source]
def backspace_signal #

[View source]
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.


[View source]
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.


[View source]
def bottom_margin : Int32 #

Gets the bottom margin for text in the text_view.


[View source]
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.


[View source]
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.


[View source]
def buffer=(buffer : Gtk::TextBuffer | Nil) : 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.


[View source]
def buffer_to_window_coords(win : Gtk::TextWindowType, buffer_x : Int32, buffer_y : Int32) : Nil #

Converts buffer coordinates to window coordinates.


[View source]
def copy_clipboard_signal #

[View source]
def cursor_locations(iter : Gtk::TextIter | Nil) : 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.


[View source]
def cursor_visible : Bool #

Find out whether the cursor should be displayed.


[View source]
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.


[View source]
def cursor_visible? : Bool #

[View source]
def cut_clipboard_signal #

[View source]
def delete_from_cursor_signal #

[View source]
def editable : Bool #

Returns the default editability of the Gtk::TextView.

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


[View source]
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.


[View source]
def editable? : Bool #

[View source]
def extend_selection_signal #

[View source]
def extra_menu : Gio::MenuModel #

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


[View source]
def extra_menu=(model : Gio::MenuModel | Nil) : 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.


[View source]
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.


[View source]
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.


[View source]
def gutter(win : Gtk::TextWindowType) : Gtk::Widget | Nil #

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.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


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);
}

[View source]
def im_module : String #

[View source]
def im_module=(value : String) : String #

[View source]
def im_module=(value : Nil) : Nil #

Set #im_module property to nil.


[View source]
def im_module? : String | Nil #

Same as #im_module, but can return nil.


[View source]
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.


[View source]
def indent=(indent : Int32) : Nil #

Sets the default indentation for paragraphs in text_view.

Tags in the buffer may override the default.


[View source]
def input_hints : Gtk::InputHints #

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


[View source]
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.


[View source]
def input_purpose : Gtk::InputPurpose #

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


[View source]
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.


[View source]
def insert_at_cursor_signal #

[View source]
def insert_emoji_signal #

[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def justification : Gtk::Justification #

Gets the default justification of paragraphs in text_view.

Tags in the buffer may override the default.


[View source]
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.


[View source]
def left_margin : Int32 #

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

Tags in the buffer may override the default.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def monospace : Bool #

Gets whether the Gtk::TextView uses monospace styling.


[View source]
def monospace=(monospace : Bool) : Nil #

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


[View source]
def monospace? : Bool #

[View source]
def move_cursor_signal #

[View source]
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.


[View source]
def move_overlay(child : Gtk::Widget, xpos : Int32, ypos : Int32) : Nil #

Updates the position of a child.

See Gtk::TextView#add_overlay.


[View source]
def move_viewport_signal #

[View source]
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.


[View source]
def overwrite : Bool #

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


[View source]
def overwrite=(overwrite : Bool) : Nil #

Changes the Gtk::TextView overwrite mode.


[View source]
def overwrite? : Bool #

[View source]
def paste_clipboard_signal #

[View source]
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.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def pixels_inside_wrap : Int32 #

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


[View source]
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.


[View source]
def place_cursor_onscreen : Bool #

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


[View source]
def preedit_changed_signal #

[View source]
def remove(child : Gtk::Widget) : Nil #

Removes a child widget from text_view.


[View source]
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).


[View source]
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.


[View source]
def right_margin : Int32 #

Gets the default right margin for text in text_view.

Tags in the buffer may override the default.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def select_all_signal #

[View source]
def set_anchor_signal #

[View source]
def set_gutter(win : Gtk::TextWindowType, widget : Gtk::Widget | Nil) : 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.


[View source]
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.


[View source]
def tabs : Pango::TabArray | Nil #

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.


[View source]
def tabs=(tabs : Pango::TabArray) : Nil #

Sets the default tab stops for paragraphs in text_view.

Tags in the buffer may override the default.


[View source]
def tabs=(value : Pango::TabArray | Nil) : Pango::TabArray | Nil #

[View source]
def toggle_cursor_visible_signal #

[View source]
def toggle_overwrite_signal #

[View source]
def top_margin : Int32 #

Gets the top margin for text in the text_view.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def wrap_mode : Gtk::WrapMode #

Gets the line wrapping for the view.


[View source]
def wrap_mode=(wrap_mode : Gtk::WrapMode) : Nil #

Sets the line wrapping for the view.


[View source]