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.Utils;
26 
27 private import glib.Str;
28 private import gsv.c.functions;
29 public  import gsv.c.types;
30 public  import gsvc.gsvtypes;
31 
32 
33 /** */
34 public struct Utils
35 {
36 
37 	/**
38 	 * Free the resources allocated by GtkSourceView. For example it unrefs the
39 	 * singleton objects.
40 	 *
41 	 * It is not mandatory to call this function, it's just to be friendlier to
42 	 * memory debugging tools. This function is meant to be called at the end of
43 	 * main(). It can be called several times.
44 	 *
45 	 * Since: 4.0
46 	 */
47 	public static void finalize()
48 	{
49 		gtk_source_finalize();
50 	}
51 
52 	/**
53 	 * Initializes the GtkSourceView library (e.g. for the internationalization).
54 	 *
55 	 * This function can be called several times, but is meant to be called at the
56 	 * beginning of main(), before any other GtkSourceView function call.
57 	 *
58 	 * Since: 4.0
59 	 */
60 	public static void init()
61 	{
62 		gtk_source_init();
63 	}
64 
65 	/**
66 	 * Use this function to escape the following characters: `\n`, `\r`, `\t` and `\`.
67 	 *
68 	 * For a regular expression search, use g_regex_escape_string() instead.
69 	 *
70 	 * One possible use case is to take the #GtkTextBuffer's selection and put it in a
71 	 * search entry. The selection can contain tabulations, newlines, etc. So it's
72 	 * better to escape those special characters to better fit in the search entry.
73 	 *
74 	 * See also: gtk_source_utils_unescape_search_text().
75 	 *
76 	 * <warning>
77 	 * Warning: the escape and unescape functions are not reciprocal! For example,
78 	 * escape (unescape (\)) = \\. So avoid cycles such as: search entry -> unescape
79 	 * -> search settings -> escape -> search entry. The original search entry text
80 	 * may be modified.
81 	 * </warning>
82 	 *
83 	 * Params:
84 	 *     text = the text to escape.
85 	 *
86 	 * Returns: the escaped @text.
87 	 *
88 	 * Since: 3.10
89 	 */
90 	public static string escapeSearchText(string text)
91 	{
92 		auto retStr = gtk_source_utils_escape_search_text(Str.toStringz(text));
93 
94 		scope(exit) Str.freeString(retStr);
95 		return Str.toString(retStr);
96 	}
97 
98 	/**
99 	 * Use this function before gtk_source_search_settings_set_search_text(), to
100 	 * unescape the following sequences of characters: `\n`, `\r`, `\t` and `\\`.
101 	 * The purpose is to easily write those characters in a search entry.
102 	 *
103 	 * Note that unescaping the search text is not needed for regular expression
104 	 * searches.
105 	 *
106 	 * See also: gtk_source_utils_escape_search_text().
107 	 *
108 	 * Params:
109 	 *     text = the text to unescape.
110 	 *
111 	 * Returns: the unescaped @text.
112 	 *
113 	 * Since: 3.10
114 	 */
115 	public static string unescapeSearchText(string text)
116 	{
117 		auto retStr = gtk_source_utils_unescape_search_text(Str.toStringz(text));
118 
119 		scope(exit) Str.freeString(retStr);
120 		return Str.toString(retStr);
121 	}
122 }