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 pango.PgMiscellaneous; 26 27 private import core.stdc.stdio; 28 private import glib.Str; 29 private import glib.StringG; 30 private import glib.c.functions; 31 private import pango.c.functions; 32 public import pango.c.types; 33 34 35 /** */ 36 public struct PgMiscellaneous 37 { 38 39 /** 40 * Checks if a character that should not be normally rendered. 41 * 42 * This includes all Unicode characters with "ZERO WIDTH" in their name, 43 * as well as *bidi* formatting characters, and a few other ones. This is 44 * totally different from g_unichar_iszerowidth() and is at best misnamed. 45 * 46 * Params: 47 * ch = a Unicode character 48 * 49 * Returns: %TRUE if @ch is a zero-width character, %FALSE otherwise 50 * 51 * Since: 1.10 52 */ 53 public static bool isZeroWidth(dchar ch) 54 { 55 return pango_is_zero_width(ch) != 0; 56 } 57 58 /** 59 * Return the bidirectional embedding levels of the input paragraph. 60 * 61 * The bidirectional embedding levels are defined by the Unicode Bidirectional 62 * Algorithm available at: 63 * 64 * http://www.unicode.org/reports/tr9/ 65 * 66 * If the input base direction is a weak direction, the direction of the 67 * characters in the text will determine the final resolved direction. 68 * 69 * Params: 70 * text = the text to itemize. 71 * length = the number of bytes (not characters) to process, or -1 72 * if @text is nul-terminated and the length should be calculated. 73 * pbaseDir = input base direction, and output resolved direction. 74 * 75 * Returns: a newly allocated array of embedding levels, one item per 76 * character (not byte), that should be freed using g_free(). 77 * 78 * Since: 1.4 79 */ 80 public static ubyte* log2visGetEmbeddingLevels(string text, int length, PangoDirection* pbaseDir) 81 { 82 return pango_log2vis_get_embedding_levels(Str.toStringz(text), length, pbaseDir); 83 } 84 85 /** 86 * Parses an enum type and stores the result in @value. 87 * 88 * If @str does not match the nick name of any of the possible values for the 89 * enum and is not an integer, %FALSE is returned, a warning is issued 90 * if @warn is %TRUE, and a 91 * string representing the list of possible values is stored in 92 * @possible_values. The list is slash-separated, eg. 93 * "none/start/middle/end". If failed and @possible_values is not %NULL, 94 * returned string should be freed using g_free(). 95 * 96 * Params: 97 * type = enum type to parse, eg. %PANGO_TYPE_ELLIPSIZE_MODE. 98 * str = string to parse. May be %NULL. 99 * value = integer to store the result in, or %NULL. 100 * warn = if %TRUE, issue a g_warning() on bad input. 101 * possibleValues = place to store list of possible values on failure, or %NULL. 102 * 103 * Returns: %TRUE if @str was successfully parsed. 104 * 105 * Since: 1.16 106 */ 107 public static bool parseEnum(GType type, string str, out int value, bool warn, out string possibleValues) 108 { 109 char* outpossibleValues = null; 110 111 auto __p = pango_parse_enum(type, Str.toStringz(str), &value, warn, &outpossibleValues) != 0; 112 113 possibleValues = Str.toString(outpossibleValues); 114 115 return __p; 116 } 117 118 /** 119 * Parses a font stretch. 120 * 121 * The allowed values are 122 * "ultra_condensed", "extra_condensed", "condensed", 123 * "semi_condensed", "normal", "semi_expanded", "expanded", 124 * "extra_expanded" and "ultra_expanded". Case variations are 125 * ignored and the '_' characters may be omitted. 126 * 127 * Params: 128 * str = a string to parse. 129 * stretch = a `PangoStretch` to store the result in. 130 * warn = if %TRUE, issue a g_warning() on bad input. 131 * 132 * Returns: %TRUE if @str was successfully parsed. 133 */ 134 public static bool parseStretch(string str, out PangoStretch stretch, bool warn) 135 { 136 return pango_parse_stretch(Str.toStringz(str), &stretch, warn) != 0; 137 } 138 139 /** 140 * Parses a font style. 141 * 142 * The allowed values are "normal", "italic" and "oblique", case 143 * variations being 144 * ignored. 145 * 146 * Params: 147 * str = a string to parse. 148 * style = a `PangoStyle` to store the result in. 149 * warn = if %TRUE, issue a g_warning() on bad input. 150 * 151 * Returns: %TRUE if @str was successfully parsed. 152 */ 153 public static bool parseStyle(string str, out PangoStyle style, bool warn) 154 { 155 return pango_parse_style(Str.toStringz(str), &style, warn) != 0; 156 } 157 158 /** 159 * Parses a font variant. 160 * 161 * The allowed values are "normal" and "smallcaps" or "small_caps", 162 * case variations being ignored. 163 * 164 * Params: 165 * str = a string to parse. 166 * variant = a `PangoVariant` to store the result in. 167 * warn = if %TRUE, issue a g_warning() on bad input. 168 * 169 * Returns: %TRUE if @str was successfully parsed. 170 */ 171 public static bool parseVariant(string str, out PangoVariant variant, bool warn) 172 { 173 return pango_parse_variant(Str.toStringz(str), &variant, warn) != 0; 174 } 175 176 /** 177 * Parses a font weight. 178 * 179 * The allowed values are "heavy", 180 * "ultrabold", "bold", "normal", "light", "ultraleight" 181 * and integers. Case variations are ignored. 182 * 183 * Params: 184 * str = a string to parse. 185 * weight = a `PangoWeight` to store the result in. 186 * warn = if %TRUE, issue a g_warning() on bad input. 187 * 188 * Returns: %TRUE if @str was successfully parsed. 189 */ 190 public static bool parseWeight(string str, out PangoWeight weight, bool warn) 191 { 192 return pango_parse_weight(Str.toStringz(str), &weight, warn) != 0; 193 } 194 195 /** 196 * Quantizes the thickness and position of a line to whole device pixels. 197 * 198 * This is typically used for underline or strikethrough. The purpose of 199 * this function is to avoid such lines looking blurry. 200 * 201 * Care is taken to make sure @thickness is at least one pixel when this 202 * function returns, but returned @position may become zero as a result 203 * of rounding. 204 * 205 * Params: 206 * thickness = pointer to the thickness of a line, in Pango units 207 * position = corresponding position 208 * 209 * Since: 1.12 210 */ 211 public static void quantizeLineGeometry(ref int thickness, ref int position) 212 { 213 pango_quantize_line_geometry(&thickness, &position); 214 } 215 216 /** 217 * Scans an integer. 218 * 219 * Leading white space is skipped. 220 * 221 * Params: 222 * pos = in/out string position 223 * out_ = an int into which to write the result 224 * 225 * Returns: %FALSE if a parse error occurred. 226 */ 227 public static bool scanInt(ref string pos, out int out_) 228 { 229 char* outpos = Str.toStringz(pos); 230 231 auto __p = pango_scan_int(&outpos, &out_) != 0; 232 233 pos = Str.toString(outpos); 234 235 return __p; 236 } 237 238 /** 239 * Scans a string into a #GString buffer. 240 * 241 * The string may either be a sequence of non-white-space characters, 242 * or a quoted string with '"'. Instead a quoted string, '\"' represents 243 * a literal quote. Leading white space outside of quotes is skipped. 244 * 245 * Params: 246 * pos = in/out string position 247 * out_ = a #GString into which to write the result 248 * 249 * Returns: %FALSE if a parse error occurred. 250 */ 251 public static bool scanString(ref string pos, StringG out_) 252 { 253 char* outpos = Str.toStringz(pos); 254 255 auto __p = pango_scan_string(&outpos, (out_ is null) ? null : out_.getStringGStruct()) != 0; 256 257 pos = Str.toString(outpos); 258 259 return __p; 260 } 261 262 /** 263 * Scans a word into a #GString buffer. 264 * 265 * A word consists of [A-Za-z_] followed by zero or more 266 * [A-Za-z_0-9]. Leading white space is skipped. 267 * 268 * Params: 269 * pos = in/out string position 270 * out_ = a #GString into which to write the result 271 * 272 * Returns: %FALSE if a parse error occurred. 273 */ 274 public static bool scanWord(ref string pos, StringG out_) 275 { 276 char* outpos = Str.toStringz(pos); 277 278 auto __p = pango_scan_word(&outpos, (out_ is null) ? null : out_.getStringGStruct()) != 0; 279 280 pos = Str.toString(outpos); 281 282 return __p; 283 } 284 285 /** 286 * Skips 0 or more characters of white space. 287 * 288 * Params: 289 * pos = in/out string position 290 * 291 * Returns: %FALSE if skipping the white space leaves 292 * the position at a '\0' character. 293 */ 294 public static bool skipSpace(ref string pos) 295 { 296 char* outpos = Str.toStringz(pos); 297 298 auto __p = pango_skip_space(&outpos) != 0; 299 300 pos = Str.toString(outpos); 301 302 return __p; 303 } 304 305 /** 306 * Splits a %G_SEARCHPATH_SEPARATOR-separated list of files, stripping 307 * white space and substituting ~/ with $HOME/. 308 * 309 * Params: 310 * str = a %G_SEARCHPATH_SEPARATOR separated list of filenames 311 * 312 * Returns: a list of 313 * strings to be freed with g_strfreev() 314 */ 315 public static string[] splitFileList(string str) 316 { 317 auto retStr = pango_split_file_list(Str.toStringz(str)); 318 319 scope(exit) Str.freeStringArray(retStr); 320 return Str.toStringArray(retStr); 321 } 322 323 /** 324 * Trims leading and trailing whitespace from a string. 325 * 326 * Params: 327 * str = a string 328 * 329 * Returns: A newly-allocated string that must be freed with g_free() 330 */ 331 public static string trimString(string str) 332 { 333 auto retStr = pango_trim_string(Str.toStringz(str)); 334 335 scope(exit) Str.freeString(retStr); 336 return Str.toString(retStr); 337 } 338 339 /** 340 * Reads an entire line from a file into a buffer. 341 * 342 * Lines may be delimited with '\n', '\r', '\n\r', or '\r\n'. The delimiter 343 * is not written into the buffer. Text after a '#' character is treated as 344 * a comment and skipped. '\' can be used to escape a # character. 345 * '\' proceeding a line delimiter combines adjacent lines. A '\' proceeding 346 * any other character is ignored and written into the output buffer 347 * unmodified. 348 * 349 * Params: 350 * stream = a stdio stream 351 * str = #GString buffer into which to write the result 352 * 353 * Returns: 0 if the stream was already at an %EOF character, 354 * otherwise the number of lines read (this is useful for maintaining 355 * a line number counter which doesn't combine lines with '\') 356 */ 357 public static int readLine(FILE* stream, StringG str) 358 { 359 return pango_read_line(stream, (str is null) ? null : str.getStringGStruct()); 360 } 361 }