func (rg Range) Column(x int) Range {
	if rg.Min.Shift(x, 0).In(rg) {
		rg.Min.X = rg.Min.X + x
		rg.Max.X = rg.Min.X + 1
	} else {
		rg = Range{}
	}
	return rg
}
Column reduces the range to relative column x, or an empty range if out of
bounds.
package gruid
import (
	"fmt"
	"strings"
	"time"
)
type AttrMask uint32
const AttrsDefault AttrMask = 0
type Color uint32
const ColorDefault Color = 0
type Cell struct {
	Rune  rune   
	Style Style  
}
func (c Cell) WithRune(r rune) Cell {
	c.Rune = r
	return c
}
func (c Cell) WithStyle(st Style) Cell {
	c.Style = st
	return c
}
type Style struct {
	Fg    Color     
	Bg    Color     
	Attrs AttrMask  
}
func (st Style) WithFg(cl Color) Style {
	st.Fg = cl
	return st
}
func (st Style) WithBg(cl Color) Style {
	st.Bg = cl
	return st
}
func (st Style) WithAttrs(attrs AttrMask) Style {
	st.Attrs = attrs
	return st
}
type Point struct {
	X int
	Y int
}
func (p Point) String() string {
	return fmt.Sprintf("(%d,%d)", p.X, p.Y)
}
func (p Point) Shift(x, y int) Point {
	return Point{X: p.X + x, Y: p.Y + y}
}
func (p Point) Add(q Point) Point {
	return Point{X: p.X + q.X, Y: p.Y + q.Y}
}
func (p Point) Sub(q Point) Point {
	return Point{X: p.X - q.X, Y: p.Y - q.Y}
}
func (p Point) In(rg Range) bool {
	return p.X >= rg.Min.X && p.X < rg.Max.X && p.Y >= rg.Min.Y && p.Y < rg.Max.Y
}
func (p Point) Mul(k int) Point {
	return Point{X: p.X * k, Y: p.Y * k}
}
func (p Point) Div(k int) Point {
	return Point{X: p.X / k, Y: p.Y / k}
}
type Range struct {
	Min, Max Point
}
func NewRange(x0, y0, x1, y1 int) Range {
	if x1 < x0 {
		x0, x1 = x1, x0
	}
	if y1 < y0 {
		y0, y1 = y1, y0
	}
	return Range{Min: Point{X: x0, Y: y0}, Max: Point{X: x1, Y: y1}}
}
func (rg Range) String() string {
	return fmt.Sprintf("%s-%s", rg.Min, rg.Max)
}
func (rg Range) Size() Point {
	return rg.Max.Sub(rg.Min)
}
func (rg Range) Shift(x0, y0, x1, y1 int) Range {
	rg = Range{Min: rg.Min.Shift(x0, y0), Max: rg.Max.Shift(x1, y1)}
	if rg.Empty() {
		return Range{}
	}
	return rg
}
func (rg Range) Line(y int) Range {
	if rg.Min.Shift(0, y).In(rg) {
		rg.Min.Y = rg.Min.Y + y
		rg.Max.Y = rg.Min.Y + 1
	} else {
		rg = Range{}
	}
	return rg
}
func (rg Range) Lines(y0, y1 int) Range {
	nrg := rg
	nrg.Min.Y = rg.Min.Y + y0
	nrg.Max.Y = rg.Min.Y + y1
	return rg.Intersect(nrg)
}