mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
refactor: understandable offset properties
This commit is contained in:
parent
4fb33afd88
commit
9a508142fc
|
@ -3,7 +3,7 @@
|
||||||
{
|
{
|
||||||
"type": "prompt",
|
"type": "prompt",
|
||||||
"alignment": "right",
|
"alignment": "right",
|
||||||
"line_offset": -1,
|
"vertical_offset": -1,
|
||||||
"segments": [
|
"segments": [
|
||||||
{
|
{
|
||||||
"type": "time",
|
"type": "time",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{
|
{
|
||||||
"type": "prompt",
|
"type": "prompt",
|
||||||
"alignment": "right",
|
"alignment": "right",
|
||||||
"line_offset": -1,
|
"vertical_offset": -1,
|
||||||
"segments": [
|
"segments": [
|
||||||
{
|
{
|
||||||
"type": "time",
|
"type": "time",
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue