[ Widgets ]
Fill and Clear
koto::Fill fills a rectangular area with a repeated codepoint, foreground/background colors, and an optional id tag, while koto::Clear resets an area to spaces (U' ') with COLOR_DEFAULT colors (Header: koto/fill.hpp).
Quick example
Section titled “Quick example”Fill(Color::DarkGray) .fg(Color::Cyan) .char_code(U'.') .id(Id("backdrop")) .draw(frame, fill_area);................................................................................................Behavior
Section titled “Behavior”Fill::draw(frame, area): Callsframe.fill(area, m_ch, m_fg, m_bg, m_tag_id)(src/fill.cpp:35-38), which writesCell{m_ch, m_fg, m_bg, 1, false}to every coordinate inareaand, ifm_tag_idis notId::none(), stampsm_hit_bufferand updatesm_tag_bounds.Clear::draw(frame, area): Callsframe.fill(area, U' ', COLOR_DEFAULT, COLOR_DEFAULT, m_tag_id)(src/fill.cpp:46-49), resetting every cell inareato a default blank space and optionally tagging the region withm_tag_id.
Methods
Section titled “Methods”Fill methods
Section titled “Fill methods”| Method | Description | Default |
|---|---|---|
Fill() | Default-constructs a Fill widget with U' ' and COLOR_DEFAULT colors. | m_ch = U' ', m_fg = COLOR_DEFAULT, m_bg = COLOR_DEFAULT |
Fill(Color bg) | Explicit constructor setting m_bg = bg.value. | m_ch = U' ', m_fg = COLOR_DEFAULT |
bg(Color color) | Sets the fill background color. | COLOR_DEFAULT |
fg(Color color) | Sets the fill character foreground color. | COLOR_DEFAULT |
char_code(char32_t ch) | Sets the codepoint written to each cell. | U' ' |
id(Id id) | Sets the id token stamped into the hit buffer across area. | Id::none() |
draw(Frame& frame, Area area) | Fills area in frame. | None |
Clear methods
Section titled “Clear methods”| Method | Description | Default |
|---|---|---|
Clear() | Default-constructs a Clear widget. | m_tag_id = Id::none() |
id(Id id) | Sets the id token stamped into the hit buffer across area. | Id::none() |
draw(Frame& frame, Area area) | Resets area in frame to U' ' with COLOR_DEFAULT foreground and background. | None |
Gotchas
Section titled “Gotchas”Fill::char_codeuses width 1 inFrame::fill:Frame::fill(area, m_ch, m_fg, m_bg, m_tag_id)constructsCell{ch, fg, bg, 1, false}(src/frame.cpp:167-170), whichFrame::set_cellpromotes to width 2 ifcodepoint_width(ch) == 2. Avoid passing a 2-column CJK or emoji codepoint toFill::char_code, becauseFrame::fillstepscolby 1 across every column and each column will overwrite the continuation cell of the previous column.