Add left prompt frame

This commit is contained in:
Ilan Cosman 2020-06-29 12:32:56 -07:00
parent b46514cabc
commit 3a75a22aff

View File

@ -1,6 +1,7 @@
function _tide_left_prompt function _tide_left_prompt
set lastItemWasNewline # Display prefix instead of separator before first item set lastItemWasNewline # Display prefix instead of separator before first item
set color normal set color normal
set currentHeight 1
for item in $tide_left_prompt_items for item in $tide_left_prompt_items
if test "$item" = 'newline' if test "$item" = 'newline'
@ -10,17 +11,36 @@ function _tide_left_prompt
end end
printf '%b' '\n' printf '%b' '\n'
set lastItemWasNewline set lastItemWasNewline
set currentHeight (math $currentHeight +1)
continue continue
end end
if set -q lastItemWasNewline
if test "$tide_left_prompt_frame_enabled" = 'true'
set_color $tide_left_prompt_frame_color
if test $currentHeight -eq 1
printf '%s' '╭─'
else if test $currentHeight -lt $_tide_left_prompt_height
printf '%s' '├─'
else
printf '%s' '╰─'
end
end
end
set -l output (_tide_item_$item) set -l output (_tide_item_$item)
if test -n "$output" if test -n "$output"
set -l colorName 'tide_'$item'_bg_color' set -l colorName 'tide_'$item'_bg_color'
set -l color $$colorName set -l color $$colorName
set_color -b $color
if set -e lastItemWasNewline if set -e lastItemWasNewline
if test "$item" != 'prompt_char' if test "$item" != 'prompt_char'
printf '%s' $tide_left_prompt_prefix printf '%s' $tide_left_prompt_prefix
@ -30,8 +50,7 @@ function _tide_left_prompt
_print_left_prompt_separator _print_left_prompt_separator
end end
set_color -b $color printf '%s' "$output"
printf '%b' $output
set previousColor $color set previousColor $color