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