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.SourceSearchContext;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import glib.ConstructionException;
30 private import glib.ErrorG;
31 private import glib.GException;
32 private import glib.MemorySlice;
33 private import glib.Str;
34 private import gobject.ObjectG;
35 private import gsv.SourceBuffer;
36 private import gsv.SourceSearchSettings;
37 private import gsv.SourceStyle;
38 private import gsv.c.functions;
39 public  import gsv.c.types;
40 public  import gsvc.gsvtypes;
41 private import gtk.TextIter;
42 
43 
44 /** */
45 public class SourceSearchContext : ObjectG
46 {
47 	/** the main Gtk struct */
48 	protected GtkSourceSearchContext* gtkSourceSearchContext;
49 
50 	/** Get the main Gtk struct */
51 	public GtkSourceSearchContext* getSourceSearchContextStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return gtkSourceSearchContext;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkSourceSearchContext;
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (GtkSourceSearchContext* gtkSourceSearchContext, bool ownedRef = false)
68 	{
69 		this.gtkSourceSearchContext = gtkSourceSearchContext;
70 		super(cast(GObject*)gtkSourceSearchContext, ownedRef);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return gtk_source_search_context_get_type();
78 	}
79 
80 	/**
81 	 * Creates a new search context, associated with @buffer, and customized with
82 	 * @settings. If @settings is %NULL, a new #GtkSourceSearchSettings object will
83 	 * be created, that you can retrieve with
84 	 * gtk_source_search_context_get_settings().
85 	 *
86 	 * Params:
87 	 *     buffer = a #GtkSourceBuffer.
88 	 *     settings = a #GtkSourceSearchSettings, or %NULL.
89 	 *
90 	 * Returns: a new search context.
91 	 *
92 	 * Since: 3.10
93 	 *
94 	 * Throws: ConstructionException GTK+ fails to create the object.
95 	 */
96 	public this(SourceBuffer buffer, SourceSearchSettings settings)
97 	{
98 		auto p = gtk_source_search_context_new((buffer is null) ? null : buffer.getSourceBufferStruct(), (settings is null) ? null : settings.getSourceSearchSettingsStruct());
99 
100 		if(p is null)
101 		{
102 			throw new ConstructionException("null returned by new");
103 		}
104 
105 		this(cast(GtkSourceSearchContext*) p, true);
106 	}
107 
108 	/**
109 	 * Synchronous backward search. It is recommended to use the asynchronous
110 	 * functions instead, to not block the user interface. However, if you are sure
111 	 * that the @buffer is small, this function is more convenient to use.
112 	 *
113 	 * Deprecated: Use gtk_source_search_context_backward2() instead.
114 	 *
115 	 * Params:
116 	 *     iter = start of search.
117 	 *     matchStart = return location for start of match, or %NULL.
118 	 *     matchEnd = return location for end of match, or %NULL.
119 	 *
120 	 * Returns: whether a match was found.
121 	 *
122 	 * Since: 3.10
123 	 */
124 	public bool backward(TextIter iter, out TextIter matchStart, out TextIter matchEnd)
125 	{
126 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
127 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
128 
129 		auto p = gtk_source_search_context_backward(gtkSourceSearchContext, (iter is null) ? null : iter.getTextIterStruct(), outmatchStart, outmatchEnd) != 0;
130 
131 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
132 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
133 
134 		return p;
135 	}
136 
137 	/**
138 	 * Synchronous backward search. It is recommended to use the asynchronous
139 	 * functions instead, to not block the user interface. However, if you are sure
140 	 * that the @buffer is small, this function is more convenient to use.
141 	 *
142 	 * The difference with gtk_source_search_context_backward() is that the
143 	 * @has_wrapped_around out parameter has been added for convenience.
144 	 *
145 	 * If the #GtkSourceSearchSettings:wrap-around property is %FALSE, this function
146 	 * doesn't try to wrap around.
147 	 *
148 	 * The @has_wrapped_around out parameter is set independently of whether a match
149 	 * is found. So if this function returns %FALSE, @has_wrapped_around will have
150 	 * the same value as the #GtkSourceSearchSettings:wrap-around property.
151 	 *
152 	 * Params:
153 	 *     iter = start of search.
154 	 *     matchStart = return location for start of match, or %NULL.
155 	 *     matchEnd = return location for end of match, or %NULL.
156 	 *     hasWrappedAround = return location to know whether the
157 	 *         search has wrapped around, or %NULL.
158 	 *
159 	 * Returns: whether a match was found.
160 	 *
161 	 * Since: 3.22
162 	 */
163 	public bool backward2(TextIter iter, out TextIter matchStart, out TextIter matchEnd, out bool hasWrappedAround)
164 	{
165 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
166 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
167 		int outhasWrappedAround;
168 
169 		auto p = gtk_source_search_context_backward2(gtkSourceSearchContext, (iter is null) ? null : iter.getTextIterStruct(), outmatchStart, outmatchEnd, &outhasWrappedAround) != 0;
170 
171 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
172 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
173 		hasWrappedAround = (outhasWrappedAround == 1);
174 
175 		return p;
176 	}
177 
178 	/**
179 	 * The asynchronous version of gtk_source_search_context_backward2().
180 	 *
181 	 * See the documentation of gtk_source_search_context_backward2() for more
182 	 * details.
183 	 *
184 	 * See the #GAsyncResult documentation to know how to use this function.
185 	 *
186 	 * If the operation is cancelled, the @callback will only be called if
187 	 * @cancellable was not %NULL. gtk_source_search_context_backward_async() takes
188 	 * ownership of @cancellable, so you can unref it after calling this function.
189 	 *
190 	 * Params:
191 	 *     iter = start of search.
192 	 *     cancellable = a #GCancellable, or %NULL.
193 	 *     callback = a #GAsyncReadyCallback to call when the operation is finished.
194 	 *     userData = the data to pass to the @callback function.
195 	 *
196 	 * Since: 3.10
197 	 */
198 	public void backwardAsync(TextIter iter, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
199 	{
200 		gtk_source_search_context_backward_async(gtkSourceSearchContext, (iter is null) ? null : iter.getTextIterStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
201 	}
202 
203 	/**
204 	 * Finishes a backward search started with
205 	 * gtk_source_search_context_backward_async().
206 	 *
207 	 * Deprecated: Use gtk_source_search_context_backward_finish2() instead.
208 	 *
209 	 * Params:
210 	 *     result = a #GAsyncResult.
211 	 *     matchStart = return location for start of match, or %NULL.
212 	 *     matchEnd = return location for end of match, or %NULL.
213 	 *
214 	 * Returns: whether a match was found.
215 	 *
216 	 * Since: 3.10
217 	 *
218 	 * Throws: GException on failure.
219 	 */
220 	public bool backwardFinish(AsyncResultIF result, out TextIter matchStart, out TextIter matchEnd)
221 	{
222 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
223 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
224 		GError* err = null;
225 
226 		auto p = gtk_source_search_context_backward_finish(gtkSourceSearchContext, (result is null) ? null : result.getAsyncResultStruct(), outmatchStart, outmatchEnd, &err) != 0;
227 
228 		if (err !is null)
229 		{
230 			throw new GException( new ErrorG(err) );
231 		}
232 
233 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
234 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
235 
236 		return p;
237 	}
238 
239 	/**
240 	 * Finishes a backward search started with
241 	 * gtk_source_search_context_backward_async().
242 	 *
243 	 * See the documentation of gtk_source_search_context_backward2() for more
244 	 * details.
245 	 *
246 	 * Params:
247 	 *     result = a #GAsyncResult.
248 	 *     matchStart = return location for start of match, or %NULL.
249 	 *     matchEnd = return location for end of match, or %NULL.
250 	 *     hasWrappedAround = return location to know whether the
251 	 *         search has wrapped around, or %NULL.
252 	 *
253 	 * Returns: whether a match was found.
254 	 *
255 	 * Since: 3.22
256 	 *
257 	 * Throws: GException on failure.
258 	 */
259 	public bool backwardFinish2(AsyncResultIF result, out TextIter matchStart, out TextIter matchEnd, out bool hasWrappedAround)
260 	{
261 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
262 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
263 		int outhasWrappedAround;
264 		GError* err = null;
265 
266 		auto p = gtk_source_search_context_backward_finish2(gtkSourceSearchContext, (result is null) ? null : result.getAsyncResultStruct(), outmatchStart, outmatchEnd, &outhasWrappedAround, &err) != 0;
267 
268 		if (err !is null)
269 		{
270 			throw new GException( new ErrorG(err) );
271 		}
272 
273 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
274 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
275 		hasWrappedAround = (outhasWrappedAround == 1);
276 
277 		return p;
278 	}
279 
280 	/**
281 	 * Synchronous forward search. It is recommended to use the asynchronous
282 	 * functions instead, to not block the user interface. However, if you are sure
283 	 * that the @buffer is small, this function is more convenient to use.
284 	 *
285 	 * Deprecated: Use gtk_source_search_context_forward2() instead.
286 	 *
287 	 * Params:
288 	 *     iter = start of search.
289 	 *     matchStart = return location for start of match, or %NULL.
290 	 *     matchEnd = return location for end of match, or %NULL.
291 	 *
292 	 * Returns: whether a match was found.
293 	 *
294 	 * Since: 3.10
295 	 */
296 	public bool forward(TextIter iter, out TextIter matchStart, out TextIter matchEnd)
297 	{
298 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
299 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
300 
301 		auto p = gtk_source_search_context_forward(gtkSourceSearchContext, (iter is null) ? null : iter.getTextIterStruct(), outmatchStart, outmatchEnd) != 0;
302 
303 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
304 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
305 
306 		return p;
307 	}
308 
309 	/**
310 	 * Synchronous forward search. It is recommended to use the asynchronous
311 	 * functions instead, to not block the user interface. However, if you are sure
312 	 * that the @buffer is small, this function is more convenient to use.
313 	 *
314 	 * The difference with gtk_source_search_context_forward() is that the
315 	 * @has_wrapped_around out parameter has been added for convenience.
316 	 *
317 	 * If the #GtkSourceSearchSettings:wrap-around property is %FALSE, this function
318 	 * doesn't try to wrap around.
319 	 *
320 	 * The @has_wrapped_around out parameter is set independently of whether a match
321 	 * is found. So if this function returns %FALSE, @has_wrapped_around will have
322 	 * the same value as the #GtkSourceSearchSettings:wrap-around property.
323 	 *
324 	 * Params:
325 	 *     iter = start of search.
326 	 *     matchStart = return location for start of match, or %NULL.
327 	 *     matchEnd = return location for end of match, or %NULL.
328 	 *     hasWrappedAround = return location to know whether the
329 	 *         search has wrapped around, or %NULL.
330 	 *
331 	 * Returns: whether a match was found.
332 	 *
333 	 * Since: 3.22
334 	 */
335 	public bool forward2(TextIter iter, out TextIter matchStart, out TextIter matchEnd, out bool hasWrappedAround)
336 	{
337 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
338 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
339 		int outhasWrappedAround;
340 
341 		auto p = gtk_source_search_context_forward2(gtkSourceSearchContext, (iter is null) ? null : iter.getTextIterStruct(), outmatchStart, outmatchEnd, &outhasWrappedAround) != 0;
342 
343 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
344 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
345 		hasWrappedAround = (outhasWrappedAround == 1);
346 
347 		return p;
348 	}
349 
350 	/**
351 	 * The asynchronous version of gtk_source_search_context_forward2().
352 	 *
353 	 * See the documentation of gtk_source_search_context_forward2() for more
354 	 * details.
355 	 *
356 	 * See the #GAsyncResult documentation to know how to use this function.
357 	 *
358 	 * If the operation is cancelled, the @callback will only be called if
359 	 * @cancellable was not %NULL. gtk_source_search_context_forward_async() takes
360 	 * ownership of @cancellable, so you can unref it after calling this function.
361 	 *
362 	 * Params:
363 	 *     iter = start of search.
364 	 *     cancellable = a #GCancellable, or %NULL.
365 	 *     callback = a #GAsyncReadyCallback to call when the operation is finished.
366 	 *     userData = the data to pass to the @callback function.
367 	 *
368 	 * Since: 3.10
369 	 */
370 	public void forwardAsync(TextIter iter, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
371 	{
372 		gtk_source_search_context_forward_async(gtkSourceSearchContext, (iter is null) ? null : iter.getTextIterStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
373 	}
374 
375 	/**
376 	 * Finishes a forward search started with
377 	 * gtk_source_search_context_forward_async().
378 	 *
379 	 * Deprecated: Use gtk_source_search_context_forward_finish2() instead.
380 	 *
381 	 * Params:
382 	 *     result = a #GAsyncResult.
383 	 *     matchStart = return location for start of match, or %NULL.
384 	 *     matchEnd = return location for end of match, or %NULL.
385 	 *
386 	 * Returns: whether a match was found.
387 	 *
388 	 * Since: 3.10
389 	 *
390 	 * Throws: GException on failure.
391 	 */
392 	public bool forwardFinish(AsyncResultIF result, out TextIter matchStart, out TextIter matchEnd)
393 	{
394 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
395 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
396 		GError* err = null;
397 
398 		auto p = gtk_source_search_context_forward_finish(gtkSourceSearchContext, (result is null) ? null : result.getAsyncResultStruct(), outmatchStart, outmatchEnd, &err) != 0;
399 
400 		if (err !is null)
401 		{
402 			throw new GException( new ErrorG(err) );
403 		}
404 
405 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
406 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
407 
408 		return p;
409 	}
410 
411 	/**
412 	 * Finishes a forward search started with
413 	 * gtk_source_search_context_forward_async().
414 	 *
415 	 * See the documentation of gtk_source_search_context_forward2() for more
416 	 * details.
417 	 *
418 	 * Params:
419 	 *     result = a #GAsyncResult.
420 	 *     matchStart = return location for start of match, or %NULL.
421 	 *     matchEnd = return location for end of match, or %NULL.
422 	 *     hasWrappedAround = return location to know whether the
423 	 *         search has wrapped around, or %NULL.
424 	 *
425 	 * Returns: whether a match was found.
426 	 *
427 	 * Since: 3.22
428 	 *
429 	 * Throws: GException on failure.
430 	 */
431 	public bool forwardFinish2(AsyncResultIF result, out TextIter matchStart, out TextIter matchEnd, out bool hasWrappedAround)
432 	{
433 		GtkTextIter* outmatchStart = sliceNew!GtkTextIter();
434 		GtkTextIter* outmatchEnd = sliceNew!GtkTextIter();
435 		int outhasWrappedAround;
436 		GError* err = null;
437 
438 		auto p = gtk_source_search_context_forward_finish2(gtkSourceSearchContext, (result is null) ? null : result.getAsyncResultStruct(), outmatchStart, outmatchEnd, &outhasWrappedAround, &err) != 0;
439 
440 		if (err !is null)
441 		{
442 			throw new GException( new ErrorG(err) );
443 		}
444 
445 		matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true);
446 		matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true);
447 		hasWrappedAround = (outhasWrappedAround == 1);
448 
449 		return p;
450 	}
451 
452 	/**
453 	 * Returns: the associated buffer.
454 	 *
455 	 * Since: 3.10
456 	 */
457 	public SourceBuffer getBuffer()
458 	{
459 		auto p = gtk_source_search_context_get_buffer(gtkSourceSearchContext);
460 
461 		if(p is null)
462 		{
463 			return null;
464 		}
465 
466 		return ObjectG.getDObject!(SourceBuffer)(cast(GtkSourceBuffer*) p);
467 	}
468 
469 	/**
470 	 * Returns: whether to highlight the search occurrences.
471 	 *
472 	 * Since: 3.10
473 	 */
474 	public bool getHighlight()
475 	{
476 		return gtk_source_search_context_get_highlight(gtkSourceSearchContext) != 0;
477 	}
478 
479 	/**
480 	 * Returns: the #GtkSourceStyle to apply on search matches.
481 	 *
482 	 * Since: 3.16
483 	 */
484 	public SourceStyle getMatchStyle()
485 	{
486 		auto p = gtk_source_search_context_get_match_style(gtkSourceSearchContext);
487 
488 		if(p is null)
489 		{
490 			return null;
491 		}
492 
493 		return ObjectG.getDObject!(SourceStyle)(cast(GtkSourceStyle*) p);
494 	}
495 
496 	/**
497 	 * Gets the position of a search occurrence. If the buffer is not already fully
498 	 * scanned, the position may be unknown, and -1 is returned. If 0 is returned,
499 	 * it means that this part of the buffer has already been scanned, and that
500 	 * @match_start and @match_end don't delimit an occurrence.
501 	 *
502 	 * Params:
503 	 *     matchStart = the start of the occurrence.
504 	 *     matchEnd = the end of the occurrence.
505 	 *
506 	 * Returns: the position of the search occurrence. The first occurrence has the
507 	 *     position 1 (not 0). Returns 0 if @match_start and @match_end don't delimit
508 	 *     an occurrence. Returns -1 if the position is not yet known.
509 	 *
510 	 * Since: 3.10
511 	 */
512 	public int getOccurrencePosition(TextIter matchStart, TextIter matchEnd)
513 	{
514 		return gtk_source_search_context_get_occurrence_position(gtkSourceSearchContext, (matchStart is null) ? null : matchStart.getTextIterStruct(), (matchEnd is null) ? null : matchEnd.getTextIterStruct());
515 	}
516 
517 	/**
518 	 * Gets the total number of search occurrences. If the buffer is not already
519 	 * fully scanned, the total number of occurrences is unknown, and -1 is
520 	 * returned.
521 	 *
522 	 * Returns: the total number of search occurrences, or -1 if unknown.
523 	 *
524 	 * Since: 3.10
525 	 */
526 	public int getOccurrencesCount()
527 	{
528 		return gtk_source_search_context_get_occurrences_count(gtkSourceSearchContext);
529 	}
530 
531 	/**
532 	 * Regular expression patterns must follow certain rules. If
533 	 * #GtkSourceSearchSettings:search-text breaks a rule, the error can be retrieved
534 	 * with this function. The error domain is #G_REGEX_ERROR.
535 	 *
536 	 * Free the return value with g_error_free().
537 	 *
538 	 * Returns: the #GError, or %NULL if the pattern is valid.
539 	 *
540 	 * Since: 3.10
541 	 */
542 	public ErrorG getRegexError()
543 	{
544 		auto p = gtk_source_search_context_get_regex_error(gtkSourceSearchContext);
545 
546 		if(p is null)
547 		{
548 			return null;
549 		}
550 
551 		return new ErrorG(cast(GError*) p, true);
552 	}
553 
554 	/**
555 	 * Returns: the search settings.
556 	 *
557 	 * Since: 3.10
558 	 */
559 	public SourceSearchSettings getSettings()
560 	{
561 		auto p = gtk_source_search_context_get_settings(gtkSourceSearchContext);
562 
563 		if(p is null)
564 		{
565 			return null;
566 		}
567 
568 		return ObjectG.getDObject!(SourceSearchSettings)(cast(GtkSourceSearchSettings*) p);
569 	}
570 
571 	/**
572 	 * Replaces a search match by another text. If @match_start and @match_end
573 	 * doesn't correspond to a search match, %FALSE is returned.
574 	 *
575 	 * For a regular expression replacement, you can check if @replace is valid by
576 	 * calling g_regex_check_replacement(). The @replace text can contain
577 	 * backreferences; read the g_regex_replace() documentation for more details.
578 	 *
579 	 * Deprecated: Use gtk_source_search_context_replace2() instead.
580 	 *
581 	 * Params:
582 	 *     matchStart = the start of the match to replace.
583 	 *     matchEnd = the end of the match to replace.
584 	 *     replace = the replacement text.
585 	 *     replaceLength = the length of @replace in bytes, or -1.
586 	 *
587 	 * Returns: whether the match has been replaced.
588 	 *
589 	 * Since: 3.10
590 	 *
591 	 * Throws: GException on failure.
592 	 */
593 	public bool replace(TextIter matchStart, TextIter matchEnd, string replace, int replaceLength)
594 	{
595 		GError* err = null;
596 
597 		auto p = gtk_source_search_context_replace(gtkSourceSearchContext, (matchStart is null) ? null : matchStart.getTextIterStruct(), (matchEnd is null) ? null : matchEnd.getTextIterStruct(), Str.toStringz(replace), replaceLength, &err) != 0;
598 
599 		if (err !is null)
600 		{
601 			throw new GException( new ErrorG(err) );
602 		}
603 
604 		return p;
605 	}
606 
607 	/**
608 	 * Replaces a search match by another text. If @match_start and @match_end
609 	 * doesn't correspond to a search match, %FALSE is returned.
610 	 *
611 	 * Unlike with gtk_source_search_context_replace(), the @match_start and
612 	 * @match_end iters are revalidated to point to the replacement text boundaries.
613 	 *
614 	 * For a regular expression replacement, you can check if @replace is valid by
615 	 * calling g_regex_check_replacement(). The @replace text can contain
616 	 * backreferences; read the g_regex_replace() documentation for more details.
617 	 *
618 	 * Params:
619 	 *     matchStart = the start of the match to replace.
620 	 *     matchEnd = the end of the match to replace.
621 	 *     replace = the replacement text.
622 	 *     replaceLength = the length of @replace in bytes, or -1.
623 	 *
624 	 * Returns: whether the match has been replaced.
625 	 *
626 	 * Since: 3.22
627 	 *
628 	 * Throws: GException on failure.
629 	 */
630 	public bool replace2(TextIter matchStart, TextIter matchEnd, string replace, int replaceLength)
631 	{
632 		GError* err = null;
633 
634 		auto p = gtk_source_search_context_replace2(gtkSourceSearchContext, (matchStart is null) ? null : matchStart.getTextIterStruct(), (matchEnd is null) ? null : matchEnd.getTextIterStruct(), Str.toStringz(replace), replaceLength, &err) != 0;
635 
636 		if (err !is null)
637 		{
638 			throw new GException( new ErrorG(err) );
639 		}
640 
641 		return p;
642 	}
643 
644 	/**
645 	 * Replaces all search matches by another text. It is a synchronous function, so
646 	 * it can block the user interface.
647 	 *
648 	 * For a regular expression replacement, you can check if @replace is valid by
649 	 * calling g_regex_check_replacement(). The @replace text can contain
650 	 * backreferences; read the g_regex_replace() documentation for more details.
651 	 *
652 	 * Params:
653 	 *     replace = the replacement text.
654 	 *     replaceLength = the length of @replace in bytes, or -1.
655 	 *
656 	 * Returns: the number of replaced matches.
657 	 *
658 	 * Since: 3.10
659 	 *
660 	 * Throws: GException on failure.
661 	 */
662 	public uint replaceAll(string replace, int replaceLength)
663 	{
664 		GError* err = null;
665 
666 		auto p = gtk_source_search_context_replace_all(gtkSourceSearchContext, Str.toStringz(replace), replaceLength, &err);
667 
668 		if (err !is null)
669 		{
670 			throw new GException( new ErrorG(err) );
671 		}
672 
673 		return p;
674 	}
675 
676 	/**
677 	 * Enables or disables the search occurrences highlighting.
678 	 *
679 	 * Params:
680 	 *     highlight = the setting.
681 	 *
682 	 * Since: 3.10
683 	 */
684 	public void setHighlight(bool highlight)
685 	{
686 		gtk_source_search_context_set_highlight(gtkSourceSearchContext, highlight);
687 	}
688 
689 	/**
690 	 * Set the style to apply on search matches. If @match_style is %NULL, default
691 	 * theme's scheme 'match-style' will be used.
692 	 * To enable or disable the search highlighting, use
693 	 * gtk_source_search_context_set_highlight().
694 	 *
695 	 * Params:
696 	 *     matchStyle = a #GtkSourceStyle, or %NULL.
697 	 *
698 	 * Since: 3.16
699 	 */
700 	public void setMatchStyle(SourceStyle matchStyle)
701 	{
702 		gtk_source_search_context_set_match_style(gtkSourceSearchContext, (matchStyle is null) ? null : matchStyle.getSourceStyleStruct());
703 	}
704 
705 	/**
706 	 * Associate a #GtkSourceSearchSettings with the search context. If @settings is
707 	 * %NULL, a new one will be created.
708 	 *
709 	 * The search context holds a reference to @settings.
710 	 *
711 	 * Deprecated: The #GtkSourceSearchContext:settings property will become a
712 	 * construct-only property in a future version. Create a new
713 	 * #GtkSourceSearchContext instead, or change the #GtkSourceSearchSettings
714 	 * properties. When the #GtkSourceSearchContext:settings property will become
715 	 * construct-only, it will be possible to simplify some code that needed to
716 	 * listen to the notify::settings signal.
717 	 *
718 	 * Params:
719 	 *     settings = the new #GtkSourceSearchSettings, or %NULL.
720 	 *
721 	 * Since: 3.10
722 	 */
723 	public void setSettings(SourceSearchSettings settings)
724 	{
725 		gtk_source_search_context_set_settings(gtkSourceSearchContext, (settings is null) ? null : settings.getSourceSearchSettingsStruct());
726 	}
727 }