def window(values, index, delta):
    """
    Extract 1+2*`delta` items from `values` centered at `index` and return a tuple with
    (items, left, right).

    This function tries to simulate a physical slider, meaning the number of extracted elements is
    constant but the centering at `index` is not guaranteed.

    A visual example with 6 `values` and ``delta=1``::

        index = 0  [+++]---  left = 0, right = 2
        index = 1  [+++]---  left = 0, right = 2
        index = 2  -[+++]--  left = 1, right = 3
        index = 3  --[+++]-  left = 2, right = 4
        index = 4  ---[+++]  left = 3, right = 5
        index = 5  ---[+++]  left = 3, right = 5

    **Example usage**

    >>> from pytoolbox.unittest import asserts
    >>> eq = asserts.equal
    >>> eq(window(['a'], 0, 2), (['a'], 0, 0))
    >>> eq(window(['a', 'b', 'c', 'd'], 2, 0), (['c'], 2, 2))
    >>> eq(window(['a', 'b', 'c', 'd', 'e'], 0, 1), (['a', 'b', 'c'], 0, 2))
    >>> eq(window(['a', 'b', 'c', 'd', 'e'], 1, 1), (['a', 'b', 'c'], 0, 2))
    >>> eq(window(['a', 'b', 'c', 'd', 'e'], 2, 1), (['b', 'c', 'd'], 1, 3))
    >>> eq(window(['a', 'b', 'c', 'd', 'e'], 3, 1), (['c', 'd', 'e'], 2, 4))
    >>> eq(window(['a', 'b', 'c', 'd', 'e'], 4, 1), (['c', 'd', 'e'], 2, 4))
    >>> eq(window(['a', 'b', 'c', 'd', 'e'], 3, 6), (['a', 'b', 'c', 'd', 'e'], 0, 4))
    >>> eq(window(list(range(20)), 6, 6), ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 0, 12))
    >>> eq(window(list(range(20)), 7, 6), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 1, 13))
    >>> eq(window(list(range(20)), 10, 6), ([4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 4, 16))
    >>> eq(window(list(range(20)), 19, 6), ([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], 7, 19))
    """
    length = len(values)
    left, right = index - delta, index + delta
    if left < 0:
        left, right = 0, right - left
    elif right >= length:
        left, right = left - right + length - 1, length - 1
    left, right = max(left, 0), min(right, length - 1)
    return values[left:right + 1], left, right
