Class: ATSPI::Accessible::Text
- Inherits:
-
Object
- Object
- ATSPI::Accessible::Text
- Extended by:
- Forwardable
- Defined in:
- lib/atspi/accessible/text.rb,
lib/atspi/accessible/text/caret.rb,
lib/atspi/accessible/text/range.rb,
lib/atspi/accessible/text/offset.rb,
lib/atspi/accessible/text/editable.rb,
lib/atspi/accessible/text/character.rb,
lib/atspi/accessible/text/hyperlink.rb,
lib/atspi/accessible/text/hypertext.rb,
lib/atspi/accessible/text/selection.rb
Overview
Wraps libatspi’s text interface, editable_text interface and hypertext interface.
Defined Under Namespace
Modules: Editable, Hypertext Classes: Caret, Character, Hyperlink, Offset, Range, Selection
Attributes & States collapse
-
#caret ⇒ Caret
(also: #cursor)
Its caret/cursor.
-
#editable? ⇒ true, false
included
from Editable
Checks if it is editable.
-
#hyperlinks ⇒ Array<Hyperlink>
(also: #links)
included
from Hypertext
Its hyperlinks.
-
#hypertext? ⇒ true, false
included
from Hypertext
Checks if it is a hypertext.
-
#length ⇒ Integer
Its length.
-
#selections ⇒ Array<Selection>
Its selected text ranges.
Geometric Access collapse
-
#offset_at(x, y, relative_to:) ⇒ Offset
The offset at the given point.
-
#ranges_in(x, y, width, height, relative_to:, clip_x: :none, clip_y: :none) ⇒ Array<Range>
The ranges inside the given rectangle.
Actions collapse
-
#copy(from: 0, to: length) ⇒ true, false
included
from Editable
Copies its content in the given range into the clipboard.
-
#cut(from: 0, to: length) ⇒ true, false
included
from Editable
Cuts its content in the given range and puts it into the clipboard.
-
#delete(from: 0, to: length) ⇒ true, false
included
from Editable
Deletes its content in the given range.
-
#deselect ⇒ true, false
Deselects the entire text.
-
#insert(text, at: caret) ⇒ true, false
included
from Editable
Inserts a string at the given offset.
-
#paste(at: caret) ⇒ true, false
included
from Editable
Pastes the string in the clipboard at the given offset.
-
#select(from: 0, to: length) ⇒ true, false
Selects the text between the given offsets.
-
#set_to(text) ⇒ true, false
included
from Editable
Replaces its content with the given one.
Representations collapse
-
#inspect ⇒ String
Itself as an inspectable string.
-
#to_s(from: 0, to: length) ⇒ String
Its string representation.
Instance Method Details
#caret ⇒ Caret Also known as: cursor
Returns its caret/cursor.
23 24 25 |
# File 'lib/atspi/accessible/text.rb', line 23 def caret Caret.new(@native) end |
#copy(from: 0, to: length) ⇒ true, false Originally defined in module Editable
Copies its content in the given range into the clipboard. Will succeed only if it’s editable.
#cut(from: 0, to: length) ⇒ true, false Originally defined in module Editable
Cuts its content in the given range and puts it into the clipboard. Will succeed only if it’s editable.
#delete(from: 0, to: length) ⇒ true, false Originally defined in module Editable
Deletes its content in the given range. Will succeed only if it’s editable.
#deselect ⇒ true, false
Deselects the entire text.
To deselect a single selection do it via ATSPI::Accessible::Text::Selection#deselect.
97 98 99 |
# File 'lib/atspi/accessible/text.rb', line 97 def deselect selections.reverse.map(&:deselect).all? end |
#editable? ⇒ true, false Originally defined in module Editable
Checks if it is editable.
#hyperlinks ⇒ Array<Hyperlink> Also known as: links Originally defined in module Hypertext
Returns its hyperlinks. Will be an empty array if it is not a hypertext.
#hypertext? ⇒ true, false Originally defined in module Hypertext
Checks if it is a hypertext.
#insert(text, at: caret) ⇒ true, false Originally defined in module Editable
Inserts a string at the given offset. Will succeed only if it’s editable.
#inspect ⇒ String
Returns itself as an inspectable string.
114 115 116 117 |
# File 'lib/atspi/accessible/text.rb', line 114 def inspect text_s = to_s(from: 0, to: 20) << (length > 20 ? '…' : '') "#<#{self.class.name}:0x#{'%x14' % __id__} @to_s=#{text_s.inspect} @length=#{length}>" end |
#length ⇒ Integer
Returns its length.
18 19 20 |
# File 'lib/atspi/accessible/text.rb', line 18 def length @native.character_count end |
#offset_at(x, y, relative_to:) ⇒ Offset
Returns the offset at the given point.
50 51 52 |
# File 'lib/atspi/accessible/text.rb', line 50 def offset_at(x, y, relative_to:) Offset.new(@native, @native.offset_at_point(x, y, relative_to)) end |
#paste(at: caret) ⇒ true, false Originally defined in module Editable
Pastes the string in the clipboard at the given offset. Will succeed only if it’s editable.
#ranges_in(x, y, width, height, relative_to:, clip_x: :none, clip_y: :none) ⇒ Array<Range>
Returns the ranges inside the given rectangle.
72 73 74 75 76 |
# File 'lib/atspi/accessible/text.rb', line 72 def ranges_in(x, y, width, height, relative_to:, clip_x: :none, clip_y: :none) @native.bounded_ranges(x, y, width, height, relative_to, clip_x, clip_y).map do |range| Range.new(@native, range) end end |
#select(from: 0, to: length) ⇒ true, false
Selects the text between the given offsets.
88 89 90 |
# File 'lib/atspi/accessible/text.rb', line 88 def select(from: 0, to: length) @native.add_selection(from.to_i, to.to_i) end |
#selections ⇒ Array<Selection>
Returns its selected text ranges.
30 31 32 33 34 |
# File 'lib/atspi/accessible/text.rb', line 30 def selections @native.n_selections.times.map do |idx| Selection.new(@native, idx) end end |
#set_to(text) ⇒ true, false Originally defined in module Editable
Replaces its content with the given one. Will succeed only if it’s editable.
#to_s(from: 0, to: length) ⇒ String
Returns its string representation.
109 110 111 |
# File 'lib/atspi/accessible/text.rb', line 109 def to_s(from: 0, to: length) @native.text(from.to_i, to.to_i) end |