atspi 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.yardopts +2 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +2 -0
- data/atspi.gemspec +23 -0
- data/bin/console +7 -0
- data/lib/atspi/accessible/action.rb +45 -0
- data/lib/atspi/accessible/children/selected.rb +32 -0
- data/lib/atspi/accessible/children.rb +72 -0
- data/lib/atspi/accessible/descendants/attribute_filter.rb +32 -0
- data/lib/atspi/accessible/descendants/interface_filter.rb +24 -0
- data/lib/atspi/accessible/descendants/name_filter.rb +18 -0
- data/lib/atspi/accessible/descendants/options.rb +49 -0
- data/lib/atspi/accessible/descendants/role_filter.rb +23 -0
- data/lib/atspi/accessible/descendants/state_filter.rb +23 -0
- data/lib/atspi/accessible/descendants.rb +278 -0
- data/lib/atspi/accessible/document.rb +26 -0
- data/lib/atspi/accessible/extents.rb +129 -0
- data/lib/atspi/accessible/hyperlink/anchor.rb +30 -0
- data/lib/atspi/accessible/hyperlink.rb +31 -0
- data/lib/atspi/accessible/image.rb +35 -0
- data/lib/atspi/accessible/selectable.rb +47 -0
- data/lib/atspi/accessible/table/cell/columns.rb +44 -0
- data/lib/atspi/accessible/table/cell/rows.rb +44 -0
- data/lib/atspi/accessible/table/cell.rb +18 -0
- data/lib/atspi/accessible/table/cells.rb +37 -0
- data/lib/atspi/accessible/table/column.rb +59 -0
- data/lib/atspi/accessible/table/columns/selected.rb +42 -0
- data/lib/atspi/accessible/table/columns.rb +34 -0
- data/lib/atspi/accessible/table/row.rb +59 -0
- data/lib/atspi/accessible/table/rows/selected.rb +42 -0
- data/lib/atspi/accessible/table/rows.rb +31 -0
- data/lib/atspi/accessible/table.rb +50 -0
- data/lib/atspi/accessible/text/caret.rb +31 -0
- data/lib/atspi/accessible/text/character.rb +45 -0
- data/lib/atspi/accessible/text/editable.rb +90 -0
- data/lib/atspi/accessible/text/hyperlink.rb +19 -0
- data/lib/atspi/accessible/text/hypertext.rb +29 -0
- data/lib/atspi/accessible/text/offset.rb +59 -0
- data/lib/atspi/accessible/text/range.rb +66 -0
- data/lib/atspi/accessible/text/selection.rb +48 -0
- data/lib/atspi/accessible/text.rb +120 -0
- data/lib/atspi/accessible/value.rb +47 -0
- data/lib/atspi/accessible.rb +267 -0
- data/lib/atspi/application.rb +46 -0
- data/lib/atspi/collection.rb +60 -0
- data/lib/atspi/desktop.rb +52 -0
- data/lib/atspi/extents.rb +28 -0
- data/lib/atspi/libatspi.rb +7 -0
- data/lib/atspi/requires.rb +76 -0
- data/lib/atspi/selectable_collection/selected.rb +23 -0
- data/lib/atspi/selectable_collection.rb +32 -0
- data/lib/atspi/state_set.rb +141 -0
- data/lib/atspi/version.rb +4 -0
- data/lib/atspi/window.rb +33 -0
- data/lib/atspi.rb +58 -0
- metadata +132 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Table
|
3
|
+
# Represents a cell in a {Table}. It is child accessible of its {Table}.
|
4
|
+
class Cell < Accessible
|
5
|
+
# @return [Rows] the rows it spans
|
6
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-row-column-extents-at-index atspi_table_get_row_column_extents_at_index
|
7
|
+
def rows
|
8
|
+
Rows.new(@native)
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Columns] the columns it spans
|
12
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-row-column-extents-at-index atspi_table_get_row_column_extents_at_index
|
13
|
+
def columns
|
14
|
+
Columns.new(@native)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class ATSPI::Accessible
|
2
|
+
class Table
|
3
|
+
# Represents all cells in a {Table}. Cells are also the children of their
|
4
|
+
# {Table}.
|
5
|
+
class Cells < Children
|
6
|
+
# @!group Enumerable interface
|
7
|
+
# @overload at(idx)
|
8
|
+
# @param (see Children#at)
|
9
|
+
#
|
10
|
+
# @overload at(row:, column:)
|
11
|
+
# @param (see #at_coords)
|
12
|
+
#
|
13
|
+
# @return [Cell] the cell at +idx+ or at (+row+,+column+)
|
14
|
+
#
|
15
|
+
# @see https://developer.gnome.org/libatspi/stable/AtspiAccessible.html#atspi-accessible-get-child-at-index atspi_accessible_get_child_at_index
|
16
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-accessible-at atspi_table_get_accessible_at
|
17
|
+
def at(idx = nil)
|
18
|
+
if idx.is_a? Numeric
|
19
|
+
Cell.new(@native.child_at_index(idx))
|
20
|
+
else
|
21
|
+
at_coords(idx)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param row [Integer]
|
26
|
+
# @param colum [Integer]
|
27
|
+
#
|
28
|
+
# @return [Cell] the cell at (+row+,+column+)
|
29
|
+
#
|
30
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-accessible-at atspi_table_get_accessible_at
|
31
|
+
def at_coords(row:, column:)
|
32
|
+
Cell.new(@native.accessible_at(row, column))
|
33
|
+
end
|
34
|
+
# @!endgroup
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class ATSPI::Accessible::Table
|
2
|
+
# Represents a column in a {Table}
|
3
|
+
class Column
|
4
|
+
# @api private
|
5
|
+
def initialize(native, index)
|
6
|
+
@native = native
|
7
|
+
@index = index
|
8
|
+
end
|
9
|
+
|
10
|
+
# @group State & Attributes
|
11
|
+
# @return [Integer] its index
|
12
|
+
attr_reader :index
|
13
|
+
|
14
|
+
# @return [Cell] its header
|
15
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-column-header atspi_table_get_column_header
|
16
|
+
def header
|
17
|
+
header = @native.column_header(@index)
|
18
|
+
Cell.new(header) if header
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String] its description
|
22
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-column-description atspi_table_get_column_description
|
23
|
+
def description
|
24
|
+
@native.column_description(@index)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Checks if it is selected
|
28
|
+
# @return [true,false]
|
29
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-is-column-selected atspi_table_is_column_selected
|
30
|
+
def selected?
|
31
|
+
@native.is_column_selected(@index)
|
32
|
+
end
|
33
|
+
# @endgroup
|
34
|
+
|
35
|
+
# @group Actions
|
36
|
+
# Selects its
|
37
|
+
# @return [true,false]
|
38
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-add-column-selection atspi_table_add_column_selection
|
39
|
+
def select
|
40
|
+
@native.add_column_selection(@index)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Deselects its
|
44
|
+
# @return [true,false]
|
45
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-remove-column-selection atspi_table_remove_column_selection
|
46
|
+
def deselect
|
47
|
+
@native.remove_column_selection(@index)
|
48
|
+
end
|
49
|
+
# @endgroup
|
50
|
+
|
51
|
+
# @group Representations
|
52
|
+
# @return [String] itself as an inspectable string
|
53
|
+
def inspect
|
54
|
+
"#<#{self.class.name}:0x#{'%x14' % __id__} @index=#{index} @selected?=#{selected?} " <<
|
55
|
+
"@description=#{description.inspect}>"
|
56
|
+
end
|
57
|
+
# @endgroup
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Table
|
3
|
+
# Represents all selected columns of a {Table}
|
4
|
+
class Columns::Selected
|
5
|
+
include SelectableCollection::Selected
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
INDEX_METHOD = :index
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
def initialize(native)
|
12
|
+
@native = native
|
13
|
+
end
|
14
|
+
|
15
|
+
# @!group Enumerable interface
|
16
|
+
# Iterates over all selected columns
|
17
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-selected-columns atspi_table_get_selected_columns
|
18
|
+
def each
|
19
|
+
@native.selected_columns.each do |idx|
|
20
|
+
yield at(idx)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param n [Integer] the index in the collection of selected columns and
|
25
|
+
# not the index in the collection of all the table's columns.
|
26
|
+
#
|
27
|
+
# @return [Column] the table's n'th selected column
|
28
|
+
def at(n)
|
29
|
+
super do |mapped_idx|
|
30
|
+
Column.new(@native, mapped_idx)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Integer] the number of selected columns
|
35
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-n-selected-columns atspi_table_get_n_selected_columns
|
36
|
+
def count
|
37
|
+
@native.n_selected_columns
|
38
|
+
end
|
39
|
+
# @!endgroup
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Table
|
3
|
+
# Represents all columns in a {Table}
|
4
|
+
class Columns
|
5
|
+
include SelectableCollection
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
INDEX_METHOD = :index
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
def initialize(native)
|
12
|
+
@native = native
|
13
|
+
end
|
14
|
+
|
15
|
+
# @!group Enumerable interface
|
16
|
+
# @param idx [Integer]
|
17
|
+
#
|
18
|
+
# @return [Column] the column at index +idx+
|
19
|
+
def at(idx)
|
20
|
+
super do |mapped_idx|
|
21
|
+
Column.new(@native, mapped_idx)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Integer] its number of columns
|
26
|
+
#
|
27
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-n-columns atspi_table_get_n_columns
|
28
|
+
def count
|
29
|
+
@native.n_columns
|
30
|
+
end
|
31
|
+
# @!endgroup
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class ATSPI::Accessible::Table
|
2
|
+
# Represents a row in a {Table}
|
3
|
+
class Row
|
4
|
+
# @api private
|
5
|
+
def initialize(native, index)
|
6
|
+
@native = native
|
7
|
+
@index = index
|
8
|
+
end
|
9
|
+
|
10
|
+
# @group State & Attributes
|
11
|
+
# @return [Integer] its index
|
12
|
+
attr_reader :index
|
13
|
+
|
14
|
+
# @return [Cell] its header
|
15
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-row-header atspi_table_get_row_header
|
16
|
+
def header
|
17
|
+
header = @native.row_header(@index)
|
18
|
+
Cell.new(header) if header
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String] its description
|
22
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-row-description atspi_table_get_row_description
|
23
|
+
def description
|
24
|
+
@native.row_description(@index)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Checks if it is selected
|
28
|
+
# @return [true,false]
|
29
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-is-row-selected atspi_table_is_row_selected
|
30
|
+
def selected?
|
31
|
+
@native.is_row_selected(@index)
|
32
|
+
end
|
33
|
+
# @endgroup
|
34
|
+
|
35
|
+
# @group Actions
|
36
|
+
# Selects its
|
37
|
+
# @return [true,false]
|
38
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-add-row-selection atspi_table_add_row_selection
|
39
|
+
def select
|
40
|
+
@native.add_row_selection(@index)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Deselects its
|
44
|
+
# @return [true,false]
|
45
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-remove-row-selection atspi_table_remove_row_selection
|
46
|
+
def deselect
|
47
|
+
@native.remove_row_selection(@index)
|
48
|
+
end
|
49
|
+
# @endgroup
|
50
|
+
|
51
|
+
# @group Representations
|
52
|
+
# @return [String] itself as an inspectable string
|
53
|
+
def inspect
|
54
|
+
"#<#{self.class.name}:0x#{'%x14' % __id__} @index=#{index} @selected?=#{selected?} " <<
|
55
|
+
"@description=#{description.inspect}>"
|
56
|
+
end
|
57
|
+
# @endgroup
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Table
|
3
|
+
# Represents all selected rows of a {Table}
|
4
|
+
class Rows::Selected
|
5
|
+
include SelectableCollection::Selected
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
INDEX_METHOD = :index
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
def initialize(native)
|
12
|
+
@native = native
|
13
|
+
end
|
14
|
+
|
15
|
+
# @!group Enumerable interface
|
16
|
+
# Iterates over all selected rows
|
17
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-selected-rows atspi_table_get_selected_rows
|
18
|
+
def each
|
19
|
+
@native.selected_rows.each do |idx|
|
20
|
+
yield at(idx)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param n [Integer] the index in the collection of selected rows and
|
25
|
+
# not the index in the collection of all the table's rows.
|
26
|
+
#
|
27
|
+
# @return [Row] the table's n'th selected row
|
28
|
+
def at(n)
|
29
|
+
super do |idx|
|
30
|
+
Row.new(@native, idx)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Integer] the number of selected rows
|
35
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-n-selected-rows atspi_table_get_n_selected_rows
|
36
|
+
def count
|
37
|
+
@native.n_selected_rows
|
38
|
+
end
|
39
|
+
# @!endgroup
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Table
|
3
|
+
# Represents all rows in a {Table}
|
4
|
+
class Rows
|
5
|
+
include SelectableCollection
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
def initialize(native)
|
9
|
+
@native = native
|
10
|
+
end
|
11
|
+
|
12
|
+
# @!group Enumerable interface
|
13
|
+
# @param idx [Integer]
|
14
|
+
#
|
15
|
+
# @return [Row] the row at index +idx+
|
16
|
+
def at(idx)
|
17
|
+
super do |mapped_idx|
|
18
|
+
Row.new(@native, mapped_idx)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Integer] its number of rows
|
23
|
+
#
|
24
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-n-rows atspi_table_get_n_rows
|
25
|
+
def count
|
26
|
+
@native.n_rows
|
27
|
+
end
|
28
|
+
# @!endgroup
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ATSPI
|
2
|
+
# Wraps libatspi's AtspiTable[https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html].
|
3
|
+
class Accessible::Table
|
4
|
+
# @api private
|
5
|
+
def initialize(native)
|
6
|
+
@native = native
|
7
|
+
end
|
8
|
+
|
9
|
+
# @group Attributes
|
10
|
+
# @return [Accessible,nil] its caption
|
11
|
+
#
|
12
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-caption atspi_table_get_caption
|
13
|
+
def caption
|
14
|
+
Accessible.new(@native.caption) if @native.caption
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Accessible,nil] its summary
|
18
|
+
#
|
19
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-table.html#atspi-table-get-summary atspi_table_get_summary
|
20
|
+
def summary
|
21
|
+
Accessible.new(@native.summary) if @native.caption
|
22
|
+
end
|
23
|
+
# @endgroup
|
24
|
+
|
25
|
+
# @group Parts
|
26
|
+
# @return [Rows] its rows
|
27
|
+
def rows
|
28
|
+
Rows.new(@native)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Columns] its columns
|
32
|
+
def columns
|
33
|
+
Columns.new(@native)
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Cells] its cells
|
37
|
+
def cells
|
38
|
+
Cells.new(@native)
|
39
|
+
end
|
40
|
+
# @endgroup
|
41
|
+
|
42
|
+
# @group Representations
|
43
|
+
# @return [String] itself as an inspectable string
|
44
|
+
def inspect
|
45
|
+
"#<#{self.class.name}:0x#{'%x14' % __id__} @caption=#{caption.inspect} " <<
|
46
|
+
"@cells=#{cells.inspect} @rows=#{rows.inspect} @columns=#{columns.inspect}>"
|
47
|
+
end
|
48
|
+
# @endgroup
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Text
|
3
|
+
# Represents the caret in a {Text}.
|
4
|
+
class Caret < Offset
|
5
|
+
# @api private
|
6
|
+
def initialize(text_native)
|
7
|
+
@text_native = text_native
|
8
|
+
end
|
9
|
+
|
10
|
+
# @!group Actions
|
11
|
+
# @param offset [responds to #to_i]
|
12
|
+
#
|
13
|
+
# @return [true,false] indicating success
|
14
|
+
#
|
15
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-text.html#atspi-text-set-caret-offset atspi_text_set_caret_offset
|
16
|
+
def move_to(offset)
|
17
|
+
@text_native.set_caret_offset(offset.to_i)
|
18
|
+
end
|
19
|
+
# @!endgroup
|
20
|
+
|
21
|
+
# @!group Representations
|
22
|
+
# @return [Integer] its integer representation
|
23
|
+
#
|
24
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-text.html#atspi-text-get-caret-offset atspi_text_get_caret_offset
|
25
|
+
def to_i
|
26
|
+
@text_native.caret_offset
|
27
|
+
end
|
28
|
+
# @!endgroup
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Text
|
3
|
+
# Represents a single character in a {Text}.
|
4
|
+
class Character
|
5
|
+
# @api private
|
6
|
+
def initialize(native, offset)
|
7
|
+
@native = native
|
8
|
+
@offset = offset
|
9
|
+
end
|
10
|
+
|
11
|
+
# @!group Attributes
|
12
|
+
# @return [1] its length
|
13
|
+
def length
|
14
|
+
1
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param relative_to [Symbol] coordinate system derived from
|
18
|
+
# libatspi's {https://developer.gnome.org/libatspi/stable/libatspi-atspi-constants.html#AtspiCoordType AtspiCoordType enum}
|
19
|
+
# by removing the prefix +ATSPI_COORD_TYPE+ and making it lowercase
|
20
|
+
#
|
21
|
+
# @return [Extents] its extents
|
22
|
+
#
|
23
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-text.html#atspi-text-get-character-extents atspi_text_get_character_extents
|
24
|
+
def extents(relative_to:)
|
25
|
+
Extents.new(@native.character_extents(@offset, relative_to))
|
26
|
+
end
|
27
|
+
# @!endgroup
|
28
|
+
|
29
|
+
# @!group Representations
|
30
|
+
# @return [String] its string representation
|
31
|
+
#
|
32
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-text.html#atspi-text-get-character-at-offset atspi_text_get_character_at_offset
|
33
|
+
def to_s
|
34
|
+
[@native.character_at_offset(@offset)].pack("U") # UCS-4 codepoint to readable character
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String] itself as an inspectable string
|
38
|
+
def inspect
|
39
|
+
"#<#{self.class.name}:0x#{'%x14' % __id__} @to_s=#{to_s.inspect} @length=#{length} " <<
|
40
|
+
"@offset=#{@offset} @extents=#{extents(relative_to: :screen).inspect}>"
|
41
|
+
end
|
42
|
+
# @!endgroup
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
class ATSPI::Accessible::Text
|
2
|
+
# Wraps libatspi's {https://developer.gnome.org/libatspi/stable/libatspi-atspi-editabletext.html#AtspiEditableText editable_text interface}.
|
3
|
+
module Editable
|
4
|
+
# @!group Attributes & States
|
5
|
+
# Checks if it is editable.
|
6
|
+
#
|
7
|
+
# @return [true,false]
|
8
|
+
#
|
9
|
+
# @see https://developer.gnome.org/libatspi/stable/AtspiAccessible.html#atspi-accessible-get-editable-text atspi_accessible_get_editable_text_iface
|
10
|
+
def editable?
|
11
|
+
not @native.editable_text_iface.nil?
|
12
|
+
end
|
13
|
+
# @!endgroup
|
14
|
+
|
15
|
+
# @!group Actions
|
16
|
+
# Replaces its content with the given one. Will succeed only if it's
|
17
|
+
# editable.
|
18
|
+
#
|
19
|
+
# @param text [respond to #to_s] the new text
|
20
|
+
#
|
21
|
+
# @return [true,false] indicating success
|
22
|
+
def set_to(text)
|
23
|
+
delete && insert(text.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Inserts a string at the given offset. Will succeed only if it's editable.
|
27
|
+
#
|
28
|
+
# @param text [respond to #to_s] the text to insert
|
29
|
+
# @param at [responds to #to_i] the offset to insert the string at
|
30
|
+
#
|
31
|
+
# @return [true,false] indicating success
|
32
|
+
#
|
33
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-editabletext.html#atspi-editable-text-insert-text atspi_editable_text_insert_text
|
34
|
+
def insert(text, at: caret)
|
35
|
+
editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Pastes the string in the clipboard at the given offset. Will succeed
|
39
|
+
# only if it's editable.
|
40
|
+
#
|
41
|
+
# @param at [responds to #to_i] the offset to insert the string at
|
42
|
+
#
|
43
|
+
# @return [true,false] indicating success
|
44
|
+
#
|
45
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-editabletext.html#atspi-editable-text-paste-text atspi_editable_text_paste_text
|
46
|
+
def paste(at: caret)
|
47
|
+
editable? and @native.paste_text(at.to_i)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Copies its content in the given range into the clipboard. Will succeed
|
51
|
+
# only if it's editable.
|
52
|
+
#
|
53
|
+
# @param from [responds to #to_i] the start offset of the range
|
54
|
+
# @param to [responds to #to_i] the end offset of the range
|
55
|
+
#
|
56
|
+
# @return [true,false] indicating success
|
57
|
+
#
|
58
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-editabletext.html#atspi-editable-text-copy-text atspi_editable_text_copy_text
|
59
|
+
def copy(from: 0, to: length)
|
60
|
+
editable? and @native.copy_text(from.to_i, to.to_i)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Cuts its content in the given range and puts it into the clipboard. Will
|
64
|
+
# succeed only if it's editable.
|
65
|
+
#
|
66
|
+
# @param from [responds to #to_i] the start offset of the range
|
67
|
+
# @param to [responds to #to_i] the end offset of the range
|
68
|
+
#
|
69
|
+
# @return [true,false] indicating success
|
70
|
+
#
|
71
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-editabletext.html#atspi-editable-text-cut-text atspi_editable_text_cut_text
|
72
|
+
def cut(from: 0, to: length)
|
73
|
+
editable? and @native.cut_text(from.to_i, to.to_i)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Deletes its content in the given range. Will succeed only if it's
|
77
|
+
# editable.
|
78
|
+
#
|
79
|
+
# @param from [responds to #to_i] the start offset of the range
|
80
|
+
# @param to [responds to #to_i] the end offset of the range
|
81
|
+
#
|
82
|
+
# @return [true,false] indicating success
|
83
|
+
#
|
84
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-editabletext.html#atspi-editable-text-delete-text atspi_editable_text_delete_text
|
85
|
+
def delete(from: 0, to: length)
|
86
|
+
editable? and @native.delete_text(from.to_i, to.to_i)
|
87
|
+
end
|
88
|
+
# @!endgroup
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ATSPI::Accessible
|
2
|
+
class Text
|
3
|
+
# Represents a hyperlink in a {Text}.
|
4
|
+
class Hyperlink < Hyperlink
|
5
|
+
# @api private
|
6
|
+
def initialize(text_native, native)
|
7
|
+
@text_native = text_native
|
8
|
+
super(native)
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Range] its range
|
12
|
+
#
|
13
|
+
# @see https://developer.gnome.org/libatspi/stable/AtspiHyperlink.html#atspi-hyperlink-get-index-range atspi_hyperlink_get_index_range
|
14
|
+
def range
|
15
|
+
Range.new(@text_native, @native.index_range)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class ATSPI::Accessible::Text
|
2
|
+
# Wraps libatspi's {https://developer.gnome.org/libatspi/stable/libatspi-atspi-hypertext.html#AtspiHypertext hypertext interface}.
|
3
|
+
module Hypertext
|
4
|
+
# @!group Attributes & States
|
5
|
+
# Checks if it is a hypertext.
|
6
|
+
#
|
7
|
+
# @return [true,false]
|
8
|
+
#
|
9
|
+
# @see https://developer.gnome.org/libatspi/stable/AtspiAccessible.html#atspi-accessible-get-hypertext atspi_accessible_get_hypertext_iface
|
10
|
+
def hypertext?
|
11
|
+
not @native.hypertext_iface.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Array<Hyperlink>] its hyperlinks. Will be an empty array if it
|
15
|
+
# is not a hypertext.
|
16
|
+
#
|
17
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-hypertext.html#atspi-hypertext-get-n-links atspi_hypertext_get_n_links
|
18
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-hypertext.html#atspi-hypertext-get-link atspi_hypertext_get_link
|
19
|
+
def hyperlinks
|
20
|
+
if hypertext?
|
21
|
+
@native.n_links.times.map{ |idx| Hyperlink.new(@native, @native.link(idx)) }
|
22
|
+
else
|
23
|
+
[]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
alias_method :links, :hyperlinks
|
27
|
+
# @!endgroup
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ATSPI
|
2
|
+
class Accessible::Text
|
3
|
+
# Represents an offset in a {Text}.
|
4
|
+
class Offset
|
5
|
+
# @api private
|
6
|
+
def initialize(text_native, offset)
|
7
|
+
@text_native = text_native
|
8
|
+
@offset = offset
|
9
|
+
end
|
10
|
+
|
11
|
+
# @!group Attributes
|
12
|
+
# @param boundary [Symbol] the boundary type derived from libatspi's
|
13
|
+
# {https://github.com/GNOME/at-spi2-core/blob/9439376bc09333e6baf7111d5246a7beff1f7a14/atspi/atspi-constants.h#L348 AtspiTextGranularity enum}
|
14
|
+
# by removing the prefix +ATSPI_TEXT_GRANULARITY_+ and making it lowercase
|
15
|
+
#
|
16
|
+
# @return [Range] the text between the closest boundary to the left and
|
17
|
+
# right
|
18
|
+
#
|
19
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-text.html#atspi-text-get-text-at-offset atspi_text_get_string_at_offset
|
20
|
+
def text_around(boundary)
|
21
|
+
Range.new(@text_native, @text_native.string_at_offset(to_i, boundary))
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Character] its character
|
25
|
+
def character
|
26
|
+
Character.new(@text_native, to_i)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Hyperlink,nil] its hyperlink. Will be +nil+ if its text does
|
30
|
+
# not implement the {https://developer.gnome.org/libatspi/stable/AtspiAccessible.html#atspi-accessible-get-hypertext hypertext interface}
|
31
|
+
# or there simply is no hyperlink at the offset.
|
32
|
+
#
|
33
|
+
# @see https://developer.gnome.org/libatspi/stable/AtspiAccessible.html#atspi-accessible-get-hypertext atspi_accessible_get_hypertext
|
34
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-hypertext.html#atspi-hypertext-get-link-index atspi_hypertext_get_link_index
|
35
|
+
# @see https://developer.gnome.org/libatspi/stable/libatspi-atspi-hypertext.html#atspi-hypertext-get-link atspi_hypertext_get_link
|
36
|
+
def hyperlink
|
37
|
+
if @text_native.hypertext_iface
|
38
|
+
idx = @text_native.link_index(to_i)
|
39
|
+
Hyperlink.new(@text_native, @text_native.link(idx)) if idx != -1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
alias_method :link, :hyperlink
|
43
|
+
# @!endgroup
|
44
|
+
|
45
|
+
# @!group Representations
|
46
|
+
# @return [Integer] its integer representation
|
47
|
+
def to_i
|
48
|
+
@offset
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String] itself as an inspectable string
|
52
|
+
def inspect
|
53
|
+
"#<#{self.class.name}:0x#{'%x14' % __id__} @to_i=#{to_i} " <<
|
54
|
+
"@character=#{character.to_s.inspect} @text_around=#{text_around(:word).to_s.inspect}>"
|
55
|
+
end
|
56
|
+
# @!endgroup
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|