diff --git a/src/container.zig b/src/container.zig index a024096..e33e464 100644 --- a/src/container.zig +++ b/src/container.zig @@ -48,37 +48,41 @@ pub const Border = packed struct { std.debug.assert(frame.len == 6); // render top and bottom border - for (0..size.cols) |col| { - const last_row = @as(usize, size.rows - 1) * @as(usize, size.cols); - if (this.sides.left and col == 0) { - // top left corner - if (this.sides.top) cells[col].cp = frame[0]; - // bottom left corner - if (this.sides.bottom) cells[last_row + col].cp = frame[4]; - } else if (this.sides.right and col == size.cols - 1) { - // top right corner - if (this.sides.top) cells[col].cp = frame[2]; - // bottom left corner - if (this.sides.bottom) cells[last_row + col].cp = frame[5]; - } else { - // top side - if (this.sides.top) cells[col].cp = frame[1]; - // bottom side - if (this.sides.bottom) cells[last_row + col].cp = frame[1]; + if (this.sides.top or this.sides.bottom) { + for (0..size.cols) |col| { + const last_row = @as(usize, size.rows - 1) * @as(usize, size.cols); + if (this.sides.left and col == 0) { + // top left corner + if (this.sides.top) cells[col].cp = frame[0]; + // bottom left corner + if (this.sides.bottom) cells[last_row + col].cp = frame[4]; + } else if (this.sides.right and col == size.cols - 1) { + // top right corner + if (this.sides.top) cells[col].cp = frame[2]; + // bottom left corner + if (this.sides.bottom) cells[last_row + col].cp = frame[5]; + } else { + // top side + if (this.sides.top) cells[col].cp = frame[1]; + // bottom side + if (this.sides.bottom) cells[last_row + col].cp = frame[1]; + } + if (this.sides.top) cells[col].style.fg = this.color; + if (this.sides.bottom) cells[last_row + col].style.fg = this.color; } - if (this.sides.top) cells[col].style.fg = this.color; - if (this.sides.bottom) cells[last_row + col].style.fg = this.color; } // render left and right border - for (1..size.rows -| 1) |row| { - const idx = (row * size.cols); - if (this.sides.left) { - cells[idx].cp = frame[3]; // left - cells[idx].style.fg = this.color; - } - if (this.sides.right) { - cells[idx + size.cols - 1].cp = frame[3]; // right - cells[idx + size.cols - 1].style.fg = this.color; + if (this.sides.left or this.sides.right) { + for (1..size.rows -| 1) |row| { + const idx = (row * size.cols); + if (this.sides.left) { + cells[idx].cp = frame[3]; // left + cells[idx].style.fg = this.color; + } + if (this.sides.right) { + cells[idx + size.cols - 1].cp = frame[3]; // right + cells[idx + size.cols - 1].style.fg = this.color; + } } } }