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 gsv.SourceView;
26 
27 private import gdk.Event;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gsv.SourceBuffer;
33 private import gsv.SourceCompletion;
34 private import gsv.SourceGutter;
35 private import gsv.SourceMarkAttributes;
36 private import gsv.SpaceDrawer;
37 private import gsvc.gsv;
38 public  import gsvc.gsvtypes;
39 private import gtk.BuildableIF;
40 private import gtk.BuildableT;
41 private import gtk.ScrollableIF;
42 private import gtk.ScrollableT;
43 private import gtk.TextIter;
44 private import gtk.TextView;
45 private import gtk.Widget;
46 private import std.algorithm;
47 
48 
49 /** */
50 public class SourceView : TextView
51 {
52 	/** the main Gtk struct */
53 	protected GtkSourceView* gtkSourceView;
54 
55 	/** Get the main Gtk struct */
56 	public GtkSourceView* getSourceViewStruct()
57 	{
58 		return gtkSourceView;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gtkSourceView;
65 	}
66 
67 	protected override void setStruct(GObject* obj)
68 	{
69 		gtkSourceView = cast(GtkSourceView*)obj;
70 		super.setStruct(obj);
71 	}
72 
73 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GtkSourceView* gtkSourceView, bool ownedRef = false)
77 	{
78 		this.gtkSourceView = gtkSourceView;
79 		super(cast(GtkTextView*)gtkSourceView, ownedRef);
80 	}
81 
82 	/**
83 	 * Returns the GtkSourceBuffer being displayed by this source view.
84 	 * The reference count on the buffer is not incremented; the caller
85 	 * of this function won't own a new reference.
86 	 *
87 	 * Returns:
88 	 *  a GtkSourceBuffer
89 	 */
90 	public override SourceBuffer getBuffer()
91 	{
92 		auto p = gtk_text_view_get_buffer(cast(GtkTextView*)gtkSourceView);
93 		
94 		return ObjectG.getDObject!(SourceBuffer)(cast(GtkSourceBuffer*) p);
95 	}
96 
97 	/**
98 	 */
99 
100 	/** */
101 	public static GType getType()
102 	{
103 		return gtk_source_view_get_type();
104 	}
105 
106 	/**
107 	 * Creates a new #GtkSourceView.
108 	 *
109 	 * By default, an empty #GtkSourceBuffer will be lazily created and can be
110 	 * retrieved with gtk_text_view_get_buffer().
111 	 *
112 	 * If you want to specify your own buffer, either override the
113 	 * #GtkTextViewClass create_buffer factory method, or use
114 	 * gtk_source_view_new_with_buffer().
115 	 *
116 	 * Returns: a new #GtkSourceView.
117 	 *
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this()
121 	{
122 		auto p = gtk_source_view_new();
123 		
124 		if(p is null)
125 		{
126 			throw new ConstructionException("null returned by new");
127 		}
128 		
129 		this(cast(GtkSourceView*) p);
130 	}
131 
132 	/**
133 	 * Creates a new #GtkSourceView widget displaying the buffer
134 	 * @buffer. One buffer can be shared among many widgets.
135 	 *
136 	 * Params:
137 	 *     buffer = a #GtkSourceBuffer.
138 	 *
139 	 * Returns: a new #GtkSourceView.
140 	 *
141 	 * Throws: ConstructionException GTK+ fails to create the object.
142 	 */
143 	public this(SourceBuffer buffer)
144 	{
145 		auto p = gtk_source_view_new_with_buffer((buffer is null) ? null : buffer.getSourceBufferStruct());
146 		
147 		if(p is null)
148 		{
149 			throw new ConstructionException("null returned by new_with_buffer");
150 		}
151 		
152 		this(cast(GtkSourceView*) p);
153 	}
154 
155 	/**
156 	 * Returns whether auto-indentation of text is enabled.
157 	 *
158 	 * Returns: %TRUE if auto indentation is enabled.
159 	 */
160 	public bool getAutoIndent()
161 	{
162 		return gtk_source_view_get_auto_indent(gtkSourceView) != 0;
163 	}
164 
165 	/**
166 	 * Returns the #GtkSourceBackgroundPatternType specifying if and how
167 	 * the background pattern should be displayed for this @view.
168 	 *
169 	 * Returns: the #GtkSourceBackgroundPatternType.
170 	 *
171 	 * Since: 3.16
172 	 */
173 	public GtkSourceBackgroundPatternType getBackgroundPattern()
174 	{
175 		return gtk_source_view_get_background_pattern(gtkSourceView);
176 	}
177 
178 	/**
179 	 * Gets the #GtkSourceCompletion associated with @view. The returned object is
180 	 * guaranteed to be the same for the lifetime of @view. Each #GtkSourceView
181 	 * object has a different #GtkSourceCompletion.
182 	 *
183 	 * Returns: the #GtkSourceCompletion associated with @view.
184 	 */
185 	public SourceCompletion getCompletion()
186 	{
187 		auto p = gtk_source_view_get_completion(gtkSourceView);
188 		
189 		if(p is null)
190 		{
191 			return null;
192 		}
193 		
194 		return ObjectG.getDObject!(SourceCompletion)(cast(GtkSourceCompletion*) p);
195 	}
196 
197 	/**
198 	 * Returns the #GtkSourceDrawSpacesFlags specifying if and how spaces
199 	 * should be displayed for this @view.
200 	 *
201 	 * Deprecated: Use gtk_source_space_drawer_get_types_for_locations()
202 	 * instead.
203 	 *
204 	 * Returns: the #GtkSourceDrawSpacesFlags, 0 if no spaces should be drawn.
205 	 */
206 	public GtkSourceDrawSpacesFlags getDrawSpaces()
207 	{
208 		return gtk_source_view_get_draw_spaces(gtkSourceView);
209 	}
210 
211 	/**
212 	 * Returns the #GtkSourceGutter object associated with @window_type for @view.
213 	 * Only GTK_TEXT_WINDOW_LEFT and GTK_TEXT_WINDOW_RIGHT are supported,
214 	 * respectively corresponding to the left and right gutter. The line numbers
215 	 * and mark category icons are rendered in the left gutter.
216 	 *
217 	 * Params:
218 	 *     windowType = the gutter window type.
219 	 *
220 	 * Returns: the #GtkSourceGutter.
221 	 *
222 	 * Since: 2.8
223 	 */
224 	public SourceGutter getGutter(GtkTextWindowType windowType)
225 	{
226 		auto p = gtk_source_view_get_gutter(gtkSourceView, windowType);
227 		
228 		if(p is null)
229 		{
230 			return null;
231 		}
232 		
233 		return ObjectG.getDObject!(SourceGutter)(cast(GtkSourceGutter*) p);
234 	}
235 
236 	/**
237 	 * Returns whether the current line is highlighted.
238 	 *
239 	 * Returns: %TRUE if the current line is highlighted.
240 	 */
241 	public bool getHighlightCurrentLine()
242 	{
243 		return gtk_source_view_get_highlight_current_line(gtkSourceView) != 0;
244 	}
245 
246 	/**
247 	 * Returns whether when the tab key is pressed the current selection
248 	 * should get indented instead of replaced with the \t character.
249 	 *
250 	 * Returns: %TRUE if the selection is indented when tab is pressed.
251 	 */
252 	public bool getIndentOnTab()
253 	{
254 		return gtk_source_view_get_indent_on_tab(gtkSourceView) != 0;
255 	}
256 
257 	/**
258 	 * Returns the number of spaces to use for each step of indent.
259 	 * See gtk_source_view_set_indent_width() for details.
260 	 *
261 	 * Returns: indent width.
262 	 */
263 	public int getIndentWidth()
264 	{
265 		return gtk_source_view_get_indent_width(gtkSourceView);
266 	}
267 
268 	/**
269 	 * Returns whether when inserting a tabulator character it should
270 	 * be replaced by a group of space characters.
271 	 *
272 	 * Returns: %TRUE if spaces are inserted instead of tabs.
273 	 */
274 	public bool getInsertSpacesInsteadOfTabs()
275 	{
276 		return gtk_source_view_get_insert_spaces_instead_of_tabs(gtkSourceView) != 0;
277 	}
278 
279 	/**
280 	 * Gets attributes and priority for the @category.
281 	 *
282 	 * Params:
283 	 *     category = the category.
284 	 *     priority = place where priority of the category will be stored.
285 	 *
286 	 * Returns: #GtkSourceMarkAttributes for the @category.
287 	 *     The object belongs to @view, so it must not be unreffed.
288 	 */
289 	public SourceMarkAttributes getMarkAttributes(string category, int* priority)
290 	{
291 		auto p = gtk_source_view_get_mark_attributes(gtkSourceView, Str.toStringz(category), priority);
292 		
293 		if(p is null)
294 		{
295 			return null;
296 		}
297 		
298 		return ObjectG.getDObject!(SourceMarkAttributes)(cast(GtkSourceMarkAttributes*) p);
299 	}
300 
301 	/**
302 	 * Gets the position of the right margin in the given @view.
303 	 *
304 	 * Returns: the position of the right margin.
305 	 */
306 	public uint getRightMarginPosition()
307 	{
308 		return gtk_source_view_get_right_margin_position(gtkSourceView);
309 	}
310 
311 	/**
312 	 * Returns whether line marks are displayed beside the text.
313 	 *
314 	 * Returns: %TRUE if the line marks are displayed.
315 	 *
316 	 * Since: 2.2
317 	 */
318 	public bool getShowLineMarks()
319 	{
320 		return gtk_source_view_get_show_line_marks(gtkSourceView) != 0;
321 	}
322 
323 	/**
324 	 * Returns whether line numbers are displayed beside the text.
325 	 *
326 	 * Returns: %TRUE if the line numbers are displayed.
327 	 */
328 	public bool getShowLineNumbers()
329 	{
330 		return gtk_source_view_get_show_line_numbers(gtkSourceView) != 0;
331 	}
332 
333 	/**
334 	 * Returns whether a right margin is displayed.
335 	 *
336 	 * Returns: %TRUE if the right margin is shown.
337 	 */
338 	public bool getShowRightMargin()
339 	{
340 		return gtk_source_view_get_show_right_margin(gtkSourceView) != 0;
341 	}
342 
343 	/**
344 	 * Returns %TRUE if pressing the Backspace key will try to delete spaces
345 	 * up to the previous tab stop.
346 	 *
347 	 * Returns: %TRUE if smart Backspace handling is enabled.
348 	 *
349 	 * Since: 3.18
350 	 */
351 	public bool getSmartBackspace()
352 	{
353 		return gtk_source_view_get_smart_backspace(gtkSourceView) != 0;
354 	}
355 
356 	/**
357 	 * Returns a #GtkSourceSmartHomeEndType end value specifying
358 	 * how the cursor will move when HOME and END keys are pressed.
359 	 *
360 	 * Returns: a #GtkSourceSmartHomeEndType value.
361 	 */
362 	public GtkSourceSmartHomeEndType getSmartHomeEnd()
363 	{
364 		return gtk_source_view_get_smart_home_end(gtkSourceView);
365 	}
366 
367 	/**
368 	 * Gets the #GtkSourceSpaceDrawer associated with @view. The returned object is
369 	 * guaranteed to be the same for the lifetime of @view. Each #GtkSourceView
370 	 * object has a different #GtkSourceSpaceDrawer.
371 	 *
372 	 * Returns: the #GtkSourceSpaceDrawer associated with @view.
373 	 *
374 	 * Since: 3.24
375 	 */
376 	public SpaceDrawer getSpaceDrawer()
377 	{
378 		auto p = gtk_source_view_get_space_drawer(gtkSourceView);
379 		
380 		if(p is null)
381 		{
382 			return null;
383 		}
384 		
385 		return ObjectG.getDObject!(SpaceDrawer)(cast(GtkSourceSpaceDrawer*) p);
386 	}
387 
388 	/**
389 	 * Returns the width of tabulation in characters.
390 	 *
391 	 * Returns: width of tab.
392 	 */
393 	public uint getTabWidth()
394 	{
395 		return gtk_source_view_get_tab_width(gtkSourceView);
396 	}
397 
398 	/**
399 	 * Determines the visual column at @iter taking into consideration the
400 	 * #GtkSourceView:tab-width of @view.
401 	 *
402 	 * Params:
403 	 *     iter = a position in @view.
404 	 *
405 	 * Returns: the visual column at @iter.
406 	 */
407 	public uint getVisualColumn(TextIter iter)
408 	{
409 		return gtk_source_view_get_visual_column(gtkSourceView, (iter is null) ? null : iter.getTextIterStruct());
410 	}
411 
412 	/**
413 	 * Insert one indentation level at the beginning of the
414 	 * specified lines.
415 	 *
416 	 * Params:
417 	 *     start = #GtkTextIter of the first line to indent
418 	 *     end = #GtkTextIter of the last line to indent
419 	 *
420 	 * Since: 3.16
421 	 */
422 	public void indentLines(TextIter start, TextIter end)
423 	{
424 		gtk_source_view_indent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
425 	}
426 
427 	/**
428 	 * If %TRUE auto-indentation of text is enabled.
429 	 *
430 	 * When Enter is pressed to create a new line, the auto-indentation inserts the
431 	 * same indentation as the previous line. This is <emphasis>not</emphasis> a
432 	 * "smart indentation" where an indentation level is added or removed depending
433 	 * on the context.
434 	 *
435 	 * Params:
436 	 *     enable = whether to enable auto indentation.
437 	 */
438 	public void setAutoIndent(bool enable)
439 	{
440 		gtk_source_view_set_auto_indent(gtkSourceView, enable);
441 	}
442 
443 	/**
444 	 * Set if and how the background pattern should be displayed.
445 	 *
446 	 * Params:
447 	 *     backgroundPattern = the #GtkSourceBackgroundPatternType.
448 	 *
449 	 * Since: 3.16
450 	 */
451 	public void setBackgroundPattern(GtkSourceBackgroundPatternType backgroundPattern)
452 	{
453 		gtk_source_view_set_background_pattern(gtkSourceView, backgroundPattern);
454 	}
455 
456 	/**
457 	 * Set if and how the spaces should be visualized. Specifying @flags as 0 will
458 	 * disable display of spaces.
459 	 *
460 	 * For a finer-grained method, there is also the GtkSourceTag's
461 	 * #GtkSourceTag:draw-spaces property.
462 	 *
463 	 * Deprecated: Use gtk_source_space_drawer_set_types_for_locations()
464 	 * instead.
465 	 *
466 	 * Params:
467 	 *     flags = #GtkSourceDrawSpacesFlags specifing how white spaces should
468 	 *         be displayed
469 	 */
470 	public void setDrawSpaces(GtkSourceDrawSpacesFlags flags)
471 	{
472 		gtk_source_view_set_draw_spaces(gtkSourceView, flags);
473 	}
474 
475 	/**
476 	 * If @highlight is %TRUE the current line will be highlighted.
477 	 *
478 	 * Params:
479 	 *     highlight = whether to highlight the current line.
480 	 */
481 	public void setHighlightCurrentLine(bool highlight)
482 	{
483 		gtk_source_view_set_highlight_current_line(gtkSourceView, highlight);
484 	}
485 
486 	/**
487 	 * If %TRUE, when the tab key is pressed when several lines are selected, the
488 	 * selected lines are indented of one level instead of being replaced with a \t
489 	 * character. Shift+Tab unindents the selection.
490 	 *
491 	 * If the first or last line is not selected completely, it is also indented or
492 	 * unindented.
493 	 *
494 	 * When the selection doesn't span several lines, the tab key always replaces
495 	 * the selection with a normal \t character.
496 	 *
497 	 * Params:
498 	 *     enable = whether to indent a block when tab is pressed.
499 	 */
500 	public void setIndentOnTab(bool enable)
501 	{
502 		gtk_source_view_set_indent_on_tab(gtkSourceView, enable);
503 	}
504 
505 	/**
506 	 * Sets the number of spaces to use for each step of indent when the tab key is
507 	 * pressed. If @width is -1, the value of the #GtkSourceView:tab-width property
508 	 * will be used.
509 	 *
510 	 * The #GtkSourceView:indent-width interacts with the
511 	 * #GtkSourceView:insert-spaces-instead-of-tabs property and
512 	 * #GtkSourceView:tab-width. An example will be clearer: if the
513 	 * #GtkSourceView:indent-width is 4 and
514 	 * #GtkSourceView:tab-width is 8 and
515 	 * #GtkSourceView:insert-spaces-instead-of-tabs is %FALSE, then pressing the tab
516 	 * key at the beginning of a line will insert 4 spaces. So far so good. Pressing
517 	 * the tab key a second time will remove the 4 spaces and insert a \t character
518 	 * instead (since #GtkSourceView:tab-width is 8). On the other hand, if
519 	 * #GtkSourceView:insert-spaces-instead-of-tabs is %TRUE, the second tab key
520 	 * pressed will insert 4 more spaces for a total of 8 spaces in the
521 	 * #GtkTextBuffer.
522 	 *
523 	 * The test-widget program (available in the GtkSourceView repository) may be
524 	 * useful to better understand the indentation settings (enable the space
525 	 * drawing!).
526 	 *
527 	 * Params:
528 	 *     width = indent width in characters.
529 	 */
530 	public void setIndentWidth(int width)
531 	{
532 		gtk_source_view_set_indent_width(gtkSourceView, width);
533 	}
534 
535 	/**
536 	 * If %TRUE a tab key pressed is replaced by a group of space characters. Of
537 	 * course it is still possible to insert a real \t programmatically with the
538 	 * #GtkTextBuffer API.
539 	 *
540 	 * Params:
541 	 *     enable = whether to insert spaces instead of tabs.
542 	 */
543 	public void setInsertSpacesInsteadOfTabs(bool enable)
544 	{
545 		gtk_source_view_set_insert_spaces_instead_of_tabs(gtkSourceView, enable);
546 	}
547 
548 	/**
549 	 * Sets attributes and priority for the @category.
550 	 *
551 	 * Params:
552 	 *     category = the category.
553 	 *     attributes = mark attributes.
554 	 *     priority = priority of the category.
555 	 */
556 	public void setMarkAttributes(string category, SourceMarkAttributes attributes, int priority)
557 	{
558 		gtk_source_view_set_mark_attributes(gtkSourceView, Str.toStringz(category), (attributes is null) ? null : attributes.getSourceMarkAttributesStruct(), priority);
559 	}
560 
561 	/**
562 	 * Sets the position of the right margin in the given @view.
563 	 *
564 	 * Params:
565 	 *     pos = the width in characters where to position the right margin.
566 	 */
567 	public void setRightMarginPosition(uint pos)
568 	{
569 		gtk_source_view_set_right_margin_position(gtkSourceView, pos);
570 	}
571 
572 	/**
573 	 * If %TRUE line marks will be displayed beside the text.
574 	 *
575 	 * Params:
576 	 *     show = whether line marks should be displayed.
577 	 *
578 	 * Since: 2.2
579 	 */
580 	public void setShowLineMarks(bool show)
581 	{
582 		gtk_source_view_set_show_line_marks(gtkSourceView, show);
583 	}
584 
585 	/**
586 	 * If %TRUE line numbers will be displayed beside the text.
587 	 *
588 	 * Params:
589 	 *     show = whether line numbers should be displayed.
590 	 */
591 	public void setShowLineNumbers(bool show)
592 	{
593 		gtk_source_view_set_show_line_numbers(gtkSourceView, show);
594 	}
595 
596 	/**
597 	 * If %TRUE a right margin is displayed.
598 	 *
599 	 * Params:
600 	 *     show = whether to show a right margin.
601 	 */
602 	public void setShowRightMargin(bool show)
603 	{
604 		gtk_source_view_set_show_right_margin(gtkSourceView, show);
605 	}
606 
607 	/**
608 	 * When set to %TRUE, pressing the Backspace key will try to delete spaces
609 	 * up to the previous tab stop.
610 	 *
611 	 * Params:
612 	 *     smartBackspace = whether to enable smart Backspace handling.
613 	 *
614 	 * Since: 3.18
615 	 */
616 	public void setSmartBackspace(bool smartBackspace)
617 	{
618 		gtk_source_view_set_smart_backspace(gtkSourceView, smartBackspace);
619 	}
620 
621 	/**
622 	 * Set the desired movement of the cursor when HOME and END keys
623 	 * are pressed.
624 	 *
625 	 * Params:
626 	 *     smartHomeEnd = the desired behavior among #GtkSourceSmartHomeEndType.
627 	 */
628 	public void setSmartHomeEnd(GtkSourceSmartHomeEndType smartHomeEnd)
629 	{
630 		gtk_source_view_set_smart_home_end(gtkSourceView, smartHomeEnd);
631 	}
632 
633 	/**
634 	 * Sets the width of tabulation in characters. The #GtkTextBuffer still contains
635 	 * \t characters, but they can take a different visual width in a #GtkSourceView
636 	 * widget.
637 	 *
638 	 * Params:
639 	 *     width = width of tab in characters.
640 	 */
641 	public void setTabWidth(uint width)
642 	{
643 		gtk_source_view_set_tab_width(gtkSourceView, width);
644 	}
645 
646 	/**
647 	 * Removes one indentation level at the beginning of the
648 	 * specified lines.
649 	 *
650 	 * Params:
651 	 *     start = #GtkTextIter of the first line to indent
652 	 *     end = #GtkTextIter of the last line to indent
653 	 *
654 	 * Since: 3.16
655 	 */
656 	public void unindentLines(TextIter start, TextIter end)
657 	{
658 		gtk_source_view_unindent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
659 	}
660 
661 	protected class OnChangeCaseDelegateWrapper
662 	{
663 		static OnChangeCaseDelegateWrapper[] listeners;
664 		void delegate(GtkSourceChangeCaseType, SourceView) dlg;
665 		gulong handlerId;
666 		
667 		this(void delegate(GtkSourceChangeCaseType, SourceView) dlg)
668 		{
669 			this.dlg = dlg;
670 			this.listeners ~= this;
671 		}
672 		
673 		void remove(OnChangeCaseDelegateWrapper source)
674 		{
675 			foreach(index, wrapper; listeners)
676 			{
677 				if (wrapper.handlerId == source.handlerId)
678 				{
679 					listeners[index] = null;
680 					listeners = std.algorithm.remove(listeners, index);
681 					break;
682 				}
683 			}
684 		}
685 	}
686 
687 	/**
688 	 * Keybinding signal to change case of the text at the current cursor position.
689 	 *
690 	 * Params:
691 	 *     caseType = the case to use
692 	 *
693 	 * Since: 3.16
694 	 */
695 	gulong addOnChangeCase(void delegate(GtkSourceChangeCaseType, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
696 	{
697 		auto wrapper = new OnChangeCaseDelegateWrapper(dlg);
698 		wrapper.handlerId = Signals.connectData(
699 			this,
700 			"change-case",
701 			cast(GCallback)&callBackChangeCase,
702 			cast(void*)wrapper,
703 			cast(GClosureNotify)&callBackChangeCaseDestroy,
704 			connectFlags);
705 		return wrapper.handlerId;
706 	}
707 	
708 	extern(C) static void callBackChangeCase(GtkSourceView* sourceviewStruct, GtkSourceChangeCaseType caseType, OnChangeCaseDelegateWrapper wrapper)
709 	{
710 		wrapper.dlg(caseType, wrapper.outer);
711 	}
712 	
713 	extern(C) static void callBackChangeCaseDestroy(OnChangeCaseDelegateWrapper wrapper, GClosure* closure)
714 	{
715 		wrapper.remove(wrapper);
716 	}
717 
718 	protected class OnChangeNumberDelegateWrapper
719 	{
720 		static OnChangeNumberDelegateWrapper[] listeners;
721 		void delegate(int, SourceView) dlg;
722 		gulong handlerId;
723 		
724 		this(void delegate(int, SourceView) dlg)
725 		{
726 			this.dlg = dlg;
727 			this.listeners ~= this;
728 		}
729 		
730 		void remove(OnChangeNumberDelegateWrapper source)
731 		{
732 			foreach(index, wrapper; listeners)
733 			{
734 				if (wrapper.handlerId == source.handlerId)
735 				{
736 					listeners[index] = null;
737 					listeners = std.algorithm.remove(listeners, index);
738 					break;
739 				}
740 			}
741 		}
742 	}
743 
744 	/**
745 	 * Keybinding signal to edit a number at the current cursor position.
746 	 *
747 	 * Params:
748 	 *     count = the number to add to the number at the current position
749 	 *
750 	 * Since: 3.16
751 	 */
752 	gulong addOnChangeNumber(void delegate(int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
753 	{
754 		auto wrapper = new OnChangeNumberDelegateWrapper(dlg);
755 		wrapper.handlerId = Signals.connectData(
756 			this,
757 			"change-number",
758 			cast(GCallback)&callBackChangeNumber,
759 			cast(void*)wrapper,
760 			cast(GClosureNotify)&callBackChangeNumberDestroy,
761 			connectFlags);
762 		return wrapper.handlerId;
763 	}
764 	
765 	extern(C) static void callBackChangeNumber(GtkSourceView* sourceviewStruct, int count, OnChangeNumberDelegateWrapper wrapper)
766 	{
767 		wrapper.dlg(count, wrapper.outer);
768 	}
769 	
770 	extern(C) static void callBackChangeNumberDestroy(OnChangeNumberDelegateWrapper wrapper, GClosure* closure)
771 	{
772 		wrapper.remove(wrapper);
773 	}
774 
775 	protected class OnJoinLinesDelegateWrapper
776 	{
777 		static OnJoinLinesDelegateWrapper[] listeners;
778 		void delegate(SourceView) dlg;
779 		gulong handlerId;
780 		
781 		this(void delegate(SourceView) dlg)
782 		{
783 			this.dlg = dlg;
784 			this.listeners ~= this;
785 		}
786 		
787 		void remove(OnJoinLinesDelegateWrapper source)
788 		{
789 			foreach(index, wrapper; listeners)
790 			{
791 				if (wrapper.handlerId == source.handlerId)
792 				{
793 					listeners[index] = null;
794 					listeners = std.algorithm.remove(listeners, index);
795 					break;
796 				}
797 			}
798 		}
799 	}
800 
801 	/**
802 	 * Keybinding signal to join the lines currently selected.
803 	 *
804 	 * Since: 3.16
805 	 */
806 	gulong addOnJoinLines(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
807 	{
808 		auto wrapper = new OnJoinLinesDelegateWrapper(dlg);
809 		wrapper.handlerId = Signals.connectData(
810 			this,
811 			"join-lines",
812 			cast(GCallback)&callBackJoinLines,
813 			cast(void*)wrapper,
814 			cast(GClosureNotify)&callBackJoinLinesDestroy,
815 			connectFlags);
816 		return wrapper.handlerId;
817 	}
818 	
819 	extern(C) static void callBackJoinLines(GtkSourceView* sourceviewStruct, OnJoinLinesDelegateWrapper wrapper)
820 	{
821 		wrapper.dlg(wrapper.outer);
822 	}
823 	
824 	extern(C) static void callBackJoinLinesDestroy(OnJoinLinesDelegateWrapper wrapper, GClosure* closure)
825 	{
826 		wrapper.remove(wrapper);
827 	}
828 
829 	protected class OnLineMarkActivatedDelegateWrapper
830 	{
831 		static OnLineMarkActivatedDelegateWrapper[] listeners;
832 		void delegate(TextIter, Event, SourceView) dlg;
833 		gulong handlerId;
834 		
835 		this(void delegate(TextIter, Event, SourceView) dlg)
836 		{
837 			this.dlg = dlg;
838 			this.listeners ~= this;
839 		}
840 		
841 		void remove(OnLineMarkActivatedDelegateWrapper source)
842 		{
843 			foreach(index, wrapper; listeners)
844 			{
845 				if (wrapper.handlerId == source.handlerId)
846 				{
847 					listeners[index] = null;
848 					listeners = std.algorithm.remove(listeners, index);
849 					break;
850 				}
851 			}
852 		}
853 	}
854 
855 	/**
856 	 * Emitted when a line mark has been activated (for instance when there
857 	 * was a button press in the line marks gutter). You can use @iter to
858 	 * determine on which line the activation took place.
859 	 *
860 	 * Params:
861 	 *     iter = a #GtkTextIter
862 	 *     event = the #GdkEvent that activated the event
863 	 */
864 	gulong addOnLineMarkActivated(void delegate(TextIter, Event, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
865 	{
866 		auto wrapper = new OnLineMarkActivatedDelegateWrapper(dlg);
867 		wrapper.handlerId = Signals.connectData(
868 			this,
869 			"line-mark-activated",
870 			cast(GCallback)&callBackLineMarkActivated,
871 			cast(void*)wrapper,
872 			cast(GClosureNotify)&callBackLineMarkActivatedDestroy,
873 			connectFlags);
874 		return wrapper.handlerId;
875 	}
876 	
877 	extern(C) static void callBackLineMarkActivated(GtkSourceView* sourceviewStruct, GtkTextIter* iter, GdkEvent* event, OnLineMarkActivatedDelegateWrapper wrapper)
878 	{
879 		wrapper.dlg(ObjectG.getDObject!(TextIter)(iter), ObjectG.getDObject!(Event)(event), wrapper.outer);
880 	}
881 	
882 	extern(C) static void callBackLineMarkActivatedDestroy(OnLineMarkActivatedDelegateWrapper wrapper, GClosure* closure)
883 	{
884 		wrapper.remove(wrapper);
885 	}
886 
887 	protected class OnMoveLinesDelegateWrapper
888 	{
889 		static OnMoveLinesDelegateWrapper[] listeners;
890 		void delegate(bool, int, SourceView) dlg;
891 		gulong handlerId;
892 		
893 		this(void delegate(bool, int, SourceView) dlg)
894 		{
895 			this.dlg = dlg;
896 			this.listeners ~= this;
897 		}
898 		
899 		void remove(OnMoveLinesDelegateWrapper source)
900 		{
901 			foreach(index, wrapper; listeners)
902 			{
903 				if (wrapper.handlerId == source.handlerId)
904 				{
905 					listeners[index] = null;
906 					listeners = std.algorithm.remove(listeners, index);
907 					break;
908 				}
909 			}
910 		}
911 	}
912 
913 	/**
914 	 * The ::move-lines signal is a keybinding which gets emitted
915 	 * when the user initiates moving a line. The default binding key
916 	 * is Alt+Up/Down arrow. And moves the currently selected lines,
917 	 * or the current line by @count. For the moment, only
918 	 * @count of -1 or 1 is valid.
919 	 *
920 	 * The @copy parameter is deprecated, it has never been used by
921 	 * GtkSourceView (the value is always %FALSE) and was buggy.
922 	 *
923 	 * Params:
924 	 *     copy = %TRUE if the line should be copied, %FALSE if it should be
925 	 *         moved. This parameter is deprecated and will be removed in a later
926 	 *         version, it should be always %FALSE.
927 	 *     count = the number of lines to move over. Only 1 and -1 are
928 	 *         supported.
929 	 *
930 	 * Since: 2.10
931 	 */
932 	gulong addOnMoveLines(void delegate(bool, int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
933 	{
934 		auto wrapper = new OnMoveLinesDelegateWrapper(dlg);
935 		wrapper.handlerId = Signals.connectData(
936 			this,
937 			"move-lines",
938 			cast(GCallback)&callBackMoveLines,
939 			cast(void*)wrapper,
940 			cast(GClosureNotify)&callBackMoveLinesDestroy,
941 			connectFlags);
942 		return wrapper.handlerId;
943 	}
944 	
945 	extern(C) static void callBackMoveLines(GtkSourceView* sourceviewStruct, bool copy, int count, OnMoveLinesDelegateWrapper wrapper)
946 	{
947 		wrapper.dlg(copy, count, wrapper.outer);
948 	}
949 	
950 	extern(C) static void callBackMoveLinesDestroy(OnMoveLinesDelegateWrapper wrapper, GClosure* closure)
951 	{
952 		wrapper.remove(wrapper);
953 	}
954 
955 	protected class OnMoveToMatchingBracketDelegateWrapper
956 	{
957 		static OnMoveToMatchingBracketDelegateWrapper[] listeners;
958 		void delegate(bool, SourceView) dlg;
959 		gulong handlerId;
960 		
961 		this(void delegate(bool, SourceView) dlg)
962 		{
963 			this.dlg = dlg;
964 			this.listeners ~= this;
965 		}
966 		
967 		void remove(OnMoveToMatchingBracketDelegateWrapper source)
968 		{
969 			foreach(index, wrapper; listeners)
970 			{
971 				if (wrapper.handlerId == source.handlerId)
972 				{
973 					listeners[index] = null;
974 					listeners = std.algorithm.remove(listeners, index);
975 					break;
976 				}
977 			}
978 		}
979 	}
980 
981 	/**
982 	 * Keybinding signal to move the cursor to the matching bracket.
983 	 *
984 	 * Params:
985 	 *     extendSelection = %TRUE if the move should extend the selection
986 	 *
987 	 * Since: 3.16
988 	 */
989 	gulong addOnMoveToMatchingBracket(void delegate(bool, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
990 	{
991 		auto wrapper = new OnMoveToMatchingBracketDelegateWrapper(dlg);
992 		wrapper.handlerId = Signals.connectData(
993 			this,
994 			"move-to-matching-bracket",
995 			cast(GCallback)&callBackMoveToMatchingBracket,
996 			cast(void*)wrapper,
997 			cast(GClosureNotify)&callBackMoveToMatchingBracketDestroy,
998 			connectFlags);
999 		return wrapper.handlerId;
1000 	}
1001 	
1002 	extern(C) static void callBackMoveToMatchingBracket(GtkSourceView* sourceviewStruct, bool extendSelection, OnMoveToMatchingBracketDelegateWrapper wrapper)
1003 	{
1004 		wrapper.dlg(extendSelection, wrapper.outer);
1005 	}
1006 	
1007 	extern(C) static void callBackMoveToMatchingBracketDestroy(OnMoveToMatchingBracketDelegateWrapper wrapper, GClosure* closure)
1008 	{
1009 		wrapper.remove(wrapper);
1010 	}
1011 
1012 	protected class OnMoveWordsDelegateWrapper
1013 	{
1014 		static OnMoveWordsDelegateWrapper[] listeners;
1015 		void delegate(int, SourceView) dlg;
1016 		gulong handlerId;
1017 		
1018 		this(void delegate(int, SourceView) dlg)
1019 		{
1020 			this.dlg = dlg;
1021 			this.listeners ~= this;
1022 		}
1023 		
1024 		void remove(OnMoveWordsDelegateWrapper source)
1025 		{
1026 			foreach(index, wrapper; listeners)
1027 			{
1028 				if (wrapper.handlerId == source.handlerId)
1029 				{
1030 					listeners[index] = null;
1031 					listeners = std.algorithm.remove(listeners, index);
1032 					break;
1033 				}
1034 			}
1035 		}
1036 	}
1037 
1038 	/**
1039 	 * The ::move-words signal is a keybinding which gets emitted
1040 	 * when the user initiates moving a word. The default binding key
1041 	 * is Alt+Left/Right Arrow and moves the current selection, or the current
1042 	 * word by one word.
1043 	 *
1044 	 * Params:
1045 	 *     count = the number of words to move over
1046 	 *
1047 	 * Since: 3.0
1048 	 */
1049 	gulong addOnMoveWords(void delegate(int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1050 	{
1051 		auto wrapper = new OnMoveWordsDelegateWrapper(dlg);
1052 		wrapper.handlerId = Signals.connectData(
1053 			this,
1054 			"move-words",
1055 			cast(GCallback)&callBackMoveWords,
1056 			cast(void*)wrapper,
1057 			cast(GClosureNotify)&callBackMoveWordsDestroy,
1058 			connectFlags);
1059 		return wrapper.handlerId;
1060 	}
1061 	
1062 	extern(C) static void callBackMoveWords(GtkSourceView* sourceviewStruct, int count, OnMoveWordsDelegateWrapper wrapper)
1063 	{
1064 		wrapper.dlg(count, wrapper.outer);
1065 	}
1066 	
1067 	extern(C) static void callBackMoveWordsDestroy(OnMoveWordsDelegateWrapper wrapper, GClosure* closure)
1068 	{
1069 		wrapper.remove(wrapper);
1070 	}
1071 
1072 	protected class OnRedoDelegateWrapper
1073 	{
1074 		static OnRedoDelegateWrapper[] listeners;
1075 		void delegate(SourceView) dlg;
1076 		gulong handlerId;
1077 		
1078 		this(void delegate(SourceView) dlg)
1079 		{
1080 			this.dlg = dlg;
1081 			this.listeners ~= this;
1082 		}
1083 		
1084 		void remove(OnRedoDelegateWrapper source)
1085 		{
1086 			foreach(index, wrapper; listeners)
1087 			{
1088 				if (wrapper.handlerId == source.handlerId)
1089 				{
1090 					listeners[index] = null;
1091 					listeners = std.algorithm.remove(listeners, index);
1092 					break;
1093 				}
1094 			}
1095 		}
1096 	}
1097 
1098 	/** */
1099 	gulong addOnRedo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1100 	{
1101 		auto wrapper = new OnRedoDelegateWrapper(dlg);
1102 		wrapper.handlerId = Signals.connectData(
1103 			this,
1104 			"redo",
1105 			cast(GCallback)&callBackRedo,
1106 			cast(void*)wrapper,
1107 			cast(GClosureNotify)&callBackRedoDestroy,
1108 			connectFlags);
1109 		return wrapper.handlerId;
1110 	}
1111 	
1112 	extern(C) static void callBackRedo(GtkSourceView* sourceviewStruct, OnRedoDelegateWrapper wrapper)
1113 	{
1114 		wrapper.dlg(wrapper.outer);
1115 	}
1116 	
1117 	extern(C) static void callBackRedoDestroy(OnRedoDelegateWrapper wrapper, GClosure* closure)
1118 	{
1119 		wrapper.remove(wrapper);
1120 	}
1121 
1122 	protected class OnShowCompletionDelegateWrapper
1123 	{
1124 		static OnShowCompletionDelegateWrapper[] listeners;
1125 		void delegate(SourceView) dlg;
1126 		gulong handlerId;
1127 		
1128 		this(void delegate(SourceView) dlg)
1129 		{
1130 			this.dlg = dlg;
1131 			this.listeners ~= this;
1132 		}
1133 		
1134 		void remove(OnShowCompletionDelegateWrapper source)
1135 		{
1136 			foreach(index, wrapper; listeners)
1137 			{
1138 				if (wrapper.handlerId == source.handlerId)
1139 				{
1140 					listeners[index] = null;
1141 					listeners = std.algorithm.remove(listeners, index);
1142 					break;
1143 				}
1144 			}
1145 		}
1146 	}
1147 
1148 	/**
1149 	 * The ::show-completion signal is a key binding signal which gets
1150 	 * emitted when the user requests a completion, by pressing
1151 	 * <keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>.
1152 	 *
1153 	 * This will create a #GtkSourceCompletionContext with the activation
1154 	 * type as %GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED.
1155 	 *
1156 	 * Applications should not connect to it, but may emit it with
1157 	 * g_signal_emit_by_name() if they need to activate the completion by
1158 	 * another means, for example with another key binding or a menu entry.
1159 	 */
1160 	gulong addOnShowCompletion(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1161 	{
1162 		auto wrapper = new OnShowCompletionDelegateWrapper(dlg);
1163 		wrapper.handlerId = Signals.connectData(
1164 			this,
1165 			"show-completion",
1166 			cast(GCallback)&callBackShowCompletion,
1167 			cast(void*)wrapper,
1168 			cast(GClosureNotify)&callBackShowCompletionDestroy,
1169 			connectFlags);
1170 		return wrapper.handlerId;
1171 	}
1172 	
1173 	extern(C) static void callBackShowCompletion(GtkSourceView* sourceviewStruct, OnShowCompletionDelegateWrapper wrapper)
1174 	{
1175 		wrapper.dlg(wrapper.outer);
1176 	}
1177 	
1178 	extern(C) static void callBackShowCompletionDestroy(OnShowCompletionDelegateWrapper wrapper, GClosure* closure)
1179 	{
1180 		wrapper.remove(wrapper);
1181 	}
1182 
1183 	protected class OnSmartHomeEndDelegateWrapper
1184 	{
1185 		static OnSmartHomeEndDelegateWrapper[] listeners;
1186 		void delegate(TextIter, int, SourceView) dlg;
1187 		gulong handlerId;
1188 		
1189 		this(void delegate(TextIter, int, SourceView) dlg)
1190 		{
1191 			this.dlg = dlg;
1192 			this.listeners ~= this;
1193 		}
1194 		
1195 		void remove(OnSmartHomeEndDelegateWrapper source)
1196 		{
1197 			foreach(index, wrapper; listeners)
1198 			{
1199 				if (wrapper.handlerId == source.handlerId)
1200 				{
1201 					listeners[index] = null;
1202 					listeners = std.algorithm.remove(listeners, index);
1203 					break;
1204 				}
1205 			}
1206 		}
1207 	}
1208 
1209 	/**
1210 	 * Emitted when a the cursor was moved according to the smart home
1211 	 * end setting. The signal is emitted after the cursor is moved, but
1212 	 * during the GtkTextView::move-cursor action. This can be used to find
1213 	 * out whether the cursor was moved by a normal home/end or by a smart
1214 	 * home/end.
1215 	 *
1216 	 * Params:
1217 	 *     iter = a #GtkTextIter
1218 	 *     count = the count
1219 	 *
1220 	 * Since: 3.0
1221 	 */
1222 	gulong addOnSmartHomeEnd(void delegate(TextIter, int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1223 	{
1224 		auto wrapper = new OnSmartHomeEndDelegateWrapper(dlg);
1225 		wrapper.handlerId = Signals.connectData(
1226 			this,
1227 			"smart-home-end",
1228 			cast(GCallback)&callBackSmartHomeEnd,
1229 			cast(void*)wrapper,
1230 			cast(GClosureNotify)&callBackSmartHomeEndDestroy,
1231 			connectFlags);
1232 		return wrapper.handlerId;
1233 	}
1234 	
1235 	extern(C) static void callBackSmartHomeEnd(GtkSourceView* sourceviewStruct, GtkTextIter* iter, int count, OnSmartHomeEndDelegateWrapper wrapper)
1236 	{
1237 		wrapper.dlg(ObjectG.getDObject!(TextIter)(iter), count, wrapper.outer);
1238 	}
1239 	
1240 	extern(C) static void callBackSmartHomeEndDestroy(OnSmartHomeEndDelegateWrapper wrapper, GClosure* closure)
1241 	{
1242 		wrapper.remove(wrapper);
1243 	}
1244 
1245 	protected class OnUndoDelegateWrapper
1246 	{
1247 		static OnUndoDelegateWrapper[] listeners;
1248 		void delegate(SourceView) dlg;
1249 		gulong handlerId;
1250 		
1251 		this(void delegate(SourceView) dlg)
1252 		{
1253 			this.dlg = dlg;
1254 			this.listeners ~= this;
1255 		}
1256 		
1257 		void remove(OnUndoDelegateWrapper source)
1258 		{
1259 			foreach(index, wrapper; listeners)
1260 			{
1261 				if (wrapper.handlerId == source.handlerId)
1262 				{
1263 					listeners[index] = null;
1264 					listeners = std.algorithm.remove(listeners, index);
1265 					break;
1266 				}
1267 			}
1268 		}
1269 	}
1270 
1271 	/** */
1272 	gulong addOnUndo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1273 	{
1274 		auto wrapper = new OnUndoDelegateWrapper(dlg);
1275 		wrapper.handlerId = Signals.connectData(
1276 			this,
1277 			"undo",
1278 			cast(GCallback)&callBackUndo,
1279 			cast(void*)wrapper,
1280 			cast(GClosureNotify)&callBackUndoDestroy,
1281 			connectFlags);
1282 		return wrapper.handlerId;
1283 	}
1284 	
1285 	extern(C) static void callBackUndo(GtkSourceView* sourceviewStruct, OnUndoDelegateWrapper wrapper)
1286 	{
1287 		wrapper.dlg(wrapper.outer);
1288 	}
1289 	
1290 	extern(C) static void callBackUndoDestroy(OnUndoDelegateWrapper wrapper, GClosure* closure)
1291 	{
1292 		wrapper.remove(wrapper);
1293 	}
1294 }