One window onto a text cache entry: the lines from offset, at most limit
of them, and never more bytes than the budget — whichever comes first.
Lines, because they are how a reader of text finds its way, and the byte budget because a line can be anything: a page stored as a single line of 190 000 bytes is real, and a window measured in lines alone would answer it whole. The budget is 24 000 bytes of text, measured before the answer is encoded — kept under the size at which a client stops showing a tool's answer inline and parks it in a file.
A line longer than what is left of the budget is never skipped. When it is
the window's first line it is cut at the budget, on a character boundary,
and next names the same line and the character to go on from (column,
counted in code points from 1); otherwise the window stops before it, and
next names it. A window that reaches the end answers next: nil.
Pure over its arguments: YmerNode.References.Cache hands it the text and
the reader's position, and the answer is what it serves.
Summary
Functions
The byte budget one window keeps to.
The window of text the options name — :offset (the first line, from 1),
:limit (a line count; as many as fit when absent), :column (the
character of the first line to start from, from 1) and :budget (bytes) —
answered with the text, where it starts, how many lines it holds, how many
the whole text has, and where the next window starts.
Functions
The byte budget one window keeps to.
The window of text the options name — :offset (the first line, from 1),
:limit (a line count; as many as fit when absent), :column (the
character of the first line to start from, from 1) and :budget (bytes) —
answered with the text, where it starts, how many lines it holds, how many
the whole text has, and where the next window starts.
Examples
iex> YmerNode.References.Cache.Window.take("a\nb\nc\n", offset: 2, limit: 1)
%{text: "b\n", offset: 2, lines: 1, total_lines: 3, next: %{offset: 3}}
iex> YmerNode.References.Cache.Window.take("abcdef\n", budget: 4)
%{text: "abcd", offset: 1, lines: 1, total_lines: 1, next: %{offset: 1, column: 5}}