Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
This affects a few apis, such as gtk_text_iter_get_pixbuf,
gtk_text_buffer_insert_pixbuf and GtkTextBuffer::insert-pixbuf,
which have all been replaced by texture equivalents.
Update all callers.
gtk_text_iter_backward_line() checks the value of
real->line_char_offset without previously calling
ensure_char_offsets (real) to make sure the former
is up-to-date.
As a consequence of this, when gtk_text_iter_backward_line()
is called after a gtk_text_buffer_insert_range() in the
first line of buffer, the iter is not moved to the start of
the line, and the return value is wrong.
Fixed by adding the ensure_char_offsets() call.
A test case for this bug is added to the textiter gtk testsuite.
This is a problematic struct, and giving direct access to it
has kept us from making improvements to GtkTextView. Drop it
from the public API, together with the auxiliary APIs. If
it turns out that this functionality is needed, we should add
individual getters.
The name gtk_text_*_begins_* was used only for begins_tag(). All other
similar functions use "starts": starts_line(), starts_word(), etc.
So for consistency, add gtk_text_iter_starts_tag() and deprecate
gtk_text_iter_begins_tag().
Also change (allow-none) to (nullable), to use the new annotation.
https://bugzilla.gnome.org/show_bug.cgi?id=759092
'win.lines' contains the same content as the GtkTextBuffer, so to find
@match_start, forward_chars_with_skipping() is called with
skip_decomp=FALSE (the last parameter). So far so good.
On the other hand, the content 'lines' (the needle split in lines) is
casefolded and normalized for a case insensitive search. So,
forward_chars_with_skipping(..., skip_decomp=TRUE) must be called only
for the portion of text containing the needle.
Since 'start_tmp' contains the location at the start of the match, we
can simply begin at that location to find the end of the match.
Unit tests are added.
https://bugzilla.gnome.org/show_bug.cgi?id=758698
If the last tag toggle is the end iter, the function returned the wrong
tag toggle.
This resulted in some bugs where the view wasn't relayout/redrawn
correctly.
The function also always returned TRUE, probably because the return
value is used nowhere. But for consistency with
_gtk_text_btree_get_iter_at_first_toggle(), it's better to keep the
return value, and also because otherwise the function would be wrong (it
doesn't always return a tag toggle, if there is none).
https://bugzilla.gnome.org/show_bug.cgi?id=755413
NULL was returned in case of an empty last line. Every users needed to
special-case this. Now it will return the expected result: char_len of 0
with one PangoLogAttr.
In compute_log_attrs(), 'paragraph' will be the empty string "" with
'char_len' == 0.
pango_get_log_attrs() works fine with an empty string, it will return
one correct PangoLogAttr (because there is one text position for the
empty string).
It fixes the unit tests for gtk_text_iter_is_cursor_position().
https://bugzilla.gnome.org/show_bug.cgi?id=156164
- only one blank line is enough to separate code sections.
- the 'signals' variable was in the middle of function prototypes.
- compare pointers to NULL in some conditions ("if(blah) should be used
only if blah is a boolean variable). It makes the code clearer.
- various other things.
find_by_log_attrs() can return true only in this case:
return moved && !gtk_text_iter_is_end (arg_iter);
So if the iter moved (i.e. something has been found), but is the end
iter, find_by_log_attrs() returns false.
Now the same checks are made in find_visible_by_log_attrs(). The public
functions using find_visible_by_log_attrs() say in their documentation
that false is returned for the end iter, hence the check with
gtk_text_iter_is_end().
https://bugzilla.gnome.org/show_bug.cgi?id=618852
attrs[len] is the last PangoLogAttr available, at the iter position after the
last character of the line.
For a line in the middle or the start of the buffer, the '\n' is taken
into account by 'len'. For example the is_word_end is generally reached
before the '\n', not after. But for the last line in the buffer, where
there is no trailing '\n', it is important to test until attrs[len].
The bug didn't occur before because find_by_log_attrs() worked directly
on the iter passed as the function argument. But now it is no longer the
case.
https://bugzilla.gnome.org/show_bug.cgi?id=618852
- Return true (found) and false (not found) explicitly.
- Set found_offset only when something has been found.
find_backward_cursor_pos_func() was a bit different, the while loop had
the condition "offset > 0" but the return was "offset >= 0". Probably a
micro-optimization, since offset == 0 is always a cursor position.
Anyway now the code is the same as the other functions.
https://bugzilla.gnome.org/show_bug.cgi?id=618852
Do not work with the iter passed as the function argument. Work with
another iter, and set it back to the function argument only if something
has been found.
This fixes a few unit tests. But there are regressions for a few others.
https://bugzilla.gnome.org/show_bug.cgi?id=618852
Use gtk_text_iter_set_line_offset (&tmp_iter, 0) instead of
gtk_text_iter_get_line(). The difference should not be big. In the first
case the line doesn't need to be traversed thanks to the offset 0. For
get_line(), the btree must be traversed.
A temporary iter is needed to not break the behavior. But the behavior
is quite strange, the function works directly on the iter passed as an
argument to the function, even if the function returns FALSE (not
found). So maybe a later commit will fix this strange behavior.
https://bugzilla.gnome.org/show_bug.cgi?id=629129
find_by_log_attrs() was a recursive function. It is replaced by an
iteration.
The already_moved_initially parameter was TRUE only for the recursive
call, so the paramater is removed.
There is also a small cleanup of the find_visible_by_log_attrs()
(remove trailing spaces, fix indentation).
There is still a part to optimize for a later commit.
https://bugzilla.gnome.org/show_bug.cgi?id=629129
There is a possible confusion with the sentence:
"@iter is inside a natural-language word"
The iter should be viewed here as the pointed character (i.e. on the
right of the iter), not as a position between two characters.
Instead of improving the documentation, another solution would have been
to change the implementation so it is interpreted as an iter position
inside a word, i.e. between two characters that are part of a
natural-language word. But maybe some applications rely on the current
implementation.
https://bugzilla.gnome.org/show_bug.cgi?id=727908
When the search is case sensitive, g_utf8_normalize() is not called, so
the skip_decomp argument of the function forward_chars_with_skipping()
must be FALSE.
To verify that, when searching "éb", the count parameter of
forward_chars_with_skipping() have a different value:
- case sensitive: count = 2
- case insensitive: count = 3 (g_utf8_normalize() has been called)
The commit adds unit tests that didn't pass before, and that now pass
(without known regression, obviously).
https://bugzilla.gnome.org/show_bug.cgi?id=702977
The function must return TRUE only if there is a tag toggle _after_ the
iter, not _at_ the iter. So for the end iter, the function must always
return FALSE.
Add also unit tests for gtk_text_iter_forward_to_tag_toggle().
https://bugzilla.gnome.org/show_bug.cgi?id=691266
It was not possible to know if the @limit was for @match_start or
@match_end. It was documented for backward_search(), but not for
forward_search().
https://bugzilla.gnome.org/show_bug.cgi?id=390048
For gtk_text_iter_get_char(), due to the "Returns" at the beginning of
the description, the description was not visible. So the first sentence
has been reworded.