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