1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module atk.TextT;
26 
27 public  import atk.TextRange;
28 public  import atk.c.functions;
29 public  import atk.c.types;
30 public  import glib.Str;
31 public  import gobject.ObjectG;
32 public  import gobject.Signals;
33 public  import gtkc.atktypes;
34 public  import std.algorithm;
35 
36 
37 /**
38  * #AtkText should be implemented by #AtkObjects on behalf of widgets
39  * that have text content which is either attributed or otherwise
40  * non-trivial.  #AtkObjects whose text content is simple,
41  * unattributed, and very brief may expose that content via
42  * #atk_object_get_name instead; however if the text is editable,
43  * multi-line, typically longer than three or four words, attributed,
44  * selectable, or if the object already uses the 'name' ATK property
45  * for other information, the #AtkText interface should be used to
46  * expose the text content.  In the case of editable text content,
47  * #AtkEditableText (a subtype of the #AtkText interface) should be
48  * implemented instead.
49  * 
50  * #AtkText provides not only traversal facilities and change
51  * notification for text content, but also caret tracking and glyph
52  * bounding box calculations.  Note that the text strings are exposed
53  * as UTF-8, and are therefore potentially multi-byte, and
54  * caret-to-byte offset mapping makes no assumptions about the
55  * character length; also bounding box glyph-to-offset mapping may be
56  * complex for languages which use ligatures.
57  */
58 public template TextT(TStruct)
59 {
60 	/** Get the main Gtk struct */
61 	public AtkText* getTextStruct(bool transferOwnership = false)
62 	{
63 		if (transferOwnership)
64 			ownedRef = false;
65 		return cast(AtkText*)getStruct();
66 	}
67 
68 
69 	/**
70 	 * Adds a selection bounded by the specified offsets.
71 	 *
72 	 * Params:
73 	 *     startOffset = the start position of the selected region
74 	 *     endOffset = the offset of the first character after the selected region.
75 	 *
76 	 * Returns: %TRUE if success, %FALSE otherwise
77 	 */
78 	public bool addSelection(int startOffset, int endOffset)
79 	{
80 		return atk_text_add_selection(getTextStruct(), startOffset, endOffset) != 0;
81 	}
82 
83 	/**
84 	 * Get the ranges of text in the specified bounding box.
85 	 *
86 	 * Params:
87 	 *     rect = An AtkTextRectangle giving the dimensions of the bounding box.
88 	 *     coordType = Specify whether coordinates are relative to the screen or widget window.
89 	 *     xClipType = Specify the horizontal clip type.
90 	 *     yClipType = Specify the vertical clip type.
91 	 *
92 	 * Returns: Array of AtkTextRange. The last
93 	 *     element of the array returned by this function will be NULL.
94 	 *
95 	 * Since: 1.3
96 	 */
97 	public TextRange[] getBoundedRanges(AtkTextRectangle* rect, AtkCoordType coordType, AtkTextClipType xClipType, AtkTextClipType yClipType)
98 	{
99 		auto p = atk_text_get_bounded_ranges(getTextStruct(), rect, coordType, xClipType, yClipType);
100 
101 		if(p is null)
102 		{
103 			return null;
104 		}
105 
106 		TextRange[] arr = new TextRange[getArrayLength(p)];
107 		for(int i = 0; i < getArrayLength(p); i++)
108 		{
109 			arr[i] = ObjectG.getDObject!(TextRange)(cast(AtkTextRange*) p[i]);
110 		}
111 
112 		return arr;
113 	}
114 
115 	/**
116 	 * Gets the offset position of the caret (cursor).
117 	 *
118 	 * Returns: the offset position of the caret (cursor).
119 	 */
120 	public int getCaretOffset()
121 	{
122 		return atk_text_get_caret_offset(getTextStruct());
123 	}
124 
125 	/**
126 	 * Gets the specified text.
127 	 *
128 	 * Params:
129 	 *     offset = position
130 	 *
131 	 * Returns: the character at @offset.
132 	 */
133 	public dchar getCharacterAtOffset(int offset)
134 	{
135 		return atk_text_get_character_at_offset(getTextStruct(), offset);
136 	}
137 
138 	/**
139 	 * Gets the character count.
140 	 *
141 	 * Returns: the number of characters.
142 	 */
143 	public int getCharacterCount()
144 	{
145 		return atk_text_get_character_count(getTextStruct());
146 	}
147 
148 	/**
149 	 * Get the bounding box containing the glyph representing the character at
150 	 * a particular text offset.
151 	 *
152 	 * Params:
153 	 *     offset = The offset of the text character for which bounding information is required.
154 	 *     x = Pointer for the x cordinate of the bounding box
155 	 *     y = Pointer for the y cordinate of the bounding box
156 	 *     width = Pointer for the width of the bounding box
157 	 *     height = Pointer for the height of the bounding box
158 	 *     coords = specify whether coordinates are relative to the screen or widget window
159 	 */
160 	public void getCharacterExtents(int offset, out int x, out int y, out int width, out int height, AtkCoordType coords)
161 	{
162 		atk_text_get_character_extents(getTextStruct(), offset, &x, &y, &width, &height, coords);
163 	}
164 
165 	/**
166 	 * Creates an #AtkAttributeSet which consists of the default values of
167 	 * attributes for the text. See the enum AtkTextAttribute for types of text
168 	 * attributes that can be returned. Note that other attributes may also be
169 	 * returned.
170 	 *
171 	 * Returns: an #AtkAttributeSet which contains the default
172 	 *     values of attributes.  at @offset. this #atkattributeset should be freed by
173 	 *     a call to atk_attribute_set_free().
174 	 */
175 	public AtkAttributeSet* getDefaultAttributes()
176 	{
177 		return atk_text_get_default_attributes(getTextStruct());
178 	}
179 
180 	/**
181 	 * Gets the number of selected regions.
182 	 *
183 	 * Returns: The number of selected regions, or -1 if a failure
184 	 *     occurred.
185 	 */
186 	public int getNSelections()
187 	{
188 		return atk_text_get_n_selections(getTextStruct());
189 	}
190 
191 	/**
192 	 * Gets the offset of the character located at coordinates @x and @y. @x and @y
193 	 * are interpreted as being relative to the screen or this widget's window
194 	 * depending on @coords.
195 	 *
196 	 * Params:
197 	 *     x = screen x-position of character
198 	 *     y = screen y-position of character
199 	 *     coords = specify whether coordinates are relative to the screen or
200 	 *         widget window
201 	 *
202 	 * Returns: the offset to the character which is located at
203 	 *     the specified @x and @y coordinates.
204 	 */
205 	public int getOffsetAtPoint(int x, int y, AtkCoordType coords)
206 	{
207 		return atk_text_get_offset_at_point(getTextStruct(), x, y, coords);
208 	}
209 
210 	/**
211 	 * Get the bounding box for text within the specified range.
212 	 *
213 	 * Params:
214 	 *     startOffset = The offset of the first text character for which boundary
215 	 *         information is required.
216 	 *     endOffset = The offset of the text character after the last character
217 	 *         for which boundary information is required.
218 	 *     coordType = Specify whether coordinates are relative to the screen or widget window.
219 	 *     rect = A pointer to a AtkTextRectangle which is filled in by this function.
220 	 *
221 	 * Since: 1.3
222 	 */
223 	public void getRangeExtents(int startOffset, int endOffset, AtkCoordType coordType, out AtkTextRectangle rect)
224 	{
225 		atk_text_get_range_extents(getTextStruct(), startOffset, endOffset, coordType, &rect);
226 	}
227 
228 	/**
229 	 * Creates an #AtkAttributeSet which consists of the attributes explicitly
230 	 * set at the position @offset in the text. @start_offset and @end_offset are
231 	 * set to the start and end of the range around @offset where the attributes are
232 	 * invariant. Note that @end_offset is the offset of the first character
233 	 * after the range.  See the enum AtkTextAttribute for types of text
234 	 * attributes that can be returned. Note that other attributes may also be
235 	 * returned.
236 	 *
237 	 * Params:
238 	 *     offset = the offset at which to get the attributes, -1 means the offset of
239 	 *         the character to be inserted at the caret location.
240 	 *     startOffset = the address to put the start offset of the range
241 	 *     endOffset = the address to put the end offset of the range
242 	 *
243 	 * Returns: an #AtkAttributeSet which contains the attributes
244 	 *     explicitly set at @offset. This #AtkAttributeSet should be freed by a call
245 	 *     to atk_attribute_set_free().
246 	 */
247 	public AtkAttributeSet* getRunAttributes(int offset, out int startOffset, out int endOffset)
248 	{
249 		return atk_text_get_run_attributes(getTextStruct(), offset, &startOffset, &endOffset);
250 	}
251 
252 	/**
253 	 * Gets the text from the specified selection.
254 	 *
255 	 * Params:
256 	 *     selectionNum = The selection number.  The selected regions are
257 	 *         assigned numbers that correspond to how far the region is from the
258 	 *         start of the text.  The selected region closest to the beginning
259 	 *         of the text region is assigned the number 0, etc.  Note that adding,
260 	 *         moving or deleting a selected region can change the numbering.
261 	 *     startOffset = passes back the start position of the selected region
262 	 *     endOffset = passes back the end position of (e.g. offset immediately past)
263 	 *         the selected region
264 	 *
265 	 * Returns: a newly allocated string containing the selected text. Use g_free()
266 	 *     to free the returned string.
267 	 */
268 	public string getSelection(int selectionNum, out int startOffset, out int endOffset)
269 	{
270 		auto retStr = atk_text_get_selection(getTextStruct(), selectionNum, &startOffset, &endOffset);
271 
272 		scope(exit) Str.freeString(retStr);
273 		return Str.toString(retStr);
274 	}
275 
276 	/**
277 	 * Gets a portion of the text exposed through an #AtkText according to a given @offset
278 	 * and a specific @granularity, along with the start and end offsets defining the
279 	 * boundaries of such a portion of text.
280 	 *
281 	 * If @granularity is ATK_TEXT_GRANULARITY_CHAR the character at the
282 	 * offset is returned.
283 	 *
284 	 * If @granularity is ATK_TEXT_GRANULARITY_WORD the returned string
285 	 * is from the word start at or before the offset to the word start after
286 	 * the offset.
287 	 *
288 	 * The returned string will contain the word at the offset if the offset
289 	 * is inside a word and will contain the word before the offset if the
290 	 * offset is not inside a word.
291 	 *
292 	 * If @granularity is ATK_TEXT_GRANULARITY_SENTENCE the returned string
293 	 * is from the sentence start at or before the offset to the sentence
294 	 * start after the offset.
295 	 *
296 	 * The returned string will contain the sentence at the offset if the offset
297 	 * is inside a sentence and will contain the sentence before the offset
298 	 * if the offset is not inside a sentence.
299 	 *
300 	 * If @granularity is ATK_TEXT_GRANULARITY_LINE the returned string
301 	 * is from the line start at or before the offset to the line
302 	 * start after the offset.
303 	 *
304 	 * If @granularity is ATK_TEXT_GRANULARITY_PARAGRAPH the returned string
305 	 * is from the start of the paragraph at or before the offset to the start
306 	 * of the following paragraph after the offset.
307 	 *
308 	 * Params:
309 	 *     offset = position
310 	 *     granularity = An #AtkTextGranularity
311 	 *     startOffset = the start offset of the returned string, or -1
312 	 *         if an error has occurred (e.g. invalid offset, not implemented)
313 	 *     endOffset = the offset of the first character after the returned string,
314 	 *         or -1 if an error has occurred (e.g. invalid offset, not implemented)
315 	 *
316 	 * Returns: a newly allocated string containing the text
317 	 *     at the @offset bounded by the specified @granularity. Use
318 	 *     g_free() to free the returned string.  Returns %NULL if the
319 	 *     offset is invalid or no implementation is available.
320 	 *
321 	 * Since: 2.10
322 	 */
323 	public string getStringAtOffset(int offset, AtkTextGranularity granularity, out int startOffset, out int endOffset)
324 	{
325 		auto retStr = atk_text_get_string_at_offset(getTextStruct(), offset, granularity, &startOffset, &endOffset);
326 
327 		scope(exit) Str.freeString(retStr);
328 		return Str.toString(retStr);
329 	}
330 
331 	/**
332 	 * Gets the specified text.
333 	 *
334 	 * Params:
335 	 *     startOffset = start position
336 	 *     endOffset = end position, or -1 for the end of the string.
337 	 *
338 	 * Returns: a newly allocated string containing the text from @start_offset up
339 	 *     to, but not including @end_offset. Use g_free() to free the returned string.
340 	 */
341 	public string getText(int startOffset, int endOffset)
342 	{
343 		auto retStr = atk_text_get_text(getTextStruct(), startOffset, endOffset);
344 
345 		scope(exit) Str.freeString(retStr);
346 		return Str.toString(retStr);
347 	}
348 
349 	/**
350 	 * Gets the specified text.
351 	 *
352 	 * Deprecated: Please use atk_text_get_string_at_offset() instead.
353 	 *
354 	 * Params:
355 	 *     offset = position
356 	 *     boundaryType = An #AtkTextBoundary
357 	 *     startOffset = the start offset of the returned string
358 	 *     endOffset = the offset of the first character after the
359 	 *         returned substring
360 	 *
361 	 * Returns: a newly allocated string containing the text after @offset bounded
362 	 *     by the specified @boundary_type. Use g_free() to free the returned string.
363 	 */
364 	public string getTextAfterOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset)
365 	{
366 		auto retStr = atk_text_get_text_after_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset);
367 
368 		scope(exit) Str.freeString(retStr);
369 		return Str.toString(retStr);
370 	}
371 
372 	/**
373 	 * Gets the specified text.
374 	 *
375 	 * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the
376 	 * offset is returned.
377 	 *
378 	 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string
379 	 * is from the word start at or before the offset to the word start after
380 	 * the offset.
381 	 *
382 	 * The returned string will contain the word at the offset if the offset
383 	 * is inside a word and will contain the word before the offset if the
384 	 * offset is not inside a word.
385 	 *
386 	 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned
387 	 * string is from the sentence start at or before the offset to the sentence
388 	 * start after the offset.
389 	 *
390 	 * The returned string will contain the sentence at the offset if the offset
391 	 * is inside a sentence and will contain the sentence before the offset
392 	 * if the offset is not inside a sentence.
393 	 *
394 	 * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned
395 	 * string is from the line start at or before the offset to the line
396 	 * start after the offset.
397 	 *
398 	 * Deprecated: This method is deprecated since ATK version
399 	 * 2.9.4. Please use atk_text_get_string_at_offset() instead.
400 	 *
401 	 * Params:
402 	 *     offset = position
403 	 *     boundaryType = An #AtkTextBoundary
404 	 *     startOffset = the start offset of the returned string
405 	 *     endOffset = the offset of the first character after the
406 	 *         returned substring
407 	 *
408 	 * Returns: a newly allocated string containing the text at @offset bounded by
409 	 *     the specified @boundary_type. Use g_free() to free the returned string.
410 	 */
411 	public string getTextAtOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset)
412 	{
413 		auto retStr = atk_text_get_text_at_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset);
414 
415 		scope(exit) Str.freeString(retStr);
416 		return Str.toString(retStr);
417 	}
418 
419 	/**
420 	 * Gets the specified text.
421 	 *
422 	 * Deprecated: Please use atk_text_get_string_at_offset() instead.
423 	 *
424 	 * Params:
425 	 *     offset = position
426 	 *     boundaryType = An #AtkTextBoundary
427 	 *     startOffset = the start offset of the returned string
428 	 *     endOffset = the offset of the first character after the
429 	 *         returned substring
430 	 *
431 	 * Returns: a newly allocated string containing the text before @offset bounded
432 	 *     by the specified @boundary_type. Use g_free() to free the returned string.
433 	 */
434 	public string getTextBeforeOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset)
435 	{
436 		auto retStr = atk_text_get_text_before_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset);
437 
438 		scope(exit) Str.freeString(retStr);
439 		return Str.toString(retStr);
440 	}
441 
442 	/**
443 	 * Removes the specified selection.
444 	 *
445 	 * Params:
446 	 *     selectionNum = The selection number.  The selected regions are
447 	 *         assigned numbers that correspond to how far the region is from the
448 	 *         start of the text.  The selected region closest to the beginning
449 	 *         of the text region is assigned the number 0, etc.  Note that adding,
450 	 *         moving or deleting a selected region can change the numbering.
451 	 *
452 	 * Returns: %TRUE if success, %FALSE otherwise
453 	 */
454 	public bool removeSelection(int selectionNum)
455 	{
456 		return atk_text_remove_selection(getTextStruct(), selectionNum) != 0;
457 	}
458 
459 	/**
460 	 * Sets the caret (cursor) position to the specified @offset.
461 	 *
462 	 * Params:
463 	 *     offset = position
464 	 *
465 	 * Returns: %TRUE if success, %FALSE otherwise.
466 	 */
467 	public bool setCaretOffset(int offset)
468 	{
469 		return atk_text_set_caret_offset(getTextStruct(), offset) != 0;
470 	}
471 
472 	/**
473 	 * Changes the start and end offset of the specified selection.
474 	 *
475 	 * Params:
476 	 *     selectionNum = The selection number.  The selected regions are
477 	 *         assigned numbers that correspond to how far the region is from the
478 	 *         start of the text.  The selected region closest to the beginning
479 	 *         of the text region is assigned the number 0, etc.  Note that adding,
480 	 *         moving or deleting a selected region can change the numbering.
481 	 *     startOffset = the new start position of the selection
482 	 *     endOffset = the new end position of (e.g. offset immediately past)
483 	 *         the selection
484 	 *
485 	 * Returns: %TRUE if success, %FALSE otherwise
486 	 */
487 	public bool setSelection(int selectionNum, int startOffset, int endOffset)
488 	{
489 		return atk_text_set_selection(getTextStruct(), selectionNum, startOffset, endOffset) != 0;
490 	}
491 
492 	protected class OnTextAttributesChangedDelegateWrapper
493 	{
494 		void delegate(TextIF) dlg;
495 		gulong handlerId;
496 
497 		this(void delegate(TextIF) dlg)
498 		{
499 			this.dlg = dlg;
500 			onTextAttributesChangedListeners ~= this;
501 		}
502 
503 		void remove(OnTextAttributesChangedDelegateWrapper source)
504 		{
505 			foreach(index, wrapper; onTextAttributesChangedListeners)
506 			{
507 				if (wrapper.handlerId == source.handlerId)
508 				{
509 					onTextAttributesChangedListeners[index] = null;
510 					onTextAttributesChangedListeners = std.algorithm.remove(onTextAttributesChangedListeners, index);
511 					break;
512 				}
513 			}
514 		}
515 	}
516 	OnTextAttributesChangedDelegateWrapper[] onTextAttributesChangedListeners;
517 
518 	/**
519 	 * The "text-attributes-changed" signal is emitted when the text
520 	 * attributes of the text of an object which implements AtkText
521 	 * changes.
522 	 */
523 	gulong addOnTextAttributesChanged(void delegate(TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
524 	{
525 		auto wrapper = new OnTextAttributesChangedDelegateWrapper(dlg);
526 		wrapper.handlerId = Signals.connectData(
527 			this,
528 			"text-attributes-changed",
529 			cast(GCallback)&callBackTextAttributesChanged,
530 			cast(void*)wrapper,
531 			cast(GClosureNotify)&callBackTextAttributesChangedDestroy,
532 			connectFlags);
533 		return wrapper.handlerId;
534 	}
535 
536 	extern(C) static void callBackTextAttributesChanged(AtkText* textStruct, OnTextAttributesChangedDelegateWrapper wrapper)
537 	{
538 		wrapper.dlg(wrapper.outer);
539 	}
540 
541 	extern(C) static void callBackTextAttributesChangedDestroy(OnTextAttributesChangedDelegateWrapper wrapper, GClosure* closure)
542 	{
543 		wrapper.remove(wrapper);
544 	}
545 
546 	protected class OnTextCaretMovedDelegateWrapper
547 	{
548 		void delegate(int, TextIF) dlg;
549 		gulong handlerId;
550 
551 		this(void delegate(int, TextIF) dlg)
552 		{
553 			this.dlg = dlg;
554 			onTextCaretMovedListeners ~= this;
555 		}
556 
557 		void remove(OnTextCaretMovedDelegateWrapper source)
558 		{
559 			foreach(index, wrapper; onTextCaretMovedListeners)
560 			{
561 				if (wrapper.handlerId == source.handlerId)
562 				{
563 					onTextCaretMovedListeners[index] = null;
564 					onTextCaretMovedListeners = std.algorithm.remove(onTextCaretMovedListeners, index);
565 					break;
566 				}
567 			}
568 		}
569 	}
570 	OnTextCaretMovedDelegateWrapper[] onTextCaretMovedListeners;
571 
572 	/**
573 	 * The "text-caret-moved" signal is emitted when the caret
574 	 * position of the text of an object which implements AtkText
575 	 * changes.
576 	 *
577 	 * Params:
578 	 *     arg1 = The new position of the text caret.
579 	 */
580 	gulong addOnTextCaretMoved(void delegate(int, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
581 	{
582 		auto wrapper = new OnTextCaretMovedDelegateWrapper(dlg);
583 		wrapper.handlerId = Signals.connectData(
584 			this,
585 			"text-caret-moved",
586 			cast(GCallback)&callBackTextCaretMoved,
587 			cast(void*)wrapper,
588 			cast(GClosureNotify)&callBackTextCaretMovedDestroy,
589 			connectFlags);
590 		return wrapper.handlerId;
591 	}
592 
593 	extern(C) static void callBackTextCaretMoved(AtkText* textStruct, int arg1, OnTextCaretMovedDelegateWrapper wrapper)
594 	{
595 		wrapper.dlg(arg1, wrapper.outer);
596 	}
597 
598 	extern(C) static void callBackTextCaretMovedDestroy(OnTextCaretMovedDelegateWrapper wrapper, GClosure* closure)
599 	{
600 		wrapper.remove(wrapper);
601 	}
602 
603 	protected class OnTextChangedDelegateWrapper
604 	{
605 		void delegate(int, int, TextIF) dlg;
606 		gulong handlerId;
607 
608 		this(void delegate(int, int, TextIF) dlg)
609 		{
610 			this.dlg = dlg;
611 			onTextChangedListeners ~= this;
612 		}
613 
614 		void remove(OnTextChangedDelegateWrapper source)
615 		{
616 			foreach(index, wrapper; onTextChangedListeners)
617 			{
618 				if (wrapper.handlerId == source.handlerId)
619 				{
620 					onTextChangedListeners[index] = null;
621 					onTextChangedListeners = std.algorithm.remove(onTextChangedListeners, index);
622 					break;
623 				}
624 			}
625 		}
626 	}
627 	OnTextChangedDelegateWrapper[] onTextChangedListeners;
628 
629 	/**
630 	 * The "text-changed" signal is emitted when the text of the
631 	 * object which implements the AtkText interface changes, This
632 	 * signal will have a detail which is either "insert" or
633 	 * "delete" which identifies whether the text change was an
634 	 * insertion or a deletion.
635 	 *
636 	 * Deprecated: Use #AtkObject::text-insert or
637 	 * #AtkObject::text-remove instead.
638 	 *
639 	 * Params:
640 	 *     arg1 = The position (character offset) of the insertion or deletion.
641 	 *     arg2 = The length (in characters) of text inserted or deleted.
642 	 */
643 	gulong addOnTextChanged(void delegate(int, int, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
644 	{
645 		auto wrapper = new OnTextChangedDelegateWrapper(dlg);
646 		wrapper.handlerId = Signals.connectData(
647 			this,
648 			"text-changed",
649 			cast(GCallback)&callBackTextChanged,
650 			cast(void*)wrapper,
651 			cast(GClosureNotify)&callBackTextChangedDestroy,
652 			connectFlags);
653 		return wrapper.handlerId;
654 	}
655 
656 	extern(C) static void callBackTextChanged(AtkText* textStruct, int arg1, int arg2, OnTextChangedDelegateWrapper wrapper)
657 	{
658 		wrapper.dlg(arg1, arg2, wrapper.outer);
659 	}
660 
661 	extern(C) static void callBackTextChangedDestroy(OnTextChangedDelegateWrapper wrapper, GClosure* closure)
662 	{
663 		wrapper.remove(wrapper);
664 	}
665 
666 	protected class OnTextInsertDelegateWrapper
667 	{
668 		void delegate(int, int, string, TextIF) dlg;
669 		gulong handlerId;
670 
671 		this(void delegate(int, int, string, TextIF) dlg)
672 		{
673 			this.dlg = dlg;
674 			onTextInsertListeners ~= this;
675 		}
676 
677 		void remove(OnTextInsertDelegateWrapper source)
678 		{
679 			foreach(index, wrapper; onTextInsertListeners)
680 			{
681 				if (wrapper.handlerId == source.handlerId)
682 				{
683 					onTextInsertListeners[index] = null;
684 					onTextInsertListeners = std.algorithm.remove(onTextInsertListeners, index);
685 					break;
686 				}
687 			}
688 		}
689 	}
690 	OnTextInsertDelegateWrapper[] onTextInsertListeners;
691 
692 	/**
693 	 * The "text-insert" signal is emitted when a new text is
694 	 * inserted. If the signal was not triggered by the user
695 	 * (e.g. typing or pasting text), the "system" detail should be
696 	 * included.
697 	 *
698 	 * Params:
699 	 *     arg1 = The position (character offset) of the insertion.
700 	 *     arg2 = The length (in characters) of text inserted.
701 	 *     arg3 = The new text inserted
702 	 */
703 	gulong addOnTextInsert(void delegate(int, int, string, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
704 	{
705 		auto wrapper = new OnTextInsertDelegateWrapper(dlg);
706 		wrapper.handlerId = Signals.connectData(
707 			this,
708 			"text-insert",
709 			cast(GCallback)&callBackTextInsert,
710 			cast(void*)wrapper,
711 			cast(GClosureNotify)&callBackTextInsertDestroy,
712 			connectFlags);
713 		return wrapper.handlerId;
714 	}
715 
716 	extern(C) static void callBackTextInsert(AtkText* textStruct, int arg1, int arg2, char* arg3, OnTextInsertDelegateWrapper wrapper)
717 	{
718 		wrapper.dlg(arg1, arg2, Str.toString(arg3), wrapper.outer);
719 	}
720 
721 	extern(C) static void callBackTextInsertDestroy(OnTextInsertDelegateWrapper wrapper, GClosure* closure)
722 	{
723 		wrapper.remove(wrapper);
724 	}
725 
726 	protected class OnTextRemoveDelegateWrapper
727 	{
728 		void delegate(int, int, string, TextIF) dlg;
729 		gulong handlerId;
730 
731 		this(void delegate(int, int, string, TextIF) dlg)
732 		{
733 			this.dlg = dlg;
734 			onTextRemoveListeners ~= this;
735 		}
736 
737 		void remove(OnTextRemoveDelegateWrapper source)
738 		{
739 			foreach(index, wrapper; onTextRemoveListeners)
740 			{
741 				if (wrapper.handlerId == source.handlerId)
742 				{
743 					onTextRemoveListeners[index] = null;
744 					onTextRemoveListeners = std.algorithm.remove(onTextRemoveListeners, index);
745 					break;
746 				}
747 			}
748 		}
749 	}
750 	OnTextRemoveDelegateWrapper[] onTextRemoveListeners;
751 
752 	/**
753 	 * The "text-remove" signal is emitted when a new text is
754 	 * removed. If the signal was not triggered by the user
755 	 * (e.g. typing or pasting text), the "system" detail should be
756 	 * included.
757 	 *
758 	 * Params:
759 	 *     arg1 = The position (character offset) of the removal.
760 	 *     arg2 = The length (in characters) of text removed.
761 	 *     arg3 = The old text removed
762 	 */
763 	gulong addOnTextRemove(void delegate(int, int, string, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
764 	{
765 		auto wrapper = new OnTextRemoveDelegateWrapper(dlg);
766 		wrapper.handlerId = Signals.connectData(
767 			this,
768 			"text-remove",
769 			cast(GCallback)&callBackTextRemove,
770 			cast(void*)wrapper,
771 			cast(GClosureNotify)&callBackTextRemoveDestroy,
772 			connectFlags);
773 		return wrapper.handlerId;
774 	}
775 
776 	extern(C) static void callBackTextRemove(AtkText* textStruct, int arg1, int arg2, char* arg3, OnTextRemoveDelegateWrapper wrapper)
777 	{
778 		wrapper.dlg(arg1, arg2, Str.toString(arg3), wrapper.outer);
779 	}
780 
781 	extern(C) static void callBackTextRemoveDestroy(OnTextRemoveDelegateWrapper wrapper, GClosure* closure)
782 	{
783 		wrapper.remove(wrapper);
784 	}
785 
786 	protected class OnTextSelectionChangedDelegateWrapper
787 	{
788 		void delegate(TextIF) dlg;
789 		gulong handlerId;
790 
791 		this(void delegate(TextIF) dlg)
792 		{
793 			this.dlg = dlg;
794 			onTextSelectionChangedListeners ~= this;
795 		}
796 
797 		void remove(OnTextSelectionChangedDelegateWrapper source)
798 		{
799 			foreach(index, wrapper; onTextSelectionChangedListeners)
800 			{
801 				if (wrapper.handlerId == source.handlerId)
802 				{
803 					onTextSelectionChangedListeners[index] = null;
804 					onTextSelectionChangedListeners = std.algorithm.remove(onTextSelectionChangedListeners, index);
805 					break;
806 				}
807 			}
808 		}
809 	}
810 	OnTextSelectionChangedDelegateWrapper[] onTextSelectionChangedListeners;
811 
812 	/**
813 	 * The "text-selection-changed" signal is emitted when the
814 	 * selected text of an object which implements AtkText changes.
815 	 */
816 	gulong addOnTextSelectionChanged(void delegate(TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
817 	{
818 		auto wrapper = new OnTextSelectionChangedDelegateWrapper(dlg);
819 		wrapper.handlerId = Signals.connectData(
820 			this,
821 			"text-selection-changed",
822 			cast(GCallback)&callBackTextSelectionChanged,
823 			cast(void*)wrapper,
824 			cast(GClosureNotify)&callBackTextSelectionChangedDestroy,
825 			connectFlags);
826 		return wrapper.handlerId;
827 	}
828 
829 	extern(C) static void callBackTextSelectionChanged(AtkText* textStruct, OnTextSelectionChangedDelegateWrapper wrapper)
830 	{
831 		wrapper.dlg(wrapper.outer);
832 	}
833 
834 	extern(C) static void callBackTextSelectionChangedDestroy(OnTextSelectionChangedDelegateWrapper wrapper, GClosure* closure)
835 	{
836 		wrapper.remove(wrapper);
837 	}
838 }