<commit_before>package termui

import (
	"github.com/nsf/termbox-go"
)

var rootrenderer = Renderer{0, 0, nil, termbox.ColorDefault, termbox.ColorDefault}

// Renderer helps drawing an element
type Renderer struct {
	x, y   int
	cur    Element
	fg, bg termbox.Attribute
}

// Set the given rune at a relative x and y position
func (r Renderer) Set(x, y int, ch rune) {
	termbox.SetCell(x+r.x, y+r.y, ch, r.fg, r.bg)
}

// SetAttr sets the given rune at a relative x and y position and applys the attribute to the foreground.
// This can be used to invert or underline a cell.
func (r Renderer) SetAttr(x, y int, ch rune, attr termbox.Attribute) {
	termbox.SetCell(x+r.x, y+r.y, ch, r.fg|attr, r.bg)
}

// RenderChild draws the given child.
func (r Renderer) RenderChild(e Element, width, height, xOffset, yOffset int) {
	elW, elH := e.Width(), e.Height()

	gravity := GravityProperty.Get(e)
	fg := ForegroundProperty.Get(e)
	bg := BackgroundProperty.Get(e)

	switch gravity & horizontal {
	case Left, Left | Right:
		xOffset += 0
	case Right:
		xOffset += width - elW
	case NoGravity:
		xOffset += (width - elW) / 2
	}
	switch gravity & vertical {
	case Top, Top | Bottom:<commit_msg>fill child area with background color<commit_after>package termui

import (
	"github.com/nsf/termbox-go"
)

var rootrenderer = Renderer{0, 0, nil, termbox.ColorDefault, termbox.ColorDefault}

// Renderer helps drawing an element
type Renderer struct {
	x, y   int
	cur    Element
	fg, bg termbox.Attribute
}

// Set the given rune at a relative x and y position
func (r Renderer) Set(x, y int, ch rune) {
	termbox.SetCell(x+r.x, y+r.y, ch, r.fg, r.bg)
}

// SetAttr sets the given rune at a relative x and y position and applys the attribute to the foreground.
// This can be used to invert or underline a cell.
func (r Renderer) SetAttr(x, y int, ch rune, attr termbox.Attribute) {
	termbox.SetCell(x+r.x, y+r.y, ch, r.fg|attr, r.bg)
}

// RenderChild draws the given child.
func (r Renderer) RenderChild(e Element, width, height, xOffset, yOffset int) {
	elW, elH := e.Width(), e.Height()

	gravity := GravityProperty.Get(e)
	fg := ForegroundProperty.Get(e)
	bg := BackgroundProperty.Get(e)

	for x := xOffset; x < xOffset+width; x++ {
		for y := yOffset; y < yOffset+height; y++ {
			r.Set(x, y, ' ')
		}
	}

	switch gravity & horizontal {
	case Left, Left | Right:
		xOffset += 0
	case Right:
		xOffset += width - elW
	case NoGravity:
		xOffset += (width - elW) / 2
	}
	switch gravity & vertical {
	case Top, Top | Bottom:
{'fraction_non_alphanumeric': 0.12310756972111554, 'fraction_numerical': 0.0031872509960159364, 'mean_word_length': 3.590493601462523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1288851', 'n_tokens_mistral': 937, 'n_tokens_neox': 913, 'n_words': 312}