From dfa7b1578fcd7fb187980ccc7e279e4f42d6f1cb Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 7 Nov 2019 14:17:33 +0100 Subject: [PATCH] wizard: frame for lean prompt --- config/p10k-lean.zsh | 14 +++++++++ internal/wizard.zsh | 72 +++++++++++++++++++++++++++----------------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 150e3c7b..8d321ca4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -148,6 +148,20 @@ # Add an empty line before each prompt. typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + # Connect left prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= + + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= + # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 523d56d8..651ffa1b 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -63,13 +63,13 @@ typeset -r vertical_bar='|' typeset -r slanted_bar='\uE0BD' typeset -ra lean_left=( - '' '${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 ' - '' '%76F❯%f ${buffer:-█}' + '%$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:-█}' ) typeset -ra lean_right=( - ' $prefixes[2]%101F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%66F$extra_icons[5]16:23:42%f}' '' - '' '' + ' $prefixes[2]%101F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%66F$extra_icons[5]16:23:42%f}' ' %$frame_color[$color]F─╮%f' + '' ' %$frame_color[$color]F─╯%f' ) typeset -ra classic_left=( @@ -558,7 +558,7 @@ function ask_style() { print -n $nl print -P "%B(1) Lean.%b" print -n $nl - style=lean print_prompt + style=lean left_frame=0 right_frame=0 print_prompt print -P "" print -P "%B(2) Classic.%b" print -n $nl @@ -581,7 +581,7 @@ function ask_style() { case $key in q) quit;; r) return 1;; - 1) style=lean; options+=lean; break;; + 1) style=lean; left_frame=0; right_frame=0; options+=lean; break;; 2) style=classic; options+=classic; break;; 3) style=rainbow; options+=rainbow; break;; 4) style=pure; empty_line=1; options+=pure; break;; @@ -633,8 +633,8 @@ function ask_color() { done } -function ask_frame_color() { - [[ $style != rainbow || $num_lines == 1 ]] && return +function ask_ornaments_color() { + [[ $style != (rainbow|lean) || $num_lines == 1 ]] && return [[ $gap_char == ' ' && $left_frame == 0 && $right_frame == 0 ]] && return if [[ $LINES -lt 26 ]]; then local nl='' @@ -643,7 +643,7 @@ function ask_frame_color() { fi while true; do clear - flowing -c "%BFrame Color%b" + flowing -c "%BOrnaments Color%b" print -n $nl print -P "%B(1) Lightest.%b" print -n $nl @@ -1146,7 +1146,7 @@ function ask_gap_char() { } function ask_frame() { - if [[ $style != (classic|rainbow) || $num_lines != 2 ]]; then + if [[ $style != (classic|rainbow|lean) || $num_lines != 2 ]]; then return 0 fi @@ -1568,6 +1568,22 @@ function generate_config() { fi fi + if [[ $style == lean ]]; then + sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color] + if (( right_frame )); then + sub MULTILINE_FIRST_PROMPT_SUFFIX "'%$frame_color[$color]F─╮'" + sub MULTILINE_NEWLINE_PROMPT_SUFFIX "'%$frame_color[$color]F─┤'" + sub MULTILINE_LAST_PROMPT_SUFFIX "'%$frame_color[$color]F─╯'" + sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "' '" + fi + if (( left_frame )); then + sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'" + sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'" + sub MULTILINE_LAST_PROMPT_PREFIX "'%$frame_color[$color]F╰─'" + sub LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL "' '" + fi + fi + if [[ $style == (classic|rainbow) ]]; then if (( num_lines == 2 && ! left_frame )); then uncomment prompt_char @@ -1724,26 +1740,26 @@ while true; do right_head=$fade_in fi _p9k_init_icons - ask_narrow_icons || continue - ask_style || continue + ask_narrow_icons || continue + ask_style || continue if [[ $style != pure ]]; then - ask_color || continue - ask_time || continue - ask_separators || continue - ask_heads || continue - ask_tails || continue - ask_num_lines || continue - ask_gap_char || continue - ask_frame || continue - ask_frame_color || continue - ask_empty_line || continue - ask_extra_icons || continue - ask_prefixes || continue + ask_color || continue + ask_time || continue + ask_separators || continue + ask_heads || continue + ask_tails || continue + ask_num_lines || continue + ask_gap_char || continue + ask_frame || continue + ask_ornaments_color || continue + ask_empty_line || continue + ask_extra_icons || continue + ask_prefixes || continue fi - ask_transient_prompt || continue - ask_instant_prompt || continue - ask_config_overwrite || continue - ask_zshrc_edit || continue + ask_transient_prompt || continue + ask_instant_prompt || continue + ask_config_overwrite || continue + ask_zshrc_edit || continue break done