crystallabs/crysterm

Fix border drawing when border width or height == 0

Opened this issue · 1 comments

The code previously supported either having no border on a particular side, or having a border of 1 cell.
But now border can be of arbitrary width/height, and also a particular side can have border of width or height 0.

Somewhere inside src/widget_rendering.cr#_render there is a part titled "Draw borders".
Its code works on the assumption that if there is a border, its width/height is 1 cell. Having a border of 0c makes the border not show up, but it does overwrite the text in the line.

The part that the code reaches is near the end of the function:

          if (border.bottom == 0) && x != xi && x != xl - 1
            ch = ' '
            if cell != {default_attr, ch}
              lines[y][x].attr = default_attr
              lines[y][x].char = (ch || ' ')
              lines[y].dirty = true
            end
            next
          end     

This code should be adjusted so that a border of 0 on a particular side behaves identically as the no* setting on that side (e.g. like notop or noleft).

When resolved, also update Style#border to have a non-nil border object.