Skip to content

💡 Border background color #68

@natemoo-re

Description

@natemoo-re

Is your feature request related to a problem?

A border can only carry a foreground color—there's no way to give it a background. The border op takes a single color, and every border cell is drawn with the terminal-default background, so you can't render a filled/banded border (e.g. white box-drawing glyphs on a blue band), and a border cell's foreground and background can't be set together. Border cells are the only painted surface that can't take a background—text and rects already emit \x1b[48;2;…m correctly.

Describe the solution you'd like

A bg on the border group that fills the border cells' background, alongside the existing color (foreground):

open("box", {
  border: {
    color: rgba(255, 255, 255),
    bg: rgba(0, 0, 255),
    top: 1,
    right: 1,
    bottom: 1,
    left: 1,
  },
});

Each border cell (edges and corners) then carries both the glyph in color and the bg background. The default must preserve today's behavior: with no bg, border cells emit no background SGR, exactly as now. Per-side background/color overrides are tracked separately.

Describe alternatives you've considered

We can fake a band by drawing a filled rect behind the border, but that doesn't color the border glyph cells themselves, breaks on corners, and fights the layout engine on sizing. There's no way to express "this box-drawing character on this background" without the renderer setting both on the cell.

Additional context

Failing test case on nm/repro/border-background (test · diff).

render_border pins every border cell's background to ATTR_DEFAULT (src/clayterm.c:303); setcell already writes a bg when supplied, so this mostly needs a bg word on the border op (ops.ts) threaded into render_border's setcell calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions