def shift_line(segs, amount):
    """
    Return a shifted line from a layout structure to the left or right.
    segs -- line of a layout structure
    amount -- screen columns to shift right (+ve) or left (-ve)
    """
    assert type(amount) == int, repr(amount)
    if segs and len(segs[0]) == 2 and segs[0][1] == None:
        amount += segs[0][0]
        if amount:
            return [(amount, None)] + segs[1:]
        return segs[1:]
    if amount:
        return [(amount, None)] + segs
    return segs
