mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
refactor: offsets match functionality
This commit is contained in:
parent
afaaace35b
commit
82c8483603
|
@ -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:
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue