Re: [gedit-list] Reading document content, iteratively, from plugins



On Sun, Oct 27, 2013 at 08:17:09AM -0400, Dustin Oprea wrote:
The question is about how to iteratively read lines of text from the
document. Do you have experience with this?

Line by line is a good choice. But if you don't want to block the UI (by 
running the "save as" in an idle loop, chunk by chunk, for example), the 
document can be modified during the save. It's simpler to save 
synchronously, so the document can not be modified.

If you want to take into account the encoding, the line ending type and 
some other flags, you will end up with the gedit document saver:
https://git.gnome.org/browse/gedit/tree/gedit/gedit-document-saver.h

A plan is to make the document loader and saver reusable. For example by 
moving the code in GtkSourceView. The API must be a little modified 
(e.g. to support your use case).

As to your particular answer, I am saving through alternate means because I
am not allowed [in my use-case] to induce any changes or side-effects to
the current location.

You can save the location before the "save as", and then restore the 
location, but I agree it's not fantastic.

Hope this helps,
Sébastien


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]