refactor: offsets match functionality

This commit is contained in:
Jan De Dobbeleer 2020-09-26 20:25:47 +02:00 committed by Jan De Dobbeleer
parent afaaace35b
commit 82c8483603
2 changed files with 4 additions and 4 deletions

View file

@ -120,9 +120,9 @@ func (e *engine) render() {
} }
switch block.Alignment { switch block.Alignment {
case Right: case Right:
fmt.Print(e.renderer.carriageReturn()) fmt.Print(e.renderer.carriageForward())
blockText := e.renderBlockSegments(block) blockText := e.renderBlockSegments(block)
cursorMove := e.renderer.setCursorForRightWrite(blockText, block.VerticalOffset) cursorMove := e.renderer.setCursorForRightWrite(blockText, block.HorizontalOffset)
fmt.Print(cursorMove) fmt.Print(cursorMove)
fmt.Print(blockText) fmt.Print(blockText)
default: default:

View file

@ -124,12 +124,12 @@ func (r *Renderer) lineBreak() string {
return r.formats.linebreak return r.formats.linebreak
} }
func (r *Renderer) carriageReturn() string { func (r *Renderer) carriageForward() string {
return fmt.Sprintf(r.formats.left, 1000) return fmt.Sprintf(r.formats.left, 1000)
} }
func (r *Renderer) setCursorForRightWrite(text string, offset int) string { func (r *Renderer) setCursorForRightWrite(text string, offset int) string {
strippedLen := r.lenWithoutANSI(text) + offset strippedLen := r.lenWithoutANSI(text) + -offset
return fmt.Sprintf(r.formats.right, strippedLen) return fmt.Sprintf(r.formats.right, strippedLen)
} }