feat: deprecate offset properties

This commit is contained in:
Jan De Dobbeleer 2022-07-03 10:54:52 +02:00 committed by Jan De Dobbeleer
parent 2710f79613
commit 9f9b91e566
7 changed files with 19 additions and 41 deletions

View file

@ -36,14 +36,16 @@ const (
// Block defines a part of the prompt with optional segments // Block defines a part of the prompt with optional segments
type Block struct { type Block struct {
Type BlockType `json:"type,omitempty"` Type BlockType `json:"type,omitempty"`
Alignment BlockAlignment `json:"alignment,omitempty"` Alignment BlockAlignment `json:"alignment,omitempty"`
HorizontalOffset int `json:"horizontal_offset,omitempty"` Segments []*Segment `json:"segments,omitempty"`
VerticalOffset int `json:"vertical_offset,omitempty"` Newline bool `json:"newline,omitempty"`
Segments []*Segment `json:"segments,omitempty"` Filler string `json:"filler,omitempty"`
Newline bool `json:"newline,omitempty"` Overflow Overflow `json:"overflow,omitempty"`
Filler string `json:"filler,omitempty"`
Overflow Overflow `json:"overflow,omitempty"` // Deprecated: keep the logic for legacy purposes
HorizontalOffset int `json:"horizontal_offset,omitempty"`
VerticalOffset int `json:"vertical_offset,omitempty"`
env environment.Environment env environment.Environment
writer color.Writer writer color.Writer

View file

@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [ "blocks": [
{ {
"alignment": "right", "type": "rprompt",
"segments": [ "segments": [
{ {
"foreground": "#007ACC", "foreground": "#007ACC",
@ -13,13 +13,10 @@
"template": " {{ .CurrentDate | date .Format }} ", "template": " {{ .CurrentDate | date .Format }} ",
"type": "time" "type": "time"
} }
], ]
"type": "prompt",
"vertical_offset": -1
}, },
{ {
"alignment": "left", "alignment": "left",
"newline": true,
"segments": [ "segments": [
{ {
"background": "#ffffff", "background": "#ffffff",

View file

@ -38,8 +38,7 @@
"type": "git" "type": "git"
} }
], ],
"type": "prompt", "type": "prompt"
"vertical_offset": 1
}, },
{ {
"alignment": "right", "alignment": "right",
@ -67,7 +66,7 @@
"always_enabled": true "always_enabled": true
}, },
"style": "plain", "style": "plain",
"template": " {{ if gt .Code 0 }}<#ff0000>\uf00d \ue23a</>{{ else }}<#23d18b>\uf42e \ue23a</>{{ end }} ", "template": " {{ if gt .Code 0 }}<#ff0000>\uf00d</>{{ else }}<#23d18b>\uf42e</>{{ end }} ",
"type": "exit" "type": "exit"
}, },
{ {

View file

@ -2,7 +2,6 @@
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [ "blocks": [
{ {
"alignment": "right",
"segments": [ "segments": [
{ {
"foreground": "#00C5C7", "foreground": "#00C5C7",
@ -14,12 +13,10 @@
"type": "time" "type": "time"
} }
], ],
"type": "prompt", "type": "rprompt"
"vertical_offset": -1
}, },
{ {
"alignment": "left", "alignment": "left",
"newline": true,
"segments": [ "segments": [
{ {
"foreground": "#77E4F7", "foreground": "#77E4F7",

View file

@ -171,16 +171,6 @@
"description": "https://ohmyposh.dev/docs/configuration/block#newline", "description": "https://ohmyposh.dev/docs/configuration/block#newline",
"default": false "default": false
}, },
"vertical_offset": {
"type": "integer",
"title": "Block vertical offset",
"description": "https://ohmyposh.dev/docs/configuration/block#vertical-offset"
},
"horizontal-offset": {
"type": "integer",
"title": "Block vertical offset",
"description": "https://ohmyposh.dev/docs/configuration/block#horizontal-offset"
},
"segments": { "segments": {
"type": "array", "type": "array",
"title": "Segments list, prompt elements to display based on context", "title": "Segments list, prompt elements to display based on context",

View file

@ -66,8 +66,7 @@
"type": "executiontime" "type": "executiontime"
} }
], ],
"type": "prompt", "type": "prompt"
"vertical_offset": 1
}, },
{ {
"alignment": "left", "alignment": "left",

View file

@ -23,7 +23,6 @@ import TabItem from "@theme/TabItem"
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [ "blocks": [
{ {
"alignment": "right",
"segments": [ "segments": [
{ {
"foreground": "#007ACC", "foreground": "#007ACC",
@ -35,8 +34,7 @@ import TabItem from "@theme/TabItem"
"type": "time" "type": "time"
} }
], ],
"type": "prompt", "type": "rprompt",
"vertical_offset": -1
}, },
{ {
"alignment": "left", "alignment": "left",
@ -115,7 +113,7 @@ import TabItem from "@theme/TabItem"
```yaml ```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json # yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
blocks: blocks:
- alignment: right - type: rprompt
segments: segments:
- foreground: "#007ACC" - foreground: "#007ACC"
template: " {{ .CurrentDate | date .Format }} " template: " {{ .CurrentDate | date .Format }} "
@ -123,8 +121,6 @@ blocks:
time_format: '15:04:05' time_format: '15:04:05'
style: plain style: plain
type: time type: time
type: prompt
vertical_offset: -1
- alignment: left - alignment: left
newline: true newline: true
segments: segments:
@ -185,9 +181,7 @@ final_space = true
version = 2 version = 2
[[blocks]] [[blocks]]
alignment = "right" type = "rprompt"
type = "prompt"
vertical_offset = -1
[[blocks.segments]] [[blocks.segments]]
foreground = "#007ACC" foreground = "#007ACC"