add color selection dialog for lean-8colors; remove space before prompt char in lean-* when it's the first segment on the line

pull/436/head
romkatv 5 years ago
parent 2feac7f121
commit 9586e24dfb

@ -181,7 +181,7 @@
# POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below.
typeset -g POWERLEVEL9K_SHOW_RULER=false typeset -g POWERLEVEL9K_SHOW_RULER=false
typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·'
typeset -g POWERLEVEL9K_RULER_FOREGROUND= typeset -g POWERLEVEL9K_RULER_FOREGROUND=7
# Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─'
# to make it easier to see the alignment between left and right prompt and to separate prompt # to make it easier to see the alignment between left and right prompt and to separate prompt
@ -192,7 +192,7 @@
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '
if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
# The color of the filler. # The color of the filler.
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND= typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=7
# Add a space between the end of left prompt and the filler. # Add a space between the end of left prompt and the filler.
typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' '
# Add a space between the filler and the start of right prompt. # Add a space between the filler and the start of right prompt.
@ -223,7 +223,10 @@
# Prompt symbol in overwrite vi mode. # Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
# No line terminator if prompt_char is the last segment.
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
# No line introducer if prompt_char is the first segment.
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
##################################[ dir: current directory ]################################## ##################################[ dir: current directory ]##################################
# Default current directory color. # Default current directory color.

@ -223,7 +223,10 @@
# Prompt symbol in overwrite vi mode. # Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
# No line terminator if prompt_char is the last segment.
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
# No line introducer if prompt_char is the first segment.
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
##################################[ dir: current directory ]################################## ##################################[ dir: current directory ]##################################
# Default current directory color. # Default current directory color.

@ -34,7 +34,6 @@ local -ri wizard_columns=$((COLUMNS < 80 ? COLUMNS : 80))
local -ri prompt_indent=2 local -ri prompt_indent=2
local -ra bg_color=(240 238 236 234) local -ra bg_color=(240 238 236 234)
local -ra frame_color=(244 242 240 238)
local -ra sep_color=(248 246 244 242) local -ra sep_color=(248 246 244 242)
local -ra prefix_color=(250 248 246 244) local -ra prefix_color=(250 248 246 244)
@ -55,7 +54,7 @@ local -r slanted_bar='\uE0BD'
local -ra lean_left=( local -ra lean_left=(
'%$frame_color[$color]F╭─ ' '${extra_icons[1]:+$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fsrc%b%f $prefixes[1]%76F$extra_icons[3]master%f ' '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fsrc%b%f $prefixes[1]%76F$extra_icons[3]master%f '
'%$frame_color[$color]F╰─ ' '%76F%f ${buffer:-█}' '%$frame_color[$color]F╰─' '%76F%f ${buffer:-█}'
) )
local -ra lean_right=( local -ra lean_right=(
@ -64,13 +63,13 @@ local -ra lean_right=(
) )
local -ra lean_8colors_left=( local -ra lean_8colors_left=(
'╭─ ' '${extra_icons[1]:+$extra_icons[1] }%4F$extra_icons[2]%4F~/src%f $prefixes[1]%2F$extra_icons[3]master%f ' '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+$extra_icons[1] }%4F$extra_icons[2]%4F~/src%f $prefixes[1]%2F$extra_icons[3]master%f '
'╰─ ' '%2F%f ${buffer:-█}' '%$frame_color[$color]F╰─' '%2F%f ${buffer:-█}'
) )
local -ra lean_8colors_right=( local -ra lean_8colors_right=(
' $prefixes[2]%3F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%6F$extra_icons[5]16:23:42%f}' ' ─╮' ' $prefixes[2]%3F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%6F$extra_icons[5]16:23:42%f}' ' %$frame_color[$color]F─╮%f'
'' ' ─╯' '' ' %$frame_color[$color]F─╯%f'
) )
local -ra classic_left=( local -ra classic_left=(
@ -151,8 +150,7 @@ function print_prompt() {
(( num_lines == 2 && i == 1 )) && local fill=$gap_char || local fill=' ' (( num_lines == 2 && i == 1 )) && local fill=$gap_char || local fill=' '
print -n -- ${(pl:$prompt_indent:: :)} print -n -- ${(pl:$prompt_indent:: :)}
print -nP -- $l print -nP -- $l
[[ $style == lean_8colors ]] && local gap_color='%f' || local gap_color="%$frame_color[$color]F" print -nP -- "%$frame_color[$color]F${(pl:$gap::$fill:)}%f"
print -nP -- "$gap_color${(pl:$gap::$fill:)}%f"
print -P -- $r print -P -- $r
done done
} }
@ -631,7 +629,12 @@ function ask_color_scheme() {
q) quit;; q) quit;;
r) return 1;; r) return 1;;
1) style=lean; break;; 1) style=lean; break;;
2) style=lean_8colors; break;; 2)
style=lean_8colors
frame_color=(0 7 2 4)
color_name=(Black White Green Blue)
break
;;
esac esac
done done
} }
@ -647,19 +650,19 @@ function ask_color() {
clear clear
flowing -c "%BPrompt Color%b" flowing -c "%BPrompt Color%b"
print -n $nl print -n $nl
print -P "%B(1) Lightest.%b" print -P "%B(1) $color_name[1].%b"
print -n $nl print -n $nl
color=1 print_prompt color=1 print_prompt
print -P "" print -P ""
print -P "%B(2) Light.%b" print -P "%B(1) $color_name[2].%b"
print -n $nl print -n $nl
color=2 print_prompt color=2 print_prompt
print -P "" print -P ""
print -P "%B(3) Dark.%b" print -P "%B(1) $color_name[3].%b"
print -n $nl print -n $nl
color=3 print_prompt color=3 print_prompt
print -P "" print -P ""
print -P "%B(4) Darkest.%b" print -P "%B(1) $color_name[4].%b"
print -n $nl print -n $nl
color=4 print_prompt color=4 print_prompt
print -P "" print -P ""
@ -672,16 +675,14 @@ function ask_color() {
case $key in case $key in
q) quit;; q) quit;;
r) return 1;; r) return 1;;
1) color=1; options+=lightest; break;; [1-4]) color=$key; break;;
2) color=2; options+=light; break;;
3) color=3; options+=dark; break;;
4) color=4; options+=darkest; break;;
esac esac
done done
options+=${(L)color_name[color]}
} }
function ask_ornaments_color() { function ask_ornaments_color() {
[[ $style != (rainbow|lean) || $num_lines == 1 ]] && return [[ $style != (rainbow|lean*) || $num_lines == 1 ]] && return
[[ $gap_char == ' ' && $left_frame == 0 && $right_frame == 0 ]] && return [[ $gap_char == ' ' && $left_frame == 0 && $right_frame == 0 ]] && return
if [[ $LINES -lt 26 ]]; then if [[ $LINES -lt 26 ]]; then
local nl='' local nl=''
@ -695,19 +696,19 @@ function ask_ornaments_color() {
clear clear
flowing -c "%B${(j: & :)ornaments} Color%b" flowing -c "%B${(j: & :)ornaments} Color%b"
print -n $nl print -n $nl
print -P "%B(1) Lightest.%b" print -P "%B(1) $color_name[1].%b"
print -n $nl print -n $nl
color=1 print_prompt color=1 print_prompt
print -P "" print -P ""
print -P "%B(2) Light.%b" print -P "%B(2) $color_name[2].%b"
print -n $nl print -n $nl
color=2 print_prompt color=2 print_prompt
print -P "" print -P ""
print -P "%B(3) Dark.%b" print -P "%B(3) $color_name[3].%b"
print -n $nl print -n $nl
color=3 print_prompt color=3 print_prompt
print -P "" print -P ""
print -P "%B(4) Darkest.%b" print -P "%B(4) $color_name[4].%b"
print -n $nl print -n $nl
color=4 print_prompt color=4 print_prompt
print -P "" print -P ""
@ -720,12 +721,10 @@ function ask_ornaments_color() {
case $key in case $key in
q) quit;; q) quit;;
r) return 1;; r) return 1;;
1) color=1; options+=lightest; break;; [1-4]) color=$key; break;;
2) color=2; options+=light; break;;
3) color=3; options+=dark; break;;
4) color=4; options+=darkest; break;;
esac esac
done done
options+=${(L)color_name[color]}-ornaments
} }
function ask_time() { function ask_time() {
@ -1545,6 +1544,7 @@ function generate_config() {
sub LEFT_SUBSEGMENT_SEPARATOR "'$left_subsep'" sub LEFT_SUBSEGMENT_SEPARATOR "'$left_subsep'"
sub RIGHT_SUBSEGMENT_SEPARATOR "'$right_subsep'" sub RIGHT_SUBSEGMENT_SEPARATOR "'$right_subsep'"
fi fi
sub RULER_FOREGROUND $frame_color[$color]
sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color] sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color]
sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'" sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'"
sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'" sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'"
@ -1621,22 +1621,18 @@ function generate_config() {
fi fi
if [[ $style == lean* ]]; then if [[ $style == lean* ]]; then
if [[ $style == lean ]]; then sub RULER_FOREGROUND $frame_color[$color]
local c="%$frame_color[$color]F" sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color]
sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color]
else
local c=
fi
if (( right_frame )); then if (( right_frame )); then
sub MULTILINE_FIRST_PROMPT_SUFFIX "'$c─╮'" sub MULTILINE_FIRST_PROMPT_SUFFIX "'%$frame_color[$color]F─╮'"
sub MULTILINE_NEWLINE_PROMPT_SUFFIX "'$c─┤'" sub MULTILINE_NEWLINE_PROMPT_SUFFIX "'%$frame_color[$color]F─┤'"
sub MULTILINE_LAST_PROMPT_SUFFIX "'$c─╯'" sub MULTILINE_LAST_PROMPT_SUFFIX "'%$frame_color[$color]F─╯'"
sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "' '" sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "' '"
fi fi
if (( left_frame )); then if (( left_frame )); then
sub MULTILINE_FIRST_PROMPT_PREFIX "'$c╭─'" sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'"
sub MULTILINE_NEWLINE_PROMPT_PREFIX "'$c├─'" sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'"
sub MULTILINE_LAST_PROMPT_PREFIX "'$c╰─'" sub MULTILINE_LAST_PROMPT_PREFIX "'%$frame_color[$color]F╰─'"
sub LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL "' '" sub LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL "' '"
fi fi
fi fi
@ -1740,6 +1736,8 @@ while true; do
local -i num_lines=0 empty_line=0 color=2 left_frame=1 right_frame=1 transient_prompt=0 local -i num_lines=0 empty_line=0 color=2 left_frame=1 right_frame=1 transient_prompt=0
local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_narrow_icons=0 cap_lock=0 local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_narrow_icons=0 cap_lock=0
local -a extra_icons=('' '' '') local -a extra_icons=('' '' '')
local -a frame_color=(244 242 240 238)
local -a color_name=(Lightest Light Dark Darkest)
local -a prefixes=('' '') local -a prefixes=('' '')
local -a options=() local -a options=()

Loading…
Cancel
Save