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", "type": "prompt",
"alignment": "right", "alignment": "right",
"line_offset": -1, "vertical_offset": -1,
"segments": [ "segments": [
{ {
"type": "time", "type": "time",

View file

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

View file

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

View file

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