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