def compute_region_border(start, end):
    """
    given the buffer start and end indices of a range, compute the border edges
      that should be drawn to enclose the range.

    this function currently assumes 0x10 length rows.
    the result is a dictionary from buffer index to Cell instance.
    the Cell instance has boolean properties "top", "bottom", "left", and "right"
      that describe if a border should be drawn on that side of the cell view.
    :rtype: Mapping[int, CellT]
    """
    cells = defaultdict(Cell)

    start_row = row_number(start)
    end_row = row_number(end)
    if end % 0x10 == 0:
        end_row -= 1

    ## topmost cells
    if start_row == end_row:
        for i in range(start, end):
            cells[i].top = True
    else:
        for i in range(start, row_end_index(start) + 1):
            cells[i].top = True
    # cells on second row, top left
    if start_row != end_row:
        next_row_start = row_start_index(start) + 0x10
        for i in range(next_row_start, next_row_start + column_number(start)):
            cells[i].top = True

    ## bottommost cells
    if start_row == end_row:
        for i in range(start, end):
            cells[i].bottom = True
    else:
        for i in range(row_start_index(end), end):
            cells[i].bottom = True
    # cells on second-to-last row, bottom right
    if start_row != end_row:
        prev_row_end = row_end_index(end) - 0x10
        for i in range(prev_row_end - (0x10 - column_number(end) - 1), prev_row_end + 1):
            cells[i].bottom = True

    ## leftmost cells
    if start_row == end_row:
        cells[start].left = True
    else:
        second_row_start = row_start_index(start) + 0x10
        for i in range(second_row_start, row_start_index(end) + 0x10, 0x10):
            cells[i].left = True
    # cells in first row, top left
    if start_row != end_row:
        cells[start].left = True

    ## rightmost cells
    if start_row == end_row:
        cells[end - 1].right = True
    else:
        penultimate_row_end = row_end_index(end) - 0x10
        for i in range(row_end_index(start), penultimate_row_end + 0x10, 0x10):
            cells[i].right = True
    # cells in last row, bottom right
    if start_row != end_row:
        cells[end - 1].right = True

    # convert back to standard dict
    # trick from: http://stackoverflow.com/a/20428703/87207
    cells.default_factory = None
    return cells
given the buffer start and end indices of a range, compute the border edges
      that should be drawn to enclose the range.

    this function currently assumes 0x10 length rows.
    the result is a dictionary from buffer index to Cell instance.
    the Cell instance has boolean properties "top", "bottom", "left", and "right"
      that describe if a border should be drawn on that side of the cell view.
    :rtype: Mapping[int, CellT]