Thanks, this will require more time to properly review than I currently
have. What follows are therefore only a few general remarks.
> The code for the read/write loops communicating through a pipe with the
> external process is very ugly. There must be a better way to implement
> the pipe communication but I could not figure it out.
This is where a proper libuv based main loop would come in handy. Ideally
the editor core should remain responsive while the asynchronous I/O is beeing
done. There should be some kind of progress indication and a way to cancel
those long running tasks. Also while doing so the text should essentially
be marked read only.
> This approach uses a unnecessary amount of memory too since it keeps a lot
> of the input data for the external process
This should not be necessary, it should be possible to repeatedly call
text_range_write (ignoring for now that it always takes a snapshot) with
a resonable range which is adjusted each time.
> as well as its output data in memory at the same time
Similarly it should be possible to insert the data from the external process
as it becomes available. One idea is to write the new data after the
specified range which is being written out.
Assuming we want to process the range [10, 100] it would work as follows:
1) text_snapshot
2) while (data to write or data to read)
if (data to write)
write range [10, 20] (on next iteration [20, 30] etc ...)
if (data to read)
read range and insert into [100, 110] ([110, 120], ...)
3) read command exit status depending on success
- either delete original range [10, 100] and snapshot
- or revert to last snapshot (text_undo)
--
Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0
Received on Wed May 06 2015 - 21:47:00 CEST