Partial line, and any held comment lines, from the last chunk
Newly read chunk of G-code text
complete, ready to parse, and the new tail
The returned tail excludes the newline itself, so prepending it to the
next chunk never fabricates an empty line at a chunk boundary.
complete keeps its final newline: every newline in it terminates one
line, which is exactly how the parser reads strings. A trailing newline
would otherwise be ambiguous — 'A\n' completing lines A and '' here,
but line A alone in a whole-file parse.
A chunk containing no newline at all completes nothing: complete is empty
(which parses to zero lines) and the whole chunk is carried into the tail,
so a line is only ever parsed once its terminating newline (or the end of
the stream) has arrived.
Comment lines that end a chunk are carried too. A slicer describes a layer
in a run of them -- ;LAYER_CHANGE, then ;Z:, then ;HEIGHT: -- and a
chunk ends wherever the bytes ran out, so the description can be cut in
half. Whatever reads the comments would then see a layer whose values are
in the next chunk. A run of comments is never the end of anything, so
holding it costs nothing: the G-code line that closes it brings it along.
Splits a streamed chunk into the lines that are complete and the part to carry into the next chunk.