Module: ATSPI::Accessible::Text::Editable

Included in:
ATSPI::Accessible::Text
Defined in:
lib/atspi/accessible/text/editable.rb

Overview

Wraps libatspi’s editable_text interface.

Attributes & States collapse

Actions collapse

Instance Method Details

#copy(from: 0, to: length) ⇒ true, false

Copies its content in the given range into the clipboard. Will succeed only if it’s editable.

Parameters:

  • from (responds to #to_i) (defaults to: 0)

    the start offset of the range

  • to (responds to #to_i) (defaults to: length)

    the end offset of the range

Returns:

  • (true, false)

    indicating success

See Also:



59
60
61
# File 'lib/atspi/accessible/text/editable.rb', line 59

def copy(from: 0, to: length)
  editable? and @native.copy_text(from.to_i, to.to_i)
end

#cut(from: 0, to: length) ⇒ true, false

Cuts its content in the given range and puts it into the clipboard. Will succeed only if it’s editable.

Parameters:

  • from (responds to #to_i) (defaults to: 0)

    the start offset of the range

  • to (responds to #to_i) (defaults to: length)

    the end offset of the range

Returns:

  • (true, false)

    indicating success

See Also:



72
73
74
# File 'lib/atspi/accessible/text/editable.rb', line 72

def cut(from: 0, to: length)
  editable? and @native.cut_text(from.to_i, to.to_i)
end

#delete(from: 0, to: length) ⇒ true, false

Deletes its content in the given range. Will succeed only if it’s editable.

Parameters:

  • from (responds to #to_i) (defaults to: 0)

    the start offset of the range

  • to (responds to #to_i) (defaults to: length)

    the end offset of the range

Returns:

  • (true, false)

    indicating success

See Also:



85
86
87
# File 'lib/atspi/accessible/text/editable.rb', line 85

def delete(from: 0, to: length)
  editable? and @native.delete_text(from.to_i, to.to_i)
end

#editable?true, false

Checks if it is editable.

Returns:

  • (true, false)

See Also:



10
11
12
# File 'lib/atspi/accessible/text/editable.rb', line 10

def editable?
  not @native.editable_text_iface.nil?
end

#insert(text, at: caret) ⇒ true, false

Inserts a string at the given offset. Will succeed only if it’s editable.

Parameters:

  • text (respond to #to_s)

    the text to insert

  • at (responds to #to_i) (defaults to: caret)

    the offset to insert the string at

Returns:

  • (true, false)

    indicating success

See Also:



34
35
36
# File 'lib/atspi/accessible/text/editable.rb', line 34

def insert(text, at: caret)
  editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)
end

#paste(at: caret) ⇒ true, false

Pastes the string in the clipboard at the given offset. Will succeed only if it’s editable.

Parameters:

  • at (responds to #to_i) (defaults to: caret)

    the offset to insert the string at

Returns:

  • (true, false)

    indicating success

See Also:



46
47
48
# File 'lib/atspi/accessible/text/editable.rb', line 46

def paste(at: caret)
  editable? and @native.paste_text(at.to_i)
end

#set_to(text) ⇒ true, false

Replaces its content with the given one. Will succeed only if it’s editable.

Parameters:

  • text (respond to #to_s)

    the new text

Returns:

  • (true, false)

    indicating success



22
23
24
# File 'lib/atspi/accessible/text/editable.rb', line 22

def set_to(text)
  delete && insert(text.to_s)
end