from typing import Sequence
from typing import Tuple
from typing import List


def _between(
    buf: Sequence[bytes],
    start: Tuple[int, int],
    end: Tuple[int, int],
) -> bytes:
    """Return the text between a given start and end point."""
    sline, scol = start
    eline, ecol = end

    lines: List[bytes] = []
    for idx, line in enumerate(buf[sline : eline + 1]):
        lcol = scol if idx == 0 else 0
        rcol = ecol + 1 if idx == eline - sline else len(line)
        lines.append(line[lcol:rcol])

    return b"\n".join(lines)