refactor: understandable offset properties

This commit is contained in:
Jan De Dobbeleer 2020-09-26 08:17:30 +02:00 committed by Jan De Dobbeleer
parent 4fb33afd88
commit 9a508142fc
4 changed files with 9 additions and 9 deletions

View file

@ -3,7 +3,7 @@
{
"type": "prompt",
"alignment": "right",
"line_offset": -1,
"vertical_offset": -1,
"segments": [
{
"type": "time",

View file

@ -3,7 +3,7 @@
{
"type": "prompt",
"alignment": "right",
"line_offset": -1,
"vertical_offset": -1,
"segments": [
{
"type": "time",

View file

@ -111,14 +111,14 @@ func (e *engine) render() {
fmt.Print(e.renderer.lineBreak())
continue
}
if block.LineOffset != 0 {
fmt.Print(e.renderer.changeLine(block.LineOffset))
if block.VerticalOffset != 0 {
fmt.Print(e.renderer.changeLine(block.VerticalOffset))
}
switch block.Alignment {
case Right:
fmt.Print(e.renderer.carriageReturn())
blockText := e.renderBlockSegments(block)
cursorMove := e.renderer.setCursorForRightWrite(blockText, e.settings.RightSegmentOffset)
cursorMove := e.renderer.setCursorForRightWrite(blockText, block.VerticalOffset)
fmt.Print(cursorMove)
fmt.Print(blockText)
default:

View file

@ -8,9 +8,8 @@ import (
//Settings holds all the theme for rendering the prompt
type Settings struct {
RightSegmentOffset int `json:"right_segment_offset"`
EndSpaceEnabled bool `json:"end_space_enabled"`
Blocks []*Block `json:"blocks"`
EndSpaceEnabled bool `json:"end_space_enabled"`
Blocks []*Block `json:"blocks"`
}
//BlockType type of block
@ -36,7 +35,8 @@ type Block struct {
Alignment BlockAlignment `json:"alignment"`
PowerlineSeparator string `json:"powerline_separator"`
InvertPowerlineSeparatorColor bool `json:"invert_powerline_separator_color"`
LineOffset int `json:"line_offset"`
HorizontalOffset int `json:"horizontal_offset"`
VerticalOffset int `json:"vertical_offset"`
Segments []*Segment `json:"segments"`
}