mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-18 21:41:57 +00:00
add an option to remove frame
This commit is contained in:
parent
8038ce4fae
commit
e4f04403d0
1 changed files with 70 additions and 6 deletions
|
@ -49,8 +49,8 @@ typeset -ra classic_right=(
|
|||
|
||||
typeset -ri prompt_indent=4
|
||||
|
||||
local POWERLEVEL9K_MODE style config_backup gap_char
|
||||
local -i num_lines write_config straight empty_line
|
||||
local POWERLEVEL9K_MODE style config_backup gap_char=' '
|
||||
local -i num_lines write_config straight empty_line frame=1
|
||||
local -i cap_diamond cap_python cap_narrow_icons cap_lock
|
||||
|
||||
function prompt_length() {
|
||||
|
@ -78,6 +78,9 @@ function print_prompt() {
|
|||
if (( num_lines == 1)); then
|
||||
left=($left[2] $left[4])
|
||||
right=($right[1] $right[3])
|
||||
else
|
||||
(( frame < 1 )) && left=('' $left[2] '' '%76F❯%f █')
|
||||
(( frame < 2 )) && right=($right[1] '' '' '')
|
||||
fi
|
||||
if (( straight )); then
|
||||
[[ $POWERLEVEL9K_MODE == nerdfont-complete ]] && local subsep='\uE0BD' || local subsep='|'
|
||||
|
@ -89,7 +92,7 @@ function print_prompt() {
|
|||
local l=${(g::):-$left[i]$left[i+1]}
|
||||
local r=${(g::):-$right[i]$right[i+1]}
|
||||
local -i gap=$((__p9k_wizard_columns - 2 * prompt_indent - $(prompt_length $l$r)))
|
||||
(( 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 -nP -- $l
|
||||
print -nP -- "%240F${(pl:$gap::$fill:)}%f"
|
||||
|
@ -333,11 +336,11 @@ function ask_num_lines() {
|
|||
clear
|
||||
centered "%BPrompt Height%b"
|
||||
print -P ""
|
||||
print -P "%B(1) One Line%b"
|
||||
print -P "%B(1) One line%b"
|
||||
print -P ""
|
||||
num_lines=1 print_prompt
|
||||
print -P ""
|
||||
print -P "%B(2) Two Lines%b"
|
||||
print -P "%B(2) Two lines%b"
|
||||
print -P ""
|
||||
num_lines=2 print_prompt
|
||||
print -P ""
|
||||
|
@ -394,6 +397,42 @@ function ask_gap_char() {
|
|||
done
|
||||
}
|
||||
|
||||
function ask_frame() {
|
||||
if [[ $style != classic || $num_lines != 2 ]]; then
|
||||
frame=0
|
||||
return
|
||||
fi
|
||||
while true; do
|
||||
clear
|
||||
centered "%BPrompt Frame%b"
|
||||
print -P ""
|
||||
print -P "%B(1) No frame%b"
|
||||
print -P ""
|
||||
frame=0 print_prompt
|
||||
print -P ""
|
||||
print -P "%B(2) Only left%b"
|
||||
print -P ""
|
||||
frame=1 print_prompt
|
||||
print -P ""
|
||||
print -P "%B(3) Left and right%b"
|
||||
print -P ""
|
||||
frame=2 print_prompt
|
||||
print -P ""
|
||||
print -P "(r) Restart from the beginning."
|
||||
print -P ""
|
||||
print -P "(q) Quit and do nothing."
|
||||
print -P ""
|
||||
|
||||
local key=
|
||||
read -k key${(%):-"?%BChoice [123rq]: %b"} || return 1
|
||||
case $key in
|
||||
q) quit; return 1;;
|
||||
r) return 2;;
|
||||
1|2|3) frame=$((key-1)); break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function ask_empty_line() {
|
||||
while true; do
|
||||
clear
|
||||
|
@ -488,10 +527,15 @@ function ask_config_overwrite() {
|
|||
function generate_config() {
|
||||
local base && base="$(<$__p9k_root_dir/config/p10k-$style.zsh)" || return
|
||||
local lines=("${(@f)base}")
|
||||
|
||||
function sub() {
|
||||
lines=("${(@)lines/# typeset -g POWERLEVEL9K_$1=*/ typeset -g POWERLEVEL9K_$1=$2}")
|
||||
}
|
||||
|
||||
function uncomment() {
|
||||
lines=("${(@)lines/#(#b)([[:space:]]#)\# $1(|[[:space:]]*)/$match[1]$1${match[2]:= $match[2]}}")
|
||||
}
|
||||
|
||||
sub MODE $POWERLEVEL9K_MODE
|
||||
|
||||
if (( cap_narrow_icons )); then
|
||||
|
@ -528,6 +572,20 @@ function generate_config() {
|
|||
|
||||
sub MULTILINE_FIRST_PROMPT_GAP_CHAR "'$gap_char'"
|
||||
|
||||
if (( frame < 2 )); then
|
||||
sub MULTILINE_FIRST_PROMPT_SUFFIX ''
|
||||
sub MULTILINE_NEWLINE_PROMPT_SUFFIX ''
|
||||
sub MULTILINE_LAST_PROMPT_SUFFIX ''
|
||||
if (( frame < 1 )); then
|
||||
sub MULTILINE_FIRST_PROMPT_PREFIX ''
|
||||
sub MULTILINE_NEWLINE_PROMPT_PREFIX ''
|
||||
sub MULTILINE_LAST_PROMPT_PREFIX ''
|
||||
uncomment prompt_char
|
||||
sub STATUS_OK false
|
||||
sub STATUS_ERROR false
|
||||
fi
|
||||
fi
|
||||
|
||||
(( empty_line )) && sub PROMPT_ADD_NEWLINE true || sub PROMPT_ADD_NEWLINE false
|
||||
|
||||
local header=${(%):-"# Generated by Powerlevel10k configuration wizard on %D{%Y-%m-%d at %H:%M %Z}."}$'\n'
|
||||
|
@ -540,7 +598,7 @@ function generate_config() {
|
|||
fi
|
||||
header+=$'.\n'
|
||||
header+="# Wizard options: $POWERLEVEL9K_MODE"
|
||||
(( cap_narrow_icons )) && header+=", narrow icons" || header+=", wide icons"
|
||||
(( cap_narrow_icons )) && header+=", small icons" || header+=", big icons"
|
||||
if [[ $style == classic ]]; then
|
||||
(( straight )) && header+=", straight" || header+=", angled"
|
||||
fi
|
||||
|
@ -550,6 +608,11 @@ function generate_config() {
|
|||
'·') header+=", dotted";;
|
||||
'─') header+=", solid";;
|
||||
esac
|
||||
case $frame in
|
||||
0) header+=", no frame";;
|
||||
1) header+=", left frame";;
|
||||
2) header+=", full frame";;
|
||||
esac
|
||||
(( empty_line )) && header+=", sparse" || header+=", compact";
|
||||
header+=$'.\n#'
|
||||
|
||||
|
@ -617,6 +680,7 @@ while true; do
|
|||
ask_straight || { (( $? == 2 )) && continue || return }
|
||||
ask_num_lines || { (( $? == 2 )) && continue || return }
|
||||
ask_gap_char || { (( $? == 2 )) && continue || return }
|
||||
ask_frame || { (( $? == 2 )) && continue || return }
|
||||
ask_empty_line || { (( $? == 2 )) && continue || return }
|
||||
ask_confirm || { (( $? == 2 )) && continue || return }
|
||||
ask_config_overwrite || { (( $? == 2 )) && continue || return }
|
||||
|
|
Loading…
Reference in a new issue