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