mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
fix: make newline compatible cross shell
When using PowerShell, "\n" isn't recognized as a newline character. To resolve this, moving the cursor down 1 line is more interesting as it will work in any shell using ANSI escape sequences (which we depends upon).
This commit is contained in:
parent
f3582d229e
commit
9b9405978e
|
@ -17,7 +17,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "line-break"
|
||||
"type": "newline"
|
||||
},
|
||||
{
|
||||
"type": "prompt",
|
||||
|
|
|
@ -128,13 +128,13 @@ func (e *engine) string() string {
|
|||
for _, block := range e.settings.Blocks {
|
||||
// if line break, append a line break
|
||||
if block.Type == LineBreak {
|
||||
buffer.WriteString("\n")
|
||||
buffer.WriteString("\x1b[1B")
|
||||
continue
|
||||
}
|
||||
if block.LineOffset < 0 {
|
||||
buffer.WriteString(fmt.Sprintf("\x1b[%dF", -block.LineOffset))
|
||||
} else if block.LineOffset > 0 {
|
||||
buffer.WriteString(fmt.Sprintf("\x1b[%dE", block.LineOffset))
|
||||
buffer.WriteString(fmt.Sprintf("\x1b[%dB", block.LineOffset))
|
||||
}
|
||||
switch block.Alignment {
|
||||
case Right:
|
||||
|
|
|
@ -26,7 +26,7 @@ const (
|
|||
//Prompt writes one or more Segments
|
||||
Prompt BlockType = "prompt"
|
||||
//LineBreak creates a line break in the prompt
|
||||
LineBreak BlockType = "line-break"
|
||||
LineBreak BlockType = "newline"
|
||||
//Left aligns left
|
||||
Left BlockAlignment = "left"
|
||||
//Right aligns right
|
||||
|
|
Loading…
Reference in a new issue