| 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
| 2 * gtksourceiter.c |
2 * gtksourceiter.c |
| 3 * |
3 * |
| 4 * Pidgin is the legal property of its developers, whose names are too numerous |
4 * Pidgin is the legal property of its developers, whose names are too numerous |
| 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 * source distribution. |
6 * source distribution. |
| 7 * |
7 * |
| 8 * The following copyright notice applies to this file: |
8 * The following copyright notice applies to this file: |
| 9 * |
9 * |
| 10 * Copyright (C) 2000 - 2005 Paolo Maggi |
10 * Copyright (C) 2000 - 2005 Paolo Maggi |
| 11 * Copyright (C) 2002, 2003 Jeroen Zwartepoorte |
11 * Copyright (C) 2002, 2003 Jeroen Zwartepoorte |
| 12 * |
12 * |
| 13 * This program is free software; you can redistribute it and/or modify |
13 * This program is free software; you can redistribute it and/or modify |
| 14 * it under the terms of the GNU Library General Public License as published by |
14 * it under the terms of the GNU Library General Public License as published by |
| 15 * the Free Software Foundation; either version 2 of the License, or |
15 * the Free Software Foundation; either version 2 of the License, or |
| 245 |
245 |
| 246 if (!ignored && skip_decomp) |
246 if (!ignored && skip_decomp) |
| 247 { |
247 { |
| 248 /* being UTF8 correct sucks; this accounts for extra |
248 /* being UTF8 correct sucks; this accounts for extra |
| 249 offsets coming from canonical decompositions of |
249 offsets coming from canonical decompositions of |
| 250 UTF8 characters (e.g. accented characters) which |
250 UTF8 characters (e.g. accented characters) which |
| 251 g_utf8_normalize() performs */ |
251 g_utf8_normalize() performs */ |
| 252 gchar *normal; |
252 gchar *normal; |
| 253 gchar buffer[6]; |
253 gchar buffer[6]; |
| 254 gint buffer_len; |
254 gint buffer_len; |
| 255 |
255 |
| 528 * @str: a search string. |
528 * @str: a search string. |
| 529 * @flags: flags affecting how the search is done. |
529 * @flags: flags affecting how the search is done. |
| 530 * @match_start: return location for start of match, or %%NULL. |
530 * @match_start: return location for start of match, or %%NULL. |
| 531 * @match_end: return location for end of match, or %%NULL. |
531 * @match_end: return location for end of match, or %%NULL. |
| 532 * @limit: bound for the search, or %%NULL for the end of the buffer. |
532 * @limit: bound for the search, or %%NULL for the end of the buffer. |
| 533 * |
533 * |
| 534 * Searches forward for @str. Any match is returned by setting |
534 * Searches forward for @str. Any match is returned by setting |
| 535 * @match_start to the first character of the match and @match_end to the |
535 * @match_start to the first character of the match and @match_end to the |
| 536 * first character after the match. The search will not continue past |
536 * first character after the match. The search will not continue past |
| 537 * @limit. Note that a search is a linear or O(n) operation, so you |
537 * @limit. Note that a search is a linear or O(n) operation, so you |
| 538 * may wish to use @limit to avoid locking up your UI on large |
538 * may wish to use @limit to avoid locking up your UI on large |
| 539 * buffers. |
539 * buffers. |
| 540 * |
540 * |
| 541 * If the #GTK_SOURCE_SEARCH_VISIBLE_ONLY flag is present, the match may |
541 * If the #GTK_SOURCE_SEARCH_VISIBLE_ONLY flag is present, the match may |
| 542 * have invisible text interspersed in @str. i.e. @str will be a |
542 * have invisible text interspersed in @str. i.e. @str will be a |
| 543 * possibly-noncontiguous subsequence of the matched range. similarly, |
543 * possibly-noncontiguous subsequence of the matched range. similarly, |
| 544 * if you specify #GTK_SOURCE_SEARCH_TEXT_ONLY, the match may have |
544 * if you specify #GTK_SOURCE_SEARCH_TEXT_ONLY, the match may have |
| 545 * pixbufs or child widgets mixed inside the matched range. If these |
545 * pixbufs or child widgets mixed inside the matched range. If these |
| 548 * If you specify the #GTK_SOURCE_SEARCH_CASE_INSENSITIVE flag, the text will |
548 * If you specify the #GTK_SOURCE_SEARCH_CASE_INSENSITIVE flag, the text will |
| 549 * be matched regardless of what case it is in. |
549 * be matched regardless of what case it is in. |
| 550 * |
550 * |
| 551 * Same as gtk_text_iter_forward_search(), but supports case insensitive |
551 * Same as gtk_text_iter_forward_search(), but supports case insensitive |
| 552 * searching. |
552 * searching. |
| 553 * |
553 * |
| 554 * Return value: whether a match was found. |
554 * Return value: whether a match was found. |
| 555 **/ |
555 **/ |
| 556 gboolean |
556 gboolean |
| 557 gtk_source_iter_forward_search (const GtkTextIter *iter, |
557 gtk_source_iter_forward_search (const GtkTextIter *iter, |
| 558 const gchar *str, |
558 const gchar *str, |
| 572 g_return_val_if_fail (str != NULL, FALSE); |
572 g_return_val_if_fail (str != NULL, FALSE); |
| 573 |
573 |
| 574 if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) |
574 if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) |
| 575 return gtk_text_iter_forward_search (iter, str, flags, |
575 return gtk_text_iter_forward_search (iter, str, flags, |
| 576 match_start, match_end, |
576 match_start, match_end, |
| 577 limit); |
577 limit); |
| 578 |
578 |
| 579 if (limit && gtk_text_iter_compare (iter, limit) >= 0) |
579 if (limit && gtk_text_iter_compare (iter, limit) >= 0) |
| 580 return FALSE; |
580 return FALSE; |
| 581 |
581 |
| 582 if (*str == '\0') |
582 if (*str == '\0') |
| 648 * @str: search string. |
648 * @str: search string. |
| 649 * @flags: bitmask of flags affecting the search. |
649 * @flags: bitmask of flags affecting the search. |
| 650 * @match_start: return location for start of match, or %%NULL. |
650 * @match_start: return location for start of match, or %%NULL. |
| 651 * @match_end: return location for end of match, or %%NULL. |
651 * @match_end: return location for end of match, or %%NULL. |
| 652 * @limit: location of last possible @match_start, or %%NULL for start of buffer. |
652 * @limit: location of last possible @match_start, or %%NULL for start of buffer. |
| 653 * |
653 * |
| 654 * Same as gtk_text_iter_backward_search(), but supports case insensitive |
654 * Same as gtk_text_iter_backward_search(), but supports case insensitive |
| 655 * searching. |
655 * searching. |
| 656 * |
656 * |
| 657 * Return value: whether a match was found. |
657 * Return value: whether a match was found. |
| 658 **/ |
658 **/ |
| 659 gboolean |
659 gboolean |
| 660 gtk_source_iter_backward_search (const GtkTextIter *iter, |
660 gtk_source_iter_backward_search (const GtkTextIter *iter, |
| 661 const gchar *str, |
661 const gchar *str, |
| 675 g_return_val_if_fail (str != NULL, FALSE); |
675 g_return_val_if_fail (str != NULL, FALSE); |
| 676 |
676 |
| 677 if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) |
677 if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) |
| 678 return gtk_text_iter_backward_search (iter, str, flags, |
678 return gtk_text_iter_backward_search (iter, str, flags, |
| 679 match_start, match_end, |
679 match_start, match_end, |
| 680 limit); |
680 limit); |
| 681 |
681 |
| 682 if (limit && gtk_text_iter_compare (iter, limit) <= 0) |
682 if (limit && gtk_text_iter_compare (iter, limit) <= 0) |
| 683 return FALSE; |
683 return FALSE; |
| 684 |
684 |
| 685 if (*str == '\0') |
685 if (*str == '\0') |