Make purpose clear of backgroundColor and foregroundColor functions

The functions just start the colors, they do not end them. It seems
too much to have a function that terminates a color.
pull/22/head
Dominik Ritter 6 years ago
parent 345cf87b8f
commit ebbdb3c1c0

@ -50,20 +50,12 @@ function getColor() {
# empty paramenter resets (stops) background color # empty paramenter resets (stops) background color
function backgroundColor() { function backgroundColor() {
if [[ -z $1 ]]; then echo -n "%K{$(getColor $1)}"
echo -n "%k"
else
echo -n "%K{$(getColor $1)}"
fi
} }
# empty paramenter resets (stops) foreground color # empty paramenter resets (stops) foreground color
function foregroundColor() { function foregroundColor() {
if [[ -z $1 ]]; then echo -n "%F{$(getColor $1)}"
echo -n "%f"
else
echo -n "%F{$(getColor $1)}"
fi
} }
# Get numerical color codes. That way we translate ANSI codes # Get numerical color codes. That way we translate ANSI codes
@ -346,12 +338,12 @@ function getColorCode() {
if [[ "$1" == "foreground" ]]; then if [[ "$1" == "foreground" ]]; then
# call via `getColorCode foreground` # call via `getColorCode foreground`
for i in "${(k@)codes}"; do for i in "${(k@)codes}"; do
print -P "$(foregroundColor $i)$(getColor $i) - $i$(foregroundColor)" print -P "$(foregroundColor $i)$(getColor $i) - $i%f"
done done
elif [[ "$1" == "background" ]]; then elif [[ "$1" == "background" ]]; then
# call via `getColorCode background` # call via `getColorCode background`
for i in "${(k@)codes}"; do for i in "${(k@)codes}"; do
print -P "$(backgroundColor $i)$(getColor $i) - $i$(backgroundColor)" print -P "$(backgroundColor $i)$(getColor $i) - $i%k"
done done
else else
#[[ -n "$1" ]] bg="%K{$1}" || bg="%k" #[[ -n "$1" ]] bg="%K{$1}" || bg="%k"

@ -127,8 +127,8 @@ left_prompt_segment() {
[[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER"
local bg fg local bg fg
[[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)" [[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="%k"
[[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="%f"
if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then
echo -n "$bg%F{$CURRENT_BG}" echo -n "$bg%F{$CURRENT_BG}"
@ -220,8 +220,8 @@ right_prompt_segment() {
[[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER"
local bg fg local bg fg
[[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)" [[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="%k"
[[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="%f"
# If CURRENT_RIGHT_BG is "NONE", we are the first right segment. # If CURRENT_RIGHT_BG is "NONE", we are the first right segment.

Loading…
Cancel
Save