My GSoC on GtkSourceView/gedit/… is coming along nicely. Here is a screenshot of the new search in gedit:
The visible new thing is the “298 of 703″ in the search entry, that shows the position of the current search match, and the total number of occurrences. This is just the tip of the iceberg, as much of the work has been done under the hood. Ignacio (nacho), my mentor, has improved GdTaggedEntry, and I worked on the new API in GtkSourceView, and adapted gedit to use the new API.
Note: almost all my work has already been merged upstream, but not the new search entry.
Search and replace API in GtkSourceView
The new API in GtkSourceView is available. One thing is missing though: regex search.
Why you should use this API:
- It is asynchronous, i.e. the user interface is normally not blocked when the
GtkTextBufferis scanned. And the asynchronous overhead is small;
- The search matches are highlighted;
- You can get the total number of occurrences and the position of a certain occurrence easily;
- For each search, the buffer is scanned at most once. Once the search occurrences are found, navigating through them doesn’t require to re-scan the buffer, thanks to
gtk_text_iter_forward_to_tag_toggle(). As a result, most operations are really fast;
- The regex search (still to come) will normally do multi-segment matching, also called incremental matching: when a partial match is returned, we take a bigger segment. No need to waste memory space to retrieve the entire buffer contents.
Nice, isn’t it?