summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_text_cursor.eo
blob: e63e080b78b7affdfa121892a18df8c1166933ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
enum @beta Efl.Text.Cursor_Type
{
   [[Shape of the text cursor.
     This is normally used in @Efl.Text.Cursor methods to retrieve the cursor's geometry.
   ]]
   before, [[Cursor is a vertical bar (I-beam) placed before the selected character.]]
   under   [[Cursor is an horizontal line (underscore) placed under the selected character.]]
}

enum @beta Efl.Text.Cursor_Move_Type
{
   [[Text cursor movement types.]]
   char_next,       [[Advances to the next character.]]
   char_prev,       [[Advances to the previous character.]]
   cluster_next,    [[Advances to the next grapheme cluster
                      (A character sequence rendered together. See https://unicode.org/reports/tr29/).]]
   cluster_prev,    [[Advances to the previous grapheme cluster
                      (A character sequence rendered together. See https://unicode.org/reports/tr29/).]]
   paragraph_start, [[Advances to the first character in current paragraph.]]
   paragraph_end,   [[Advances to the last character in current paragraph.]]
   word_start,      [[Advance to current word start.]]
   word_end,        [[Advance to current word end.]]
   line_start,      [[Advance to current line first character.]]
   line_end,        [[Advance to current line last character.]]
   first,           [[Advance to first character in the first paragraph.]]
   last,            [[Advance to last character in the  last  paragraph.]]
   paragraph_next,  [[Advances to the start of the next paragraph.]]
   paragraph_prev   [[Advances to the end of the previous paragraph.]]
}

abstract @beta Efl.Text.Cursor extends Efl.Object implements Efl.Duplicate{
   [[Cursor API.]]
   c_prefix: efl_text_cursor;
   methods {

      @property position {
         [[Cursor position.]]
         set {  }
         get {  }
         values {
            position: int; [[Cursor position.]]
         }
      }

      @property content {
         [[The content of the cursor (the character under the cursor).]]
         get {
         }
         values {
            content: Eina.Unicode; [[The unicode codepoint of the character.]]
         }
      }

      @property content_geometry {
         [[The geometry of the item/char pointed by the cursor.]]
         get { }
         values {
            geometry: Eina.Rect; [[The geometry in pixels.]]
         }
      }

      @property line_number {
         [[The line the cursor is on.]]
         set {  }
         get {  }
         values {
            line_number: int; [[The line number.]]
         }
      }

      @property cursor_geometry {
         [[Returns the geometry of cursor, if cursor is shown for the text 
           of the same direction as paragraph,else  ("split cursor") will return 
           and you need to consider the lower ("split cursor") @.lower_cursor_geometry

           Split cursor geometry is valid only  in @Efl.Text.Cursor_Type.before cursor mode.]]
         get {
         }
         keys {
            ctype: Efl.Text.Cursor_Type; [[The type of the cursor.]]
         }
         values {
            geometry: Eina.Rect; [[The geometry of the cursor (or upper cursor) in pixels.]]
         }
      }

      @property lower_cursor_geometry {
         [[Returns the geometry of the lower ("split cursor"), if logical cursor is
           between LTR/RTL text.

           To get the upper ("split cursor") @.cursor_geometry with @Efl.Text.Cursor_Type.before cursor mode.]]
         get {
            return: bool; [[$true if split cursor, $false otherwise.]]
         }
         values {
            geometry: Eina.Rect; [[The geometry of the lower cursor in pixels.]]
         }
      }

      equal @const {
         [[Check if two cursors are equal - faster than compare if all you want is equality.]]
         params {
            dst: const(Efl.Text.Cursor); [[Destination Cursor.]]
         }
         return: bool; [[$true if cursors are equal, $false otherwise.]]
      }

      compare @const {
         [[Compare two cursors
           Return <0 if cursor position less than dst, 0 if cursor == dest and >0 otherwise.]]
         params {
            dst: const(Efl.Text.Cursor); [[Destination Cursor.]]
         }
         return: int; [[Difference between cursors.]]
      }

      move {
         [[Move the cursor.]]
         params {
            @in type: Efl.Text.Cursor_Move_Type; [[The type of movement.]]
         }
         return: bool; [[True if actually moved.]]
      }

      char_delete {
         [[Deletes a single character from position pointed by given cursor.]]
      }

      line_jump_by {
         [[Jump the cursor by the given number of lines.]]
         params {
            by: int; [[Number of lines.]]
         }
         return: bool; [[True if actually moved.]]
      }

      char_coord_set {
         [[Set cursor coordinates.]]
         params {
            @in coord: Eina.Position2D; [[The coordinates to set to.]]
         }
      }

      cluster_coord_set {
         [[Set cursor coordinates according to grapheme clusters.
           It does not allow to put a cursor to the middle of a grapheme cluster.]]
         params {
            @in coord: Eina.Position2D; [[The coordinates to set to.]]
         }
      }

      text_insert {
         [[Adds text to the current cursor position and set the cursor to
           *after* the start of the text just added.]]
         params {
            @in text: string; [[Text to append (UTF-8 format).]]
         }
      }

      markup_insert {
         [[Inserts a markup text at cursor position.]]
         params {
            @in markup: string; [[Text to append (UTF-8 format).]]
         }
      }

      range_markup_get @const {
         [[Markup of a given range in the text.]]
         return: mstring @move; [[The markup in the given range.]]
         params {
            cur2: Efl.Text.Cursor; [[End of range.]]
         }
      }

      range_text_get @const {
         [[Returns the text in the range between cursor and $cur2.]]
         return: mstring @move; [[The text in the given range.]]
         params {
            cur2: Efl.Text.Cursor; [[End of range.]]
         }
      }

      range_geometry_get {
         [[Get the simple geometry in pixels of a range in the text.

           The geometry is the geometry in which rectangles in middle lines of
           range are merged into one big rectangle. This is an optimized
           version of @.range_precise_geometry_get.]]
         params {
             cur2: Efl.Text.Cursor; [[End of range.]]
         }
         return: iterator<Eina.Rect> @move; [[
            Iterator on all geoemtries of the given range.]]
      }

      range_precise_geometry_get {
         [[Get the "precise" geometry in pixels of a range.

           The geometry is represented as rectangles for each of the line
           segments in the given range [$cur1, $cur2].]]
         params {
             cur2: Efl.Text.Cursor; [[End of range.]]
         }
         return: iterator<Eina.Rect> @move; [[
            Iterator on all simple geometries of the given range.]]
      }

      range_delete {
         [[Deletes the range between given cursors.

           This removes all the text in given range [$start,$end].]]
         params {
            @in cur2: Efl.Text.Cursor; [[Range end position.]]
         }
      }

      @property text_object {
         [[The text object this cursor is associated with.]]
         get { }
         values {
            text_obj: Efl.Canvas.Object; [[The text object.]]
         }
      }
   }
   events {
      changed: void; [[Called when its position has changed.]]
   }

   implements {
       Efl.Object.destructor;
       Efl.Duplicate.duplicate;
   }
}