Suffix all icons with _ICON

This is done, because in case of custom segments we need to distinguish
between the content of the segment and the icon. Before this change, we
could not tell if the variable meant the content or the icon of that
segment.
This commit is contained in:
Dominik Ritter 2018-09-23 18:16:16 +02:00
parent b8964ea2b6
commit 8c0ddd9018
4 changed files with 9 additions and 9 deletions

View File

@ -59,7 +59,7 @@ fi
##
function p9k::register_icon() {
local map
local ICON_USER_VARIABLE="P9K_${1}"
local ICON_USER_VARIABLE="P9K_${1}_ICON"
if p9k::defined "${ICON_USER_VARIABLE}"; then # check for icon override first
map="${(P)ICON_USER_VARIABLE}"
else # use the icons that are registered by the segment
@ -122,10 +122,7 @@ function p9k::register_segment() {
__P9K_DATA[${STATEFUL_NAME}_FG]="$(p9k::foreground_color $4)"
fi
local ICON_NAME="${STATEFUL_NAME}"
# For custom segments, we need a special name for the icon variable.
[[ "${STATEFUL_NAME}" =~ "^CUSTOM_" ]] && ICON_NAME="${STATEFUL_NAME}_ICON"
p9k::register_icon "${ICON_NAME}" "${5}" "${6}" "${7}" "${8}" "${9}"
p9k::register_icon "${STATEFUL_NAME}" "${5}" "${6}" "${7}" "${8}" "${9}"
local ICON_COLOR_VARIABLE="P9K_${STATEFUL_NAME}_ICON_COLOR"
if p9k::defined "${ICON_COLOR_VARIABLE}"; then

View File

@ -195,7 +195,7 @@ function p9k::prepare_segment() {
# check if it is a named icon
SEGMENT_ICON=${__P9K_ICONS[${8}]}
# otherwise use it literally
[[ ${SEGMENT_ICON} == "" ]] && SEGMENT_ICON=$(echo ${8})
[[ -z "${SEGMENT_ICON}" ]] && SEGMENT_ICON=$(echo ${8})
fi
# Background overide

View File

@ -97,11 +97,14 @@ __p9k_print_deprecation_warning deprecated_segments
typeset -AH deprecated_variables
# old => new
deprecated_variables=(
# General icons
'P9K_MULTILINE_FIRST_PROMPT_PREFIX' 'P9K_MULTILINE_FIRST_PROMPT_PREFIX_ICON'
'P9K_MULTILINE_LAST_PROMPT_PREFIX' 'P9K_MULTILINE_LAST_PROMPT_PREFIX_ICON'
# status icons
'P9K_OK_ICON' 'P9K_STATUS_OK_ICON'
'P9K_FAIL_ICON' 'P9K_STATUS_ERROR_ICON'
'P9K_CARRIAGE_RETURN_ICON' 'P9K_STATUS_ERROR_CR_ICON'
#aws segment
# aws segment
'AWS_DEFAULT_PROFILE' 'P9K_AWS_DEFAULT_PROFILE'
# aws_eb_env segment
'P9K_AWS_EB_ICON' 'P9K_AWS_EB_ENV_ICON'

View File

@ -90,7 +90,7 @@ function testPrefixingFirstLineOnLeftPrompt() {
local P9K_CUSTOM_WORLD1='echo world1'
local P9K_PROMPT_ON_NEWLINE=true
local P9K_MULTILINE_FIRST_PROMPT_PREFIX='XXX'
local P9K_MULTILINE_FIRST_PROMPT_PREFIX_ICON='XXX'
source functions/icons.zsh
__p9k_prepare_prompts
@ -105,7 +105,7 @@ function testPrefixingSecondLineOnLeftPrompt() {
local P9K_CUSTOM_WORLD1='echo world1'
local P9K_PROMPT_ON_NEWLINE=true
local P9K_MULTILINE_LAST_PROMPT_PREFIX='XXX'
local P9K_MULTILINE_LAST_PROMPT_PREFIX_ICON='XXX'
source functions/icons.zsh
__p9k_prepare_prompts