2020-05-20 20:05:33 +03:00
|
|
|
function _tide_right_prompt
|
2020-07-05 05:14:21 +03:00
|
|
|
set -l splitText (_fetch_right_prompt_items | string split '@NEWLINE@')
|
2020-05-18 19:44:33 +03:00
|
|
|
set -l printAtEndedRightPromptHeight (count $splitText)
|
2020-05-17 07:43:27 +03:00
|
|
|
|
2020-06-30 05:54:59 +03:00
|
|
|
if test "$tide_right_prompt_frame_enabled" = 'true'
|
2020-07-03 01:04:29 +03:00
|
|
|
# The right frame should always look exactly like the left frame would, regardless of how many lines splitText actually has.
|
|
|
|
# In this section we check if each line exist, if so add the frame to it. If not, insert a line containing only the frame
|
|
|
|
# and update printAtEndedRightPromptHeight
|
2020-06-30 05:54:59 +03:00
|
|
|
|
2020-07-05 05:14:21 +03:00
|
|
|
set -l frameColor (set_color $tide_right_prompt_frame_color -b normal)
|
2020-07-03 01:04:29 +03:00
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
set splitText[1] $splitText[1]$frameColor'─╮'
|
2020-06-30 05:54:59 +03:00
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
if test $_tide_left_prompt_height -gt 1
|
2020-07-03 01:04:29 +03:00
|
|
|
if test $printAtEndedRightPromptHeight -gt 1
|
|
|
|
set splitText[-1] $splitText[-1]$frameColor'─╯'
|
|
|
|
else
|
|
|
|
set splitText[2] $frameColor'─╯'
|
|
|
|
set printAtEndedRightPromptHeight (math $printAtEndedRightPromptHeight+1)
|
|
|
|
end
|
|
|
|
|
|
|
|
if test $_tide_left_prompt_height -gt 2
|
|
|
|
if test $printAtEndedRightPromptHeight -gt 2
|
2020-07-05 05:14:21 +03:00
|
|
|
set splitText[2..-2] $splitText[2..-2]$frameColor'─┤'
|
2020-07-03 01:04:29 +03:00
|
|
|
else
|
2020-07-05 05:14:21 +03:00
|
|
|
set splitText $splitText[1] $frameColor'─┤' $splitText[2]
|
2020-07-03 01:04:29 +03:00
|
|
|
set printAtEndedRightPromptHeight (math $printAtEndedRightPromptHeight+1)
|
|
|
|
end
|
2020-06-30 05:54:59 +03:00
|
|
|
end
|
|
|
|
end
|
2020-05-15 07:53:37 +03:00
|
|
|
end
|
2020-06-30 05:54:59 +03:00
|
|
|
|
|
|
|
for lineOfText in $splitText[1..-2]
|
|
|
|
_print_at_end $lineOfText
|
|
|
|
end
|
|
|
|
|
2020-05-20 20:39:44 +03:00
|
|
|
if test $printAtEndedRightPromptHeight -eq $_tide_left_prompt_height
|
2020-07-05 21:34:01 +03:00
|
|
|
set -g _tide_fish_right_prompt_display $splitText[-1]
|
2020-05-18 19:44:33 +03:00
|
|
|
set printAtEndedRightPromptHeight (math $printAtEndedRightPromptHeight-1)
|
2020-05-15 07:53:37 +03:00
|
|
|
else
|
|
|
|
_print_at_end $splitText[-1]
|
2020-07-05 21:34:01 +03:00
|
|
|
set -g _tide_fish_right_prompt_display ' '
|
2020-05-15 07:53:37 +03:00
|
|
|
end
|
2020-05-17 07:43:27 +03:00
|
|
|
|
2020-07-06 19:40:46 +03:00
|
|
|
_tide_cursor_up $printAtEndedRightPromptHeight
|
2020-05-15 07:53:37 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function _fetch_right_prompt_items
|
2020-07-05 21:34:01 +03:00
|
|
|
set lastItemWasNewline # Display prefix instead of separator before first item
|
|
|
|
set color normal
|
|
|
|
|
2020-07-08 01:55:11 +03:00
|
|
|
set_color normal
|
2020-06-26 22:02:40 +03:00
|
|
|
|
|
|
|
for item in $tide_right_prompt_items
|
|
|
|
if test "$item" = 'newline'
|
2020-07-05 21:34:01 +03:00
|
|
|
if not set -q lastItemWasNewline
|
|
|
|
set_color $previousColor -b normal
|
|
|
|
printf '%s' $tide_right_prompt_suffix
|
|
|
|
end
|
|
|
|
|
|
|
|
printf '%b' '\n'
|
|
|
|
|
|
|
|
set lastItemWasNewline
|
2020-06-26 22:02:40 +03:00
|
|
|
|
|
|
|
continue
|
|
|
|
end
|
|
|
|
|
|
|
|
set -l output (_tide_item_$item)
|
|
|
|
|
|
|
|
if test -n "$output"
|
2020-07-05 21:34:01 +03:00
|
|
|
set -l colorName tide_"$item"_bg_color
|
2020-06-26 22:02:40 +03:00
|
|
|
set -l color $$colorName
|
2020-04-29 01:43:22 +03:00
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
if set -e lastItemWasNewline
|
|
|
|
set_color $color -b normal
|
|
|
|
printf '%s' $tide_right_prompt_prefix
|
2020-06-26 22:02:40 +03:00
|
|
|
else
|
2020-07-05 21:34:01 +03:00
|
|
|
if test "$color" = "$previousColor"
|
|
|
|
set_color $tide_right_prompt_item_separator_same_color_color
|
|
|
|
printf '%s' $tide_right_prompt_item_separator_same_color
|
|
|
|
else
|
|
|
|
set_color $color -b $previousColor
|
|
|
|
printf '%s' $tide_right_prompt_item_separator_diff_color
|
|
|
|
end
|
2020-06-26 22:02:40 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
set_color -b $color
|
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
if test "$tide_right_prompt_pad_items" = 'true'
|
|
|
|
printf '%s' ' '$output(set_color -b $color)' ' # The set_color is for git_prompt which resets the background color
|
|
|
|
else
|
|
|
|
printf '%s' "$output"
|
2020-06-26 22:02:40 +03:00
|
|
|
end
|
2020-07-05 21:34:01 +03:00
|
|
|
|
|
|
|
set previousColor $color
|
2020-06-26 22:02:40 +03:00
|
|
|
end
|
2020-05-09 01:32:58 +03:00
|
|
|
end
|
2020-06-26 22:02:40 +03:00
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
if not set -q lastItemWasNewline
|
|
|
|
set_color $previousColor -b normal
|
|
|
|
printf '%s' $tide_right_prompt_suffix
|
|
|
|
end
|
2020-05-15 07:53:37 +03:00
|
|
|
end
|
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
function fish_right_prompt
|
|
|
|
printf '%s' $_tide_fish_right_prompt_display
|
|
|
|
end
|
2020-07-03 01:04:29 +03:00
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
function _print_at_end -a text
|
|
|
|
set -l startLocation (math $COLUMNS -(_tide_decolor $text | string length))
|
2020-07-06 19:40:46 +03:00
|
|
|
_tide_cursor_right $startLocation
|
2020-05-27 22:11:22 +03:00
|
|
|
|
2020-07-05 21:34:01 +03:00
|
|
|
printf '%s%b' $text '\v\r' # For some reason \n doesn't work but \v\r does
|
2020-04-21 21:52:24 +03:00
|
|
|
end
|