about summary refs log blame commit diff stats
path: root/real-files.mu
blob: 7e50ac8eb485d8b1ff66d4251f93ebfbd8ccf353 (plain) (tree)
w"> ctx.viewport.Size() if x >= width || y >= height { panic(fmt.Errorf("Attempted to draw outside of context")) } str := fmt.Sprintf(format, a...) old_x := x newline := func() bool { x = old_x y++ return y < height } for _, ch := range str { switch ch { case '\n': if !newline() { return runewidth.StringWidth(str) } case '\r': x = old_x default: crunes := []rune{} ctx.viewport.SetContent(x, y, ch, crunes, style) x += runewidth.RuneWidth(ch) if x == old_x+width { if !newline() { return runewidth.StringWidth(str) } } } } return runewidth.StringWidth(str) } func (ctx *Context) Fill(x, y, width, height int, rune rune, style tcell.Style) { vp := views.NewViewPort(ctx.viewport, x, y, width, height) vp.Fill(rune, style) } func (ctx *Context) SetCursor(x, y int) { // FIXME: Cursor needs to be set on tcell.Screen, or layout has to // provide a CellModel // cv := views.NewCellView() // cv.Init() // cv.SetView(ctx.viewport) // cv.SetCursor(x, y) }