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 gtk.TextIter; 26 27 private import gdkpixbuf.Pixbuf; 28 private import glib.ListSG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gtk.TextAttributes; 32 private import gtk.TextBuffer; 33 private import gtk.TextChildAnchor; 34 private import gtk.TextTag; 35 private import gtk.c.functions; 36 public import gtk.c.types; 37 public import gtkc.gtktypes; 38 private import gtkd.Loader; 39 private import pango.PgLanguage; 40 41 42 /** 43 * You may wish to begin by reading the 44 * [text widget conceptual overview][TextWidget] 45 * which gives an overview of all the objects and data 46 * types related to the text widget and how they work together. 47 */ 48 public class TextIter 49 { 50 /** the main Gtk struct */ 51 protected GtkTextIter* gtkTextIter; 52 protected bool ownedRef; 53 54 /** Get the main Gtk struct */ 55 public GtkTextIter* getTextIterStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gtkTextIter; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected void* getStruct() 64 { 65 return cast(void*)gtkTextIter; 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkTextIter* gtkTextIter, bool ownedRef = false) 72 { 73 this.gtkTextIter = gtkTextIter; 74 this.ownedRef = ownedRef; 75 } 76 77 ~this () 78 { 79 if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef ) 80 gtk_text_iter_free(gtkTextIter); 81 } 82 83 /** */ 84 public this() 85 { 86 this(new GtkTextIter); 87 } 88 89 /** 90 */ 91 92 /** */ 93 public static GType getType() 94 { 95 return gtk_text_iter_get_type(); 96 } 97 98 /** 99 * Assigns the value of @other to @iter. This function 100 * is not useful in applications, because iterators can be assigned 101 * with `GtkTextIter i = j;`. The 102 * function is used by language bindings. 103 * 104 * Params: 105 * other = another #GtkTextIter 106 * 107 * Since: 3.2 108 */ 109 public void assign(TextIter other) 110 { 111 gtk_text_iter_assign(gtkTextIter, (other is null) ? null : other.getTextIterStruct()); 112 } 113 114 /** 115 * Moves backward by one character offset. Returns %TRUE if movement 116 * was possible; if @iter was the first in the buffer (character 117 * offset 0), gtk_text_iter_backward_char() returns %FALSE for convenience when 118 * writing loops. 119 * 120 * Returns: whether movement was possible 121 */ 122 public bool backwardChar() 123 { 124 return gtk_text_iter_backward_char(gtkTextIter) != 0; 125 } 126 127 /** 128 * Moves @count characters backward, if possible (if @count would move 129 * past the start or end of the buffer, moves to the start or end of 130 * the buffer). The return value indicates whether the iterator moved 131 * onto a dereferenceable position; if the iterator didn’t move, or 132 * moved onto the end iterator, then %FALSE is returned. If @count is 0, 133 * the function does nothing and returns %FALSE. 134 * 135 * Params: 136 * count = number of characters to move 137 * 138 * Returns: whether @iter moved and is dereferenceable 139 */ 140 public bool backwardChars(int count) 141 { 142 return gtk_text_iter_backward_chars(gtkTextIter, count) != 0; 143 } 144 145 /** 146 * Like gtk_text_iter_forward_cursor_position(), but moves backward. 147 * 148 * Returns: %TRUE if we moved 149 */ 150 public bool backwardCursorPosition() 151 { 152 return gtk_text_iter_backward_cursor_position(gtkTextIter) != 0; 153 } 154 155 /** 156 * Moves up to @count cursor positions. See 157 * gtk_text_iter_forward_cursor_position() for details. 158 * 159 * Params: 160 * count = number of positions to move 161 * 162 * Returns: %TRUE if we moved and the new position is dereferenceable 163 */ 164 public bool backwardCursorPositions(int count) 165 { 166 return gtk_text_iter_backward_cursor_positions(gtkTextIter, count) != 0; 167 } 168 169 /** 170 * Same as gtk_text_iter_forward_find_char(), but goes backward from @iter. 171 * 172 * Params: 173 * pred = function to be called on each character 174 * userData = user data for @pred 175 * limit = search limit, or %NULL for none 176 * 177 * Returns: whether a match was found 178 */ 179 public bool backwardFindChar(GtkTextCharPredicate pred, void* userData, TextIter limit) 180 { 181 return gtk_text_iter_backward_find_char(gtkTextIter, pred, userData, (limit is null) ? null : limit.getTextIterStruct()) != 0; 182 } 183 184 /** 185 * Moves @iter to the start of the previous line. Returns %TRUE if 186 * @iter could be moved; i.e. if @iter was at character offset 0, this 187 * function returns %FALSE. Therefore if @iter was already on line 0, 188 * but not at the start of the line, @iter is snapped to the start of 189 * the line and the function returns %TRUE. (Note that this implies that 190 * in a loop calling this function, the line number may not change on 191 * every iteration, if your first iteration is on line 0.) 192 * 193 * Returns: whether @iter moved 194 */ 195 public bool backwardLine() 196 { 197 return gtk_text_iter_backward_line(gtkTextIter) != 0; 198 } 199 200 /** 201 * Moves @count lines backward, if possible (if @count would move 202 * past the start or end of the buffer, moves to the start or end of 203 * the buffer). The return value indicates whether the iterator moved 204 * onto a dereferenceable position; if the iterator didn’t move, or 205 * moved onto the end iterator, then %FALSE is returned. If @count is 0, 206 * the function does nothing and returns %FALSE. If @count is negative, 207 * moves forward by 0 - @count lines. 208 * 209 * Params: 210 * count = number of lines to move backward 211 * 212 * Returns: whether @iter moved and is dereferenceable 213 */ 214 public bool backwardLines(int count) 215 { 216 return gtk_text_iter_backward_lines(gtkTextIter, count) != 0; 217 } 218 219 /** 220 * Same as gtk_text_iter_forward_search(), but moves backward. 221 * 222 * @match_end will never be set to a #GtkTextIter located after @iter, even if 223 * there is a possible @match_start before or at @iter. 224 * 225 * Params: 226 * str = search string 227 * flags = bitmask of flags affecting the search 228 * matchStart = return location for start of match, or %NULL 229 * matchEnd = return location for end of match, or %NULL 230 * limit = location of last possible @match_start, or %NULL for start of buffer 231 * 232 * Returns: whether a match was found 233 */ 234 public bool backwardSearch(string str, GtkTextSearchFlags flags, out TextIter matchStart, out TextIter matchEnd, TextIter limit) 235 { 236 GtkTextIter* outmatchStart = gMalloc!GtkTextIter(); 237 GtkTextIter* outmatchEnd = gMalloc!GtkTextIter(); 238 239 auto p = gtk_text_iter_backward_search(gtkTextIter, Str.toStringz(str), flags, outmatchStart, outmatchEnd, (limit is null) ? null : limit.getTextIterStruct()) != 0; 240 241 matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true); 242 matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true); 243 244 return p; 245 } 246 247 /** 248 * Moves backward to the previous sentence start; if @iter is already at 249 * the start of a sentence, moves backward to the next one. Sentence 250 * boundaries are determined by Pango and should be correct for nearly 251 * any language (if not, the correct fix would be to the Pango text 252 * boundary algorithms). 253 * 254 * Returns: %TRUE if @iter moved and is not the end iterator 255 */ 256 public bool backwardSentenceStart() 257 { 258 return gtk_text_iter_backward_sentence_start(gtkTextIter) != 0; 259 } 260 261 /** 262 * Calls gtk_text_iter_backward_sentence_start() up to @count times, 263 * or until it returns %FALSE. If @count is negative, moves forward 264 * instead of backward. 265 * 266 * Params: 267 * count = number of sentences to move 268 * 269 * Returns: %TRUE if @iter moved and is not the end iterator 270 */ 271 public bool backwardSentenceStarts(int count) 272 { 273 return gtk_text_iter_backward_sentence_starts(gtkTextIter, count) != 0; 274 } 275 276 /** 277 * Moves backward to the next toggle (on or off) of the 278 * #GtkTextTag @tag, or to the next toggle of any tag if 279 * @tag is %NULL. If no matching tag toggles are found, 280 * returns %FALSE, otherwise %TRUE. Does not return toggles 281 * located at @iter, only toggles before @iter. Sets @iter 282 * to the location of the toggle, or the start of the buffer 283 * if no toggle is found. 284 * 285 * Params: 286 * tag = a #GtkTextTag, or %NULL 287 * 288 * Returns: whether we found a tag toggle before @iter 289 */ 290 public bool backwardToTagToggle(TextTag tag) 291 { 292 return gtk_text_iter_backward_to_tag_toggle(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 293 } 294 295 /** 296 * Moves @iter forward to the previous visible cursor position. See 297 * gtk_text_iter_backward_cursor_position() for details. 298 * 299 * Returns: %TRUE if we moved and the new position is dereferenceable 300 * 301 * Since: 2.4 302 */ 303 public bool backwardVisibleCursorPosition() 304 { 305 return gtk_text_iter_backward_visible_cursor_position(gtkTextIter) != 0; 306 } 307 308 /** 309 * Moves up to @count visible cursor positions. See 310 * gtk_text_iter_backward_cursor_position() for details. 311 * 312 * Params: 313 * count = number of positions to move 314 * 315 * Returns: %TRUE if we moved and the new position is dereferenceable 316 * 317 * Since: 2.4 318 */ 319 public bool backwardVisibleCursorPositions(int count) 320 { 321 return gtk_text_iter_backward_visible_cursor_positions(gtkTextIter, count) != 0; 322 } 323 324 /** 325 * Moves @iter to the start of the previous visible line. Returns %TRUE if 326 * @iter could be moved; i.e. if @iter was at character offset 0, this 327 * function returns %FALSE. Therefore if @iter was already on line 0, 328 * but not at the start of the line, @iter is snapped to the start of 329 * the line and the function returns %TRUE. (Note that this implies that 330 * in a loop calling this function, the line number may not change on 331 * every iteration, if your first iteration is on line 0.) 332 * 333 * Returns: whether @iter moved 334 * 335 * Since: 2.8 336 */ 337 public bool backwardVisibleLine() 338 { 339 return gtk_text_iter_backward_visible_line(gtkTextIter) != 0; 340 } 341 342 /** 343 * Moves @count visible lines backward, if possible (if @count would move 344 * past the start or end of the buffer, moves to the start or end of 345 * the buffer). The return value indicates whether the iterator moved 346 * onto a dereferenceable position; if the iterator didn’t move, or 347 * moved onto the end iterator, then %FALSE is returned. If @count is 0, 348 * the function does nothing and returns %FALSE. If @count is negative, 349 * moves forward by 0 - @count lines. 350 * 351 * Params: 352 * count = number of lines to move backward 353 * 354 * Returns: whether @iter moved and is dereferenceable 355 * 356 * Since: 2.8 357 */ 358 public bool backwardVisibleLines(int count) 359 { 360 return gtk_text_iter_backward_visible_lines(gtkTextIter, count) != 0; 361 } 362 363 /** 364 * Moves backward to the previous visible word start. (If @iter is currently 365 * on a word start, moves backward to the next one after that.) Word breaks 366 * are determined by Pango and should be correct for nearly any 367 * language (if not, the correct fix would be to the Pango word break 368 * algorithms). 369 * 370 * Returns: %TRUE if @iter moved and is not the end iterator 371 * 372 * Since: 2.4 373 */ 374 public bool backwardVisibleWordStart() 375 { 376 return gtk_text_iter_backward_visible_word_start(gtkTextIter) != 0; 377 } 378 379 /** 380 * Calls gtk_text_iter_backward_visible_word_start() up to @count times. 381 * 382 * Params: 383 * count = number of times to move 384 * 385 * Returns: %TRUE if @iter moved and is not the end iterator 386 * 387 * Since: 2.4 388 */ 389 public bool backwardVisibleWordStarts(int count) 390 { 391 return gtk_text_iter_backward_visible_word_starts(gtkTextIter, count) != 0; 392 } 393 394 /** 395 * Moves backward to the previous word start. (If @iter is currently on a 396 * word start, moves backward to the next one after that.) Word breaks 397 * are determined by Pango and should be correct for nearly any 398 * language (if not, the correct fix would be to the Pango word break 399 * algorithms). 400 * 401 * Returns: %TRUE if @iter moved and is not the end iterator 402 */ 403 public bool backwardWordStart() 404 { 405 return gtk_text_iter_backward_word_start(gtkTextIter) != 0; 406 } 407 408 /** 409 * Calls gtk_text_iter_backward_word_start() up to @count times. 410 * 411 * Params: 412 * count = number of times to move 413 * 414 * Returns: %TRUE if @iter moved and is not the end iterator 415 */ 416 public bool backwardWordStarts(int count) 417 { 418 return gtk_text_iter_backward_word_starts(gtkTextIter, count) != 0; 419 } 420 421 /** 422 * Returns %TRUE if @tag is toggled on at exactly this point. If @tag 423 * is %NULL, returns %TRUE if any tag is toggled on at this point. 424 * 425 * Note that if gtk_text_iter_begins_tag() returns %TRUE, it means that @iter is 426 * at the beginning of the tagged range, and that the 427 * character at @iter is inside the tagged range. In other 428 * words, unlike gtk_text_iter_ends_tag(), if gtk_text_iter_begins_tag() returns 429 * %TRUE, gtk_text_iter_has_tag() will also return %TRUE for the same 430 * parameters. 431 * 432 * Deprecated: Use gtk_text_iter_starts_tag() instead. 433 * 434 * Params: 435 * tag = a #GtkTextTag, or %NULL 436 * 437 * Returns: whether @iter is the start of a range tagged with @tag 438 */ 439 public bool beginsTag(TextTag tag) 440 { 441 return gtk_text_iter_begins_tag(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 442 } 443 444 /** 445 * Considering the default editability of the buffer, and tags that 446 * affect editability, determines whether text inserted at @iter would 447 * be editable. If text inserted at @iter would be editable then the 448 * user should be allowed to insert text at @iter. 449 * gtk_text_buffer_insert_interactive() uses this function to decide 450 * whether insertions are allowed at a given position. 451 * 452 * Params: 453 * defaultEditability = %TRUE if text is editable by default 454 * 455 * Returns: whether text inserted at @iter would be editable 456 */ 457 public bool canInsert(bool defaultEditability) 458 { 459 return gtk_text_iter_can_insert(gtkTextIter, defaultEditability) != 0; 460 } 461 462 /** 463 * A qsort()-style function that returns negative if @lhs is less than 464 * @rhs, positive if @lhs is greater than @rhs, and 0 if they’re equal. 465 * Ordering is in character offset order, i.e. the first character in the buffer 466 * is less than the second character in the buffer. 467 * 468 * Params: 469 * rhs = another #GtkTextIter 470 * 471 * Returns: -1 if @lhs is less than @rhs, 1 if @lhs is greater, 0 if they are equal 472 */ 473 public int compare(TextIter rhs) 474 { 475 return gtk_text_iter_compare(gtkTextIter, (rhs is null) ? null : rhs.getTextIterStruct()); 476 } 477 478 /** 479 * Creates a dynamically-allocated copy of an iterator. This function 480 * is not useful in applications, because iterators can be copied with a 481 * simple assignment (`GtkTextIter i = j;`). The 482 * function is used by language bindings. 483 * 484 * Returns: a copy of the @iter, free with gtk_text_iter_free() 485 */ 486 public TextIter copy() 487 { 488 auto p = gtk_text_iter_copy(gtkTextIter); 489 490 if(p is null) 491 { 492 return null; 493 } 494 495 return ObjectG.getDObject!(TextIter)(cast(GtkTextIter*) p, true); 496 } 497 498 /** 499 * Returns whether the character at @iter is within an editable region 500 * of text. Non-editable text is “locked” and can’t be changed by the 501 * user via #GtkTextView. This function is simply a convenience 502 * wrapper around gtk_text_iter_get_attributes(). If no tags applied 503 * to this text affect editability, @default_setting will be returned. 504 * 505 * You don’t want to use this function to decide whether text can be 506 * inserted at @iter, because for insertion you don’t want to know 507 * whether the char at @iter is inside an editable range, you want to 508 * know whether a new character inserted at @iter would be inside an 509 * editable range. Use gtk_text_iter_can_insert() to handle this 510 * case. 511 * 512 * Params: 513 * defaultSetting = %TRUE if text is editable by default 514 * 515 * Returns: whether @iter is inside an editable range 516 */ 517 public bool editable(bool defaultSetting) 518 { 519 return gtk_text_iter_editable(gtkTextIter, defaultSetting) != 0; 520 } 521 522 /** 523 * Returns %TRUE if @iter points to the start of the paragraph 524 * delimiter characters for a line (delimiters will be either a 525 * newline, a carriage return, a carriage return followed by a 526 * newline, or a Unicode paragraph separator character). Note that an 527 * iterator pointing to the \n of a \r\n pair will not be counted as 528 * the end of a line, the line ends before the \r. The end iterator is 529 * considered to be at the end of a line, even though there are no 530 * paragraph delimiter chars there. 531 * 532 * Returns: whether @iter is at the end of a line 533 */ 534 public bool endsLine() 535 { 536 return gtk_text_iter_ends_line(gtkTextIter) != 0; 537 } 538 539 /** 540 * Determines whether @iter ends a sentence. Sentence boundaries are 541 * determined by Pango and should be correct for nearly any language 542 * (if not, the correct fix would be to the Pango text boundary 543 * algorithms). 544 * 545 * Returns: %TRUE if @iter is at the end of a sentence. 546 */ 547 public bool endsSentence() 548 { 549 return gtk_text_iter_ends_sentence(gtkTextIter) != 0; 550 } 551 552 /** 553 * Returns %TRUE if @tag is toggled off at exactly this point. If @tag 554 * is %NULL, returns %TRUE if any tag is toggled off at this point. 555 * 556 * Note that if gtk_text_iter_ends_tag() returns %TRUE, it means that @iter is 557 * at the end of the tagged range, but that the character 558 * at @iter is outside the tagged range. In other words, 559 * unlike gtk_text_iter_starts_tag(), if gtk_text_iter_ends_tag() returns %TRUE, 560 * gtk_text_iter_has_tag() will return %FALSE for the same parameters. 561 * 562 * Params: 563 * tag = a #GtkTextTag, or %NULL 564 * 565 * Returns: whether @iter is the end of a range tagged with @tag 566 */ 567 public bool endsTag(TextTag tag) 568 { 569 return gtk_text_iter_ends_tag(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 570 } 571 572 /** 573 * Determines whether @iter ends a natural-language word. Word breaks 574 * are determined by Pango and should be correct for nearly any 575 * language (if not, the correct fix would be to the Pango word break 576 * algorithms). 577 * 578 * Returns: %TRUE if @iter is at the end of a word 579 */ 580 public bool endsWord() 581 { 582 return gtk_text_iter_ends_word(gtkTextIter) != 0; 583 } 584 585 /** 586 * Tests whether two iterators are equal, using the fastest possible 587 * mechanism. This function is very fast; you can expect it to perform 588 * better than e.g. getting the character offset for each iterator and 589 * comparing the offsets yourself. Also, it’s a bit faster than 590 * gtk_text_iter_compare(). 591 * 592 * Params: 593 * rhs = another #GtkTextIter 594 * 595 * Returns: %TRUE if the iterators point to the same place in the buffer 596 */ 597 public bool equal(TextIter rhs) 598 { 599 return gtk_text_iter_equal(gtkTextIter, (rhs is null) ? null : rhs.getTextIterStruct()) != 0; 600 } 601 602 /** 603 * Moves @iter forward by one character offset. Note that images 604 * embedded in the buffer occupy 1 character slot, so 605 * gtk_text_iter_forward_char() may actually move onto an image instead 606 * of a character, if you have images in your buffer. If @iter is the 607 * end iterator or one character before it, @iter will now point at 608 * the end iterator, and gtk_text_iter_forward_char() returns %FALSE for 609 * convenience when writing loops. 610 * 611 * Returns: whether @iter moved and is dereferenceable 612 */ 613 public bool forwardChar() 614 { 615 return gtk_text_iter_forward_char(gtkTextIter) != 0; 616 } 617 618 /** 619 * Moves @count characters if possible (if @count would move past the 620 * start or end of the buffer, moves to the start or end of the 621 * buffer). The return value indicates whether the new position of 622 * @iter is different from its original position, and dereferenceable 623 * (the last iterator in the buffer is not dereferenceable). If @count 624 * is 0, the function does nothing and returns %FALSE. 625 * 626 * Params: 627 * count = number of characters to move, may be negative 628 * 629 * Returns: whether @iter moved and is dereferenceable 630 */ 631 public bool forwardChars(int count) 632 { 633 return gtk_text_iter_forward_chars(gtkTextIter, count) != 0; 634 } 635 636 /** 637 * Moves @iter forward by a single cursor position. Cursor positions 638 * are (unsurprisingly) positions where the cursor can appear. Perhaps 639 * surprisingly, there may not be a cursor position between all 640 * characters. The most common example for European languages would be 641 * a carriage return/newline sequence. For some Unicode characters, 642 * the equivalent of say the letter “a” with an accent mark will be 643 * represented as two characters, first the letter then a "combining 644 * mark" that causes the accent to be rendered; so the cursor can’t go 645 * between those two characters. See also the #PangoLogAttr-struct and 646 * pango_break() function. 647 * 648 * Returns: %TRUE if we moved and the new position is dereferenceable 649 */ 650 public bool forwardCursorPosition() 651 { 652 return gtk_text_iter_forward_cursor_position(gtkTextIter) != 0; 653 } 654 655 /** 656 * Moves up to @count cursor positions. See 657 * gtk_text_iter_forward_cursor_position() for details. 658 * 659 * Params: 660 * count = number of positions to move 661 * 662 * Returns: %TRUE if we moved and the new position is dereferenceable 663 */ 664 public bool forwardCursorPositions(int count) 665 { 666 return gtk_text_iter_forward_cursor_positions(gtkTextIter, count) != 0; 667 } 668 669 /** 670 * Advances @iter, calling @pred on each character. If 671 * @pred returns %TRUE, returns %TRUE and stops scanning. 672 * If @pred never returns %TRUE, @iter is set to @limit if 673 * @limit is non-%NULL, otherwise to the end iterator. 674 * 675 * Params: 676 * pred = a function to be called on each character 677 * userData = user data for @pred 678 * limit = search limit, or %NULL for none 679 * 680 * Returns: whether a match was found 681 */ 682 public bool forwardFindChar(GtkTextCharPredicate pred, void* userData, TextIter limit) 683 { 684 return gtk_text_iter_forward_find_char(gtkTextIter, pred, userData, (limit is null) ? null : limit.getTextIterStruct()) != 0; 685 } 686 687 /** 688 * Moves @iter to the start of the next line. If the iter is already on the 689 * last line of the buffer, moves the iter to the end of the current line. 690 * If after the operation, the iter is at the end of the buffer and not 691 * dereferencable, returns %FALSE. Otherwise, returns %TRUE. 692 * 693 * Returns: whether @iter can be dereferenced 694 */ 695 public bool forwardLine() 696 { 697 return gtk_text_iter_forward_line(gtkTextIter) != 0; 698 } 699 700 /** 701 * Moves @count lines forward, if possible (if @count would move 702 * past the start or end of the buffer, moves to the start or end of 703 * the buffer). The return value indicates whether the iterator moved 704 * onto a dereferenceable position; if the iterator didn’t move, or 705 * moved onto the end iterator, then %FALSE is returned. If @count is 0, 706 * the function does nothing and returns %FALSE. If @count is negative, 707 * moves backward by 0 - @count lines. 708 * 709 * Params: 710 * count = number of lines to move forward 711 * 712 * Returns: whether @iter moved and is dereferenceable 713 */ 714 public bool forwardLines(int count) 715 { 716 return gtk_text_iter_forward_lines(gtkTextIter, count) != 0; 717 } 718 719 /** 720 * Searches forward for @str. Any match is returned by setting 721 * @match_start to the first character of the match and @match_end to the 722 * first character after the match. The search will not continue past 723 * @limit. Note that a search is a linear or O(n) operation, so you 724 * may wish to use @limit to avoid locking up your UI on large 725 * buffers. 726 * 727 * @match_start will never be set to a #GtkTextIter located before @iter, even if 728 * there is a possible @match_end after or at @iter. 729 * 730 * Params: 731 * str = a search string 732 * flags = flags affecting how the search is done 733 * matchStart = return location for start of match, or %NULL 734 * matchEnd = return location for end of match, or %NULL 735 * limit = location of last possible @match_end, or %NULL for the end of the buffer 736 * 737 * Returns: whether a match was found 738 */ 739 public bool forwardSearch(string str, GtkTextSearchFlags flags, out TextIter matchStart, out TextIter matchEnd, TextIter limit) 740 { 741 GtkTextIter* outmatchStart = gMalloc!GtkTextIter(); 742 GtkTextIter* outmatchEnd = gMalloc!GtkTextIter(); 743 744 auto p = gtk_text_iter_forward_search(gtkTextIter, Str.toStringz(str), flags, outmatchStart, outmatchEnd, (limit is null) ? null : limit.getTextIterStruct()) != 0; 745 746 matchStart = ObjectG.getDObject!(TextIter)(outmatchStart, true); 747 matchEnd = ObjectG.getDObject!(TextIter)(outmatchEnd, true); 748 749 return p; 750 } 751 752 /** 753 * Moves forward to the next sentence end. (If @iter is at the end of 754 * a sentence, moves to the next end of sentence.) Sentence 755 * boundaries are determined by Pango and should be correct for nearly 756 * any language (if not, the correct fix would be to the Pango text 757 * boundary algorithms). 758 * 759 * Returns: %TRUE if @iter moved and is not the end iterator 760 */ 761 public bool forwardSentenceEnd() 762 { 763 return gtk_text_iter_forward_sentence_end(gtkTextIter) != 0; 764 } 765 766 /** 767 * Calls gtk_text_iter_forward_sentence_end() @count times (or until 768 * gtk_text_iter_forward_sentence_end() returns %FALSE). If @count is 769 * negative, moves backward instead of forward. 770 * 771 * Params: 772 * count = number of sentences to move 773 * 774 * Returns: %TRUE if @iter moved and is not the end iterator 775 */ 776 public bool forwardSentenceEnds(int count) 777 { 778 return gtk_text_iter_forward_sentence_ends(gtkTextIter, count) != 0; 779 } 780 781 /** 782 * Moves @iter forward to the “end iterator,” which points one past the last 783 * valid character in the buffer. gtk_text_iter_get_char() called on the 784 * end iterator returns 0, which is convenient for writing loops. 785 */ 786 public void forwardToEnd() 787 { 788 gtk_text_iter_forward_to_end(gtkTextIter); 789 } 790 791 /** 792 * Moves the iterator to point to the paragraph delimiter characters, 793 * which will be either a newline, a carriage return, a carriage 794 * return/newline in sequence, or the Unicode paragraph separator 795 * character. If the iterator is already at the paragraph delimiter 796 * characters, moves to the paragraph delimiter characters for the 797 * next line. If @iter is on the last line in the buffer, which does 798 * not end in paragraph delimiters, moves to the end iterator (end of 799 * the last line), and returns %FALSE. 800 * 801 * Returns: %TRUE if we moved and the new location is not the end iterator 802 */ 803 public bool forwardToLineEnd() 804 { 805 return gtk_text_iter_forward_to_line_end(gtkTextIter) != 0; 806 } 807 808 /** 809 * Moves forward to the next toggle (on or off) of the 810 * #GtkTextTag @tag, or to the next toggle of any tag if 811 * @tag is %NULL. If no matching tag toggles are found, 812 * returns %FALSE, otherwise %TRUE. Does not return toggles 813 * located at @iter, only toggles after @iter. Sets @iter to 814 * the location of the toggle, or to the end of the buffer 815 * if no toggle is found. 816 * 817 * Params: 818 * tag = a #GtkTextTag, or %NULL 819 * 820 * Returns: whether we found a tag toggle after @iter 821 */ 822 public bool forwardToTagToggle(TextTag tag) 823 { 824 return gtk_text_iter_forward_to_tag_toggle(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 825 } 826 827 /** 828 * Moves @iter forward to the next visible cursor position. See 829 * gtk_text_iter_forward_cursor_position() for details. 830 * 831 * Returns: %TRUE if we moved and the new position is dereferenceable 832 * 833 * Since: 2.4 834 */ 835 public bool forwardVisibleCursorPosition() 836 { 837 return gtk_text_iter_forward_visible_cursor_position(gtkTextIter) != 0; 838 } 839 840 /** 841 * Moves up to @count visible cursor positions. See 842 * gtk_text_iter_forward_cursor_position() for details. 843 * 844 * Params: 845 * count = number of positions to move 846 * 847 * Returns: %TRUE if we moved and the new position is dereferenceable 848 * 849 * Since: 2.4 850 */ 851 public bool forwardVisibleCursorPositions(int count) 852 { 853 return gtk_text_iter_forward_visible_cursor_positions(gtkTextIter, count) != 0; 854 } 855 856 /** 857 * Moves @iter to the start of the next visible line. Returns %TRUE if there 858 * was a next line to move to, and %FALSE if @iter was simply moved to 859 * the end of the buffer and is now not dereferenceable, or if @iter was 860 * already at the end of the buffer. 861 * 862 * Returns: whether @iter can be dereferenced 863 * 864 * Since: 2.8 865 */ 866 public bool forwardVisibleLine() 867 { 868 return gtk_text_iter_forward_visible_line(gtkTextIter) != 0; 869 } 870 871 /** 872 * Moves @count visible lines forward, if possible (if @count would move 873 * past the start or end of the buffer, moves to the start or end of 874 * the buffer). The return value indicates whether the iterator moved 875 * onto a dereferenceable position; if the iterator didn’t move, or 876 * moved onto the end iterator, then %FALSE is returned. If @count is 0, 877 * the function does nothing and returns %FALSE. If @count is negative, 878 * moves backward by 0 - @count lines. 879 * 880 * Params: 881 * count = number of lines to move forward 882 * 883 * Returns: whether @iter moved and is dereferenceable 884 * 885 * Since: 2.8 886 */ 887 public bool forwardVisibleLines(int count) 888 { 889 return gtk_text_iter_forward_visible_lines(gtkTextIter, count) != 0; 890 } 891 892 /** 893 * Moves forward to the next visible word end. (If @iter is currently on a 894 * word end, moves forward to the next one after that.) Word breaks 895 * are determined by Pango and should be correct for nearly any 896 * language (if not, the correct fix would be to the Pango word break 897 * algorithms). 898 * 899 * Returns: %TRUE if @iter moved and is not the end iterator 900 * 901 * Since: 2.4 902 */ 903 public bool forwardVisibleWordEnd() 904 { 905 return gtk_text_iter_forward_visible_word_end(gtkTextIter) != 0; 906 } 907 908 /** 909 * Calls gtk_text_iter_forward_visible_word_end() up to @count times. 910 * 911 * Params: 912 * count = number of times to move 913 * 914 * Returns: %TRUE if @iter moved and is not the end iterator 915 * 916 * Since: 2.4 917 */ 918 public bool forwardVisibleWordEnds(int count) 919 { 920 return gtk_text_iter_forward_visible_word_ends(gtkTextIter, count) != 0; 921 } 922 923 /** 924 * Moves forward to the next word end. (If @iter is currently on a 925 * word end, moves forward to the next one after that.) Word breaks 926 * are determined by Pango and should be correct for nearly any 927 * language (if not, the correct fix would be to the Pango word break 928 * algorithms). 929 * 930 * Returns: %TRUE if @iter moved and is not the end iterator 931 */ 932 public bool forwardWordEnd() 933 { 934 return gtk_text_iter_forward_word_end(gtkTextIter) != 0; 935 } 936 937 /** 938 * Calls gtk_text_iter_forward_word_end() up to @count times. 939 * 940 * Params: 941 * count = number of times to move 942 * 943 * Returns: %TRUE if @iter moved and is not the end iterator 944 */ 945 public bool forwardWordEnds(int count) 946 { 947 return gtk_text_iter_forward_word_ends(gtkTextIter, count) != 0; 948 } 949 950 /** 951 * Free an iterator allocated on the heap. This function 952 * is intended for use in language bindings, and is not 953 * especially useful for applications, because iterators can 954 * simply be allocated on the stack. 955 */ 956 public void free() 957 { 958 gtk_text_iter_free(gtkTextIter); 959 ownedRef = false; 960 } 961 962 /** 963 * Computes the effect of any tags applied to this spot in the 964 * text. The @values parameter should be initialized to the default 965 * settings you wish to use if no tags are in effect. You’d typically 966 * obtain the defaults from gtk_text_view_get_default_attributes(). 967 * 968 * gtk_text_iter_get_attributes() will modify @values, applying the 969 * effects of any tags present at @iter. If any tags affected @values, 970 * the function returns %TRUE. 971 * 972 * Params: 973 * values = a #GtkTextAttributes to be filled in 974 * 975 * Returns: %TRUE if @values was modified 976 */ 977 public bool getAttributes(out TextAttributes values) 978 { 979 GtkTextAttributes* outvalues = gMalloc!GtkTextAttributes(); 980 981 auto p = gtk_text_iter_get_attributes(gtkTextIter, outvalues) != 0; 982 983 values = ObjectG.getDObject!(TextAttributes)(outvalues, true); 984 985 return p; 986 } 987 988 /** 989 * Returns the #GtkTextBuffer this iterator is associated with. 990 * 991 * Returns: the buffer 992 */ 993 public TextBuffer getBuffer() 994 { 995 auto p = gtk_text_iter_get_buffer(gtkTextIter); 996 997 if(p is null) 998 { 999 return null; 1000 } 1001 1002 return ObjectG.getDObject!(TextBuffer)(cast(GtkTextBuffer*) p); 1003 } 1004 1005 /** 1006 * Returns the number of bytes in the line containing @iter, 1007 * including the paragraph delimiters. 1008 * 1009 * Returns: number of bytes in the line 1010 */ 1011 public int getBytesInLine() 1012 { 1013 return gtk_text_iter_get_bytes_in_line(gtkTextIter); 1014 } 1015 1016 /** 1017 * The Unicode character at this iterator is returned. (Equivalent to 1018 * operator* on a C++ iterator.) If the element at this iterator is a 1019 * non-character element, such as an image embedded in the buffer, the 1020 * Unicode “unknown” character 0xFFFC is returned. If invoked on 1021 * the end iterator, zero is returned; zero is not a valid Unicode character. 1022 * So you can write a loop which ends when gtk_text_iter_get_char() 1023 * returns 0. 1024 * 1025 * Returns: a Unicode character, or 0 if @iter is not dereferenceable 1026 */ 1027 public dchar getChar() 1028 { 1029 return gtk_text_iter_get_char(gtkTextIter); 1030 } 1031 1032 /** 1033 * Returns the number of characters in the line containing @iter, 1034 * including the paragraph delimiters. 1035 * 1036 * Returns: number of characters in the line 1037 */ 1038 public int getCharsInLine() 1039 { 1040 return gtk_text_iter_get_chars_in_line(gtkTextIter); 1041 } 1042 1043 /** 1044 * If the location at @iter contains a child anchor, the 1045 * anchor is returned (with no new reference count added). Otherwise, 1046 * %NULL is returned. 1047 * 1048 * Returns: the anchor at @iter 1049 */ 1050 public TextChildAnchor getChildAnchor() 1051 { 1052 auto p = gtk_text_iter_get_child_anchor(gtkTextIter); 1053 1054 if(p is null) 1055 { 1056 return null; 1057 } 1058 1059 return ObjectG.getDObject!(TextChildAnchor)(cast(GtkTextChildAnchor*) p); 1060 } 1061 1062 /** 1063 * A convenience wrapper around gtk_text_iter_get_attributes(), 1064 * which returns the language in effect at @iter. If no tags affecting 1065 * language apply to @iter, the return value is identical to that of 1066 * gtk_get_default_language(). 1067 * 1068 * Returns: language in effect at @iter 1069 */ 1070 public PgLanguage getLanguage() 1071 { 1072 auto p = gtk_text_iter_get_language(gtkTextIter); 1073 1074 if(p is null) 1075 { 1076 return null; 1077 } 1078 1079 return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) p, true); 1080 } 1081 1082 /** 1083 * Returns the line number containing the iterator. Lines in 1084 * a #GtkTextBuffer are numbered beginning with 0 for the first 1085 * line in the buffer. 1086 * 1087 * Returns: a line number 1088 */ 1089 public int getLine() 1090 { 1091 return gtk_text_iter_get_line(gtkTextIter); 1092 } 1093 1094 /** 1095 * Returns the byte index of the iterator, counting 1096 * from the start of a newline-terminated line. 1097 * Remember that #GtkTextBuffer encodes text in 1098 * UTF-8, and that characters can require a variable 1099 * number of bytes to represent. 1100 * 1101 * Returns: distance from start of line, in bytes 1102 */ 1103 public int getLineIndex() 1104 { 1105 return gtk_text_iter_get_line_index(gtkTextIter); 1106 } 1107 1108 /** 1109 * Returns the character offset of the iterator, 1110 * counting from the start of a newline-terminated line. 1111 * The first character on the line has offset 0. 1112 * 1113 * Returns: offset from start of line 1114 */ 1115 public int getLineOffset() 1116 { 1117 return gtk_text_iter_get_line_offset(gtkTextIter); 1118 } 1119 1120 /** 1121 * Returns a list of all #GtkTextMark at this location. Because marks 1122 * are not iterable (they don’t take up any "space" in the buffer, 1123 * they are just marks in between iterable locations), multiple marks 1124 * can exist in the same place. The returned list is not in any 1125 * meaningful order. 1126 * 1127 * Returns: list of #GtkTextMark 1128 */ 1129 public ListSG getMarks() 1130 { 1131 auto p = gtk_text_iter_get_marks(gtkTextIter); 1132 1133 if(p is null) 1134 { 1135 return null; 1136 } 1137 1138 return new ListSG(cast(GSList*) p); 1139 } 1140 1141 /** 1142 * Returns the character offset of an iterator. 1143 * Each character in a #GtkTextBuffer has an offset, 1144 * starting with 0 for the first character in the buffer. 1145 * Use gtk_text_buffer_get_iter_at_offset() to convert an 1146 * offset back into an iterator. 1147 * 1148 * Returns: a character offset 1149 */ 1150 public int getOffset() 1151 { 1152 return gtk_text_iter_get_offset(gtkTextIter); 1153 } 1154 1155 /** 1156 * If the element at @iter is a pixbuf, the pixbuf is returned 1157 * (with no new reference count added). Otherwise, 1158 * %NULL is returned. 1159 * 1160 * Returns: the pixbuf at @iter 1161 */ 1162 public Pixbuf getPixbuf() 1163 { 1164 auto p = gtk_text_iter_get_pixbuf(gtkTextIter); 1165 1166 if(p is null) 1167 { 1168 return null; 1169 } 1170 1171 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1172 } 1173 1174 /** 1175 * Returns the text in the given range. A “slice” is an array of 1176 * characters encoded in UTF-8 format, including the Unicode “unknown” 1177 * character 0xFFFC for iterable non-character elements in the buffer, 1178 * such as images. Because images are encoded in the slice, byte and 1179 * character offsets in the returned array will correspond to byte 1180 * offsets in the text buffer. Note that 0xFFFC can occur in normal 1181 * text as well, so it is not a reliable indicator that a pixbuf or 1182 * widget is in the buffer. 1183 * 1184 * Params: 1185 * end = iterator at end of a range 1186 * 1187 * Returns: slice of text from the buffer 1188 */ 1189 public string getSlice(TextIter end) 1190 { 1191 auto retStr = gtk_text_iter_get_slice(gtkTextIter, (end is null) ? null : end.getTextIterStruct()); 1192 1193 scope(exit) Str.freeString(retStr); 1194 return Str.toString(retStr); 1195 } 1196 1197 /** 1198 * Returns a list of tags that apply to @iter, in ascending order of 1199 * priority (highest-priority tags are last). The #GtkTextTag in the 1200 * list don’t have a reference added, but you have to free the list 1201 * itself. 1202 * 1203 * Returns: list of #GtkTextTag 1204 */ 1205 public ListSG getTags() 1206 { 1207 auto p = gtk_text_iter_get_tags(gtkTextIter); 1208 1209 if(p is null) 1210 { 1211 return null; 1212 } 1213 1214 return new ListSG(cast(GSList*) p); 1215 } 1216 1217 /** 1218 * Returns text in the given range. If the range 1219 * contains non-text elements such as images, the character and byte 1220 * offsets in the returned string will not correspond to character and 1221 * byte offsets in the buffer. If you want offsets to correspond, see 1222 * gtk_text_iter_get_slice(). 1223 * 1224 * Params: 1225 * end = iterator at end of a range 1226 * 1227 * Returns: array of characters from the buffer 1228 */ 1229 public string getText(TextIter end) 1230 { 1231 auto retStr = gtk_text_iter_get_text(gtkTextIter, (end is null) ? null : end.getTextIterStruct()); 1232 1233 scope(exit) Str.freeString(retStr); 1234 return Str.toString(retStr); 1235 } 1236 1237 /** 1238 * Returns a list of #GtkTextTag that are toggled on or off at this 1239 * point. (If @toggled_on is %TRUE, the list contains tags that are 1240 * toggled on.) If a tag is toggled on at @iter, then some non-empty 1241 * range of characters following @iter has that tag applied to it. If 1242 * a tag is toggled off, then some non-empty range following @iter 1243 * does not have the tag applied to it. 1244 * 1245 * Params: 1246 * toggledOn = %TRUE to get toggled-on tags 1247 * 1248 * Returns: tags toggled at this point 1249 */ 1250 public ListSG getToggledTags(bool toggledOn) 1251 { 1252 auto p = gtk_text_iter_get_toggled_tags(gtkTextIter, toggledOn); 1253 1254 if(p is null) 1255 { 1256 return null; 1257 } 1258 1259 return new ListSG(cast(GSList*) p); 1260 } 1261 1262 /** 1263 * Returns the number of bytes from the start of the 1264 * line to the given @iter, not counting bytes that 1265 * are invisible due to tags with the “invisible” flag 1266 * toggled on. 1267 * 1268 * Returns: byte index of @iter with respect to the start of the line 1269 */ 1270 public int getVisibleLineIndex() 1271 { 1272 return gtk_text_iter_get_visible_line_index(gtkTextIter); 1273 } 1274 1275 /** 1276 * Returns the offset in characters from the start of the 1277 * line to the given @iter, not counting characters that 1278 * are invisible due to tags with the “invisible” flag 1279 * toggled on. 1280 * 1281 * Returns: offset in visible characters from the start of the line 1282 */ 1283 public int getVisibleLineOffset() 1284 { 1285 return gtk_text_iter_get_visible_line_offset(gtkTextIter); 1286 } 1287 1288 /** 1289 * Like gtk_text_iter_get_slice(), but invisible text is not included. 1290 * Invisible text is usually invisible because a #GtkTextTag with the 1291 * “invisible” attribute turned on has been applied to it. 1292 * 1293 * Params: 1294 * end = iterator at end of range 1295 * 1296 * Returns: slice of text from the buffer 1297 */ 1298 public string getVisibleSlice(TextIter end) 1299 { 1300 auto retStr = gtk_text_iter_get_visible_slice(gtkTextIter, (end is null) ? null : end.getTextIterStruct()); 1301 1302 scope(exit) Str.freeString(retStr); 1303 return Str.toString(retStr); 1304 } 1305 1306 /** 1307 * Like gtk_text_iter_get_text(), but invisible text is not included. 1308 * Invisible text is usually invisible because a #GtkTextTag with the 1309 * “invisible” attribute turned on has been applied to it. 1310 * 1311 * Params: 1312 * end = iterator at end of range 1313 * 1314 * Returns: string containing visible text in the 1315 * range 1316 */ 1317 public string getVisibleText(TextIter end) 1318 { 1319 auto retStr = gtk_text_iter_get_visible_text(gtkTextIter, (end is null) ? null : end.getTextIterStruct()); 1320 1321 scope(exit) Str.freeString(retStr); 1322 return Str.toString(retStr); 1323 } 1324 1325 /** 1326 * Returns %TRUE if @iter points to a character that is part of a range tagged 1327 * with @tag. See also gtk_text_iter_starts_tag() and gtk_text_iter_ends_tag(). 1328 * 1329 * Params: 1330 * tag = a #GtkTextTag 1331 * 1332 * Returns: whether @iter is tagged with @tag 1333 */ 1334 public bool hasTag(TextTag tag) 1335 { 1336 return gtk_text_iter_has_tag(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 1337 } 1338 1339 /** 1340 * Checks whether @iter falls in the range [@start, @end). 1341 * @start and @end must be in ascending order. 1342 * 1343 * Params: 1344 * start = start of range 1345 * end = end of range 1346 * 1347 * Returns: %TRUE if @iter is in the range 1348 */ 1349 public bool inRange(TextIter start, TextIter end) 1350 { 1351 return gtk_text_iter_in_range(gtkTextIter, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()) != 0; 1352 } 1353 1354 /** 1355 * Determines whether @iter is inside a sentence (as opposed to in 1356 * between two sentences, e.g. after a period and before the first 1357 * letter of the next sentence). Sentence boundaries are determined 1358 * by Pango and should be correct for nearly any language (if not, the 1359 * correct fix would be to the Pango text boundary algorithms). 1360 * 1361 * Returns: %TRUE if @iter is inside a sentence. 1362 */ 1363 public bool insideSentence() 1364 { 1365 return gtk_text_iter_inside_sentence(gtkTextIter) != 0; 1366 } 1367 1368 /** 1369 * Determines whether the character pointed by @iter is part of a 1370 * natural-language word (as opposed to say inside some whitespace). Word 1371 * breaks are determined by Pango and should be correct for nearly any language 1372 * (if not, the correct fix would be to the Pango word break algorithms). 1373 * 1374 * Note that if gtk_text_iter_starts_word() returns %TRUE, then this function 1375 * returns %TRUE too, since @iter points to the first character of the word. 1376 * 1377 * Returns: %TRUE if @iter is inside a word 1378 */ 1379 public bool insideWord() 1380 { 1381 return gtk_text_iter_inside_word(gtkTextIter) != 0; 1382 } 1383 1384 /** 1385 * See gtk_text_iter_forward_cursor_position() or #PangoLogAttr or 1386 * pango_break() for details on what a cursor position is. 1387 * 1388 * Returns: %TRUE if the cursor can be placed at @iter 1389 */ 1390 public bool isCursorPosition() 1391 { 1392 return gtk_text_iter_is_cursor_position(gtkTextIter) != 0; 1393 } 1394 1395 /** 1396 * Returns %TRUE if @iter is the end iterator, i.e. one past the last 1397 * dereferenceable iterator in the buffer. gtk_text_iter_is_end() is 1398 * the most efficient way to check whether an iterator is the end 1399 * iterator. 1400 * 1401 * Returns: whether @iter is the end iterator 1402 */ 1403 public bool isEnd() 1404 { 1405 return gtk_text_iter_is_end(gtkTextIter) != 0; 1406 } 1407 1408 /** 1409 * Returns %TRUE if @iter is the first iterator in the buffer, that is 1410 * if @iter has a character offset of 0. 1411 * 1412 * Returns: whether @iter is the first in the buffer 1413 */ 1414 public bool isStart() 1415 { 1416 return gtk_text_iter_is_start(gtkTextIter) != 0; 1417 } 1418 1419 /** 1420 * Swaps the value of @first and @second if @second comes before 1421 * @first in the buffer. That is, ensures that @first and @second are 1422 * in sequence. Most text buffer functions that take a range call this 1423 * automatically on your behalf, so there’s no real reason to call it yourself 1424 * in those cases. There are some exceptions, such as gtk_text_iter_in_range(), 1425 * that expect a pre-sorted range. 1426 * 1427 * Params: 1428 * second = another #GtkTextIter 1429 */ 1430 public void order(TextIter second) 1431 { 1432 gtk_text_iter_order(gtkTextIter, (second is null) ? null : second.getTextIterStruct()); 1433 } 1434 1435 /** 1436 * Moves iterator @iter to the start of the line @line_number. If 1437 * @line_number is negative or larger than the number of lines in the 1438 * buffer, moves @iter to the start of the last line in the buffer. 1439 * 1440 * Params: 1441 * lineNumber = line number (counted from 0) 1442 */ 1443 public void setLine(int lineNumber) 1444 { 1445 gtk_text_iter_set_line(gtkTextIter, lineNumber); 1446 } 1447 1448 /** 1449 * Same as gtk_text_iter_set_line_offset(), but works with a 1450 * byte index. The given byte index must be at 1451 * the start of a character, it can’t be in the middle of a UTF-8 1452 * encoded character. 1453 * 1454 * Params: 1455 * byteOnLine = a byte index relative to the start of @iter’s current line 1456 */ 1457 public void setLineIndex(int byteOnLine) 1458 { 1459 gtk_text_iter_set_line_index(gtkTextIter, byteOnLine); 1460 } 1461 1462 /** 1463 * Moves @iter within a line, to a new character 1464 * (not byte) offset. The given character offset must be less than or 1465 * equal to the number of characters in the line; if equal, @iter 1466 * moves to the start of the next line. See 1467 * gtk_text_iter_set_line_index() if you have a byte index rather than 1468 * a character offset. 1469 * 1470 * Params: 1471 * charOnLine = a character offset relative to the start of @iter’s current line 1472 */ 1473 public void setLineOffset(int charOnLine) 1474 { 1475 gtk_text_iter_set_line_offset(gtkTextIter, charOnLine); 1476 } 1477 1478 /** 1479 * Sets @iter to point to @char_offset. @char_offset counts from the start 1480 * of the entire text buffer, starting with 0. 1481 * 1482 * Params: 1483 * charOffset = a character number 1484 */ 1485 public void setOffset(int charOffset) 1486 { 1487 gtk_text_iter_set_offset(gtkTextIter, charOffset); 1488 } 1489 1490 /** 1491 * Like gtk_text_iter_set_line_index(), but the index is in visible 1492 * bytes, i.e. text with a tag making it invisible is not counted 1493 * in the index. 1494 * 1495 * Params: 1496 * byteOnLine = a byte index 1497 */ 1498 public void setVisibleLineIndex(int byteOnLine) 1499 { 1500 gtk_text_iter_set_visible_line_index(gtkTextIter, byteOnLine); 1501 } 1502 1503 /** 1504 * Like gtk_text_iter_set_line_offset(), but the offset is in visible 1505 * characters, i.e. text with a tag making it invisible is not 1506 * counted in the offset. 1507 * 1508 * Params: 1509 * charOnLine = a character offset 1510 */ 1511 public void setVisibleLineOffset(int charOnLine) 1512 { 1513 gtk_text_iter_set_visible_line_offset(gtkTextIter, charOnLine); 1514 } 1515 1516 /** 1517 * Returns %TRUE if @iter begins a paragraph, 1518 * i.e. if gtk_text_iter_get_line_offset() would return 0. 1519 * However this function is potentially more efficient than 1520 * gtk_text_iter_get_line_offset() because it doesn’t have to compute 1521 * the offset, it just has to see whether it’s 0. 1522 * 1523 * Returns: whether @iter begins a line 1524 */ 1525 public bool startsLine() 1526 { 1527 return gtk_text_iter_starts_line(gtkTextIter) != 0; 1528 } 1529 1530 /** 1531 * Determines whether @iter begins a sentence. Sentence boundaries are 1532 * determined by Pango and should be correct for nearly any language 1533 * (if not, the correct fix would be to the Pango text boundary 1534 * algorithms). 1535 * 1536 * Returns: %TRUE if @iter is at the start of a sentence. 1537 */ 1538 public bool startsSentence() 1539 { 1540 return gtk_text_iter_starts_sentence(gtkTextIter) != 0; 1541 } 1542 1543 /** 1544 * Returns %TRUE if @tag is toggled on at exactly this point. If @tag 1545 * is %NULL, returns %TRUE if any tag is toggled on at this point. 1546 * 1547 * Note that if gtk_text_iter_starts_tag() returns %TRUE, it means that @iter is 1548 * at the beginning of the tagged range, and that the 1549 * character at @iter is inside the tagged range. In other 1550 * words, unlike gtk_text_iter_ends_tag(), if gtk_text_iter_starts_tag() returns 1551 * %TRUE, gtk_text_iter_has_tag() will also return %TRUE for the same 1552 * parameters. 1553 * 1554 * Params: 1555 * tag = a #GtkTextTag, or %NULL 1556 * 1557 * Returns: whether @iter is the start of a range tagged with @tag 1558 * 1559 * Since: 3.20 1560 */ 1561 public bool startsTag(TextTag tag) 1562 { 1563 return gtk_text_iter_starts_tag(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 1564 } 1565 1566 /** 1567 * Determines whether @iter begins a natural-language word. Word 1568 * breaks are determined by Pango and should be correct for nearly any 1569 * language (if not, the correct fix would be to the Pango word break 1570 * algorithms). 1571 * 1572 * Returns: %TRUE if @iter is at the start of a word 1573 */ 1574 public bool startsWord() 1575 { 1576 return gtk_text_iter_starts_word(gtkTextIter) != 0; 1577 } 1578 1579 /** 1580 * This is equivalent to (gtk_text_iter_starts_tag() || 1581 * gtk_text_iter_ends_tag()), i.e. it tells you whether a range with 1582 * @tag applied to it begins or ends at @iter. 1583 * 1584 * Params: 1585 * tag = a #GtkTextTag, or %NULL 1586 * 1587 * Returns: whether @tag is toggled on or off at @iter 1588 */ 1589 public bool togglesTag(TextTag tag) 1590 { 1591 return gtk_text_iter_toggles_tag(gtkTextIter, (tag is null) ? null : tag.getTextTagStruct()) != 0; 1592 } 1593 }