Cosmetic improvement for the statusbar
This commit is contained in:
parent
cf6a869e9e
commit
9363169098
|
@ -75,11 +75,14 @@ func width(cells: seq[StatusBarCell]): int =
|
||||||
|
|
||||||
proc renderCells(cells: seq[StatusBarCell], sep: string) =
|
proc renderCells(cells: seq[StatusBarCell], sep: string) =
|
||||||
for i, cell in cells:
|
for i, cell in cells:
|
||||||
if i > 0: stdout.write sep
|
stdout.setBackgroundColor backgroundColor
|
||||||
|
stdout.setForegroundColor foregroundColor
|
||||||
stdout.setStyle {styleDim}
|
stdout.setStyle {styleDim}
|
||||||
|
if i > 0: stdout.write sep
|
||||||
stdout.write " ", cell.label, ": "
|
stdout.write " ", cell.label, ": "
|
||||||
stdout.setStyle {styleBright}
|
stdout.setStyle {styleBright}
|
||||||
stdout.write cell.content, " "
|
stdout.write cell.content, " "
|
||||||
|
stdout.resetAttributes()
|
||||||
|
|
||||||
proc render*(s: var StatusBarView) =
|
proc render*(s: var StatusBarView) =
|
||||||
doAssert s.consumedLines == 0
|
doAssert s.consumedLines == 0
|
||||||
|
@ -89,9 +92,8 @@ proc render*(s: var StatusBarView) =
|
||||||
allCellsWidth = s.layout.cellsLeft.width + s.layout.cellsRight.width
|
allCellsWidth = s.layout.cellsLeft.width + s.layout.cellsRight.width
|
||||||
|
|
||||||
if allCellsWidth > 0:
|
if allCellsWidth > 0:
|
||||||
stdout.setBackgroundColor backgroundColor
|
|
||||||
stdout.setForegroundColor foregroundColor
|
|
||||||
renderCells(s.layout.cellsLeft, sepLeft)
|
renderCells(s.layout.cellsLeft, sepLeft)
|
||||||
|
stdout.setBackgroundColor backgroundColor
|
||||||
if termWidth > allCellsWidth:
|
if termWidth > allCellsWidth:
|
||||||
stdout.write spaces(termWidth - allCellsWidth)
|
stdout.write spaces(termWidth - allCellsWidth)
|
||||||
s.consumedLines = 1
|
s.consumedLines = 1
|
||||||
|
@ -99,7 +101,6 @@ proc render*(s: var StatusBarView) =
|
||||||
stdout.write spaces(max(0, termWidth - s.layout.cellsLeft.width)), "\p"
|
stdout.write spaces(max(0, termWidth - s.layout.cellsLeft.width)), "\p"
|
||||||
s.consumedLines = 2
|
s.consumedLines = 2
|
||||||
renderCells(s.layout.cellsRight, sepRight)
|
renderCells(s.layout.cellsRight, sepRight)
|
||||||
stdout.resetAttributes
|
|
||||||
stdout.flushFile
|
stdout.flushFile
|
||||||
|
|
||||||
proc erase*(s: var StatusBarView) =
|
proc erase*(s: var StatusBarView) =
|
||||||
|
|
Loading…
Reference in New Issue