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