Skip to content

Commit

Permalink
canvas (ble/canvas/trace): fix text justification for empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 1, 2022
1 parent e618133 commit cdf74c2
Show file tree
Hide file tree
Showing 13 changed files with 765 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -315,6 +315,7 @@
- main. util: fix problems of readlink etc. found by test in macOS (reported by aiotter) `#D1849` fa955c1 `#D1855` a22e145
- progcomp: fix a bug that `COMP_WORDBREAKS` is ignored `#D1872` 4d2dd35
- global: quote `return $?` `#D1884` 801d14a
- canvas (`ble/canvas/trace`): fix text justification for empty lines (reported by rashil2000) `#D1894` xxxxxxx

## Documentation

Expand Down
23 changes: 22 additions & 1 deletion lib/test-canvas.sh
Expand Up @@ -171,7 +171,7 @@ ble/test:canvas/check-trace
#------------------------------------------------------------------------------
# test-trace.sh

ble/test/start-section 'ble/canvas/trace (justify)' 24
ble/test/start-section 'ble/canvas/trace (justify)' 30

ble/test:canvas/trace.contra 30:1 'a b c' justify << EOF
a b c$
Expand Down Expand Up @@ -278,6 +278,27 @@ if [[ $_ble_test_canvas_contra ]]; then
ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:2,0-6,1'
fi


# regression tests for https://github.com/akinomyoga/ble.sh/issues/239
ble/test:canvas/trace.contra 30:3 $'\n2022-11-28' right:measure-bbox:measure-gbox << EOF
$
2022-11-28$
$
EOF
if [[ $_ble_test_canvas_contra ]]; then
ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:0,0-30,2'
ble/test 'echo "gbox:$gx1,$gy1-$gx2,$gy2"' stdout='gbox:20,1-30,2'
fi
ble/test:canvas/trace.contra 30:3 $'\n\n2022-11-28' right:measure-bbox:measure-gbox << EOF
$
$
2022-11-28$
EOF
if [[ $_ble_test_canvas_contra ]]; then
ble/test 'echo "bbox:$x1,$y1-$x2,$y2"' stdout='bbox:0,0-30,3'
ble/test 'echo "gbox:$gx1,$gy1-$gx2,$gy2"' stdout='gbox:20,2-30,3'
fi

#------------------------------------------------------------------------------
# trace-text

Expand Down
8 changes: 8 additions & 0 deletions memo/D1894/.gitignore
@@ -0,0 +1,8 @@
# gitignore

/sample
/sample.zip
/a.txt

# this file was the output of "starship init bash --print-full-init"
/starship.bash
10 changes: 10 additions & 0 deletions memo/D1894/bashrc
@@ -0,0 +1,10 @@
# bashrc

export STARSHIP_CONFIG=$PWD/starship-left.toml
starship_config_right=$PWD/starship-right.toml
eval "$(starship init bash)"
source ~/.mwg/src/ble.sh/out/ble.sh
bleopt prompt_ruler=empty-line
blehook PRECMD+='bleopt prompt_rps1="$(STARSHIP_CONFIG=$starship_config_right starship prompt)"'

#blehook PRECMD+='cat -A <<< "[rps1: $bleopt_prompt_rps1][[ps1: $PS1]" >> a.txt'
6 changes: 6 additions & 0 deletions memo/D1894/bashrc2
@@ -0,0 +1,6 @@
# bashrc

export STARSHIP_CONFIG=$PWD/starship.toml
eval "$(starship init bash)"
source ~/.mwg/src/ble.sh/out/ble.sh --norc
blehook PRECMD+='bleopt prompt_rps1="$(starship prompt --right)"'
16 changes: 16 additions & 0 deletions memo/D1894/bashrc3
@@ -0,0 +1,16 @@
# bashrc

eval "$(starship init bash)"

if source out/ble.sh --noattach --norc; then
blehook PRECMD+='bleopt prompt_rps1="\n\n$(starship prompt --right)"'

# function ble/prompt/backslash:starship/right {
# local right
# ble/util/assign right 'starship prompt --right'
# ble/prompt/process-prompt-string "$right"
# }
# bleopt prompt_rps1="\n\n\q{starship/right}"

ble-attach
fi
6 changes: 6 additions & 0 deletions memo/D1894/blerc
@@ -0,0 +1,6 @@
# blerc

export STARSHIP_CONFIG=~/.config/starship-left.toml
starship_config_right=~/.config/starship-right.toml
bleopt prompt_ruler=empty-line
blehook PRECMD+='bleopt prompt_rps1="$(STARSHIP_CONFIG=$starship_config_right starship prompt)"'
156 changes: 156 additions & 0 deletions memo/D1894/starship-left.toml
@@ -0,0 +1,156 @@
add_newline = false
format = """\
$username\
$directory\
$package\
$git_branch\
$git_commit\
$git_state\
$git_status\
$line_break\
$jobs\
$character\
"""

[directory]
truncate_to_repo = true
read_only = ""
truncation_symbol = "…/"

[package]
symbol = ""

[git_branch]
style = 'italic purple'
symbol = ""

[git_commit]
style = "bold white"
tag_symbol = ""
tag_disabled = false

[git_status]
conflicted = "= "
ahead = "⇡×${count} "
behind = "⇣×${count} "
diverged = "${ahead_count}×⇕×${behind_count} "
untracked = "?×${count} "
stashed = "\\$×${count} "
modified = "!×${count} "
staged = "+×${count} "
renamed = "»×${count} "
deleted = "✘×${count} "

[fill]
symbol = " "

[cmd_duration]
format = " took [$duration]($style)"
show_notifications = true
min_time_to_notify = 60_000

[env_var.WSL_DISTRO_NAME]
format = " [$env_value]($style)"
style = "underline purple"

[env_var.MSYSTEM]
format = " [$env_value]($style)"
style = "underline purple"

[shell]
format = " \\[[$indicator]($style)\\] at"
powershell_indicator = "pwsh"
style = "bold blue"
disabled = false

[battery]
full_symbol = ""
discharging_symbol = ""
charging_symbol = ""
unknown_symbol = "!"
format = " [$symbol$percentage]($style)"

[[battery.display]]
threshold = 20
style = "italic red"

[[battery.display]]
threshold = 80
style = "italic green"

[[battery.display]]
threshold = 100
style = "italic yellow"

[time]
disabled = false
format = " [$time]($style)"
style = "italic cyan"

[status]
disabled = false
format = "[$symbol$status]($style)"
symbol = ""

[memory_usage]
format = " $symbol[${ram}]($style)"
threshold = -1
symbol = ""
disabled = false

[aws]
symbol = ""

[dart]
symbol = ""

[docker_context]
symbol = ""

[elixir]
symbol = ""

[elm]
symbol = ""

[golang]
symbol = ""

# [haskell]
# symbol = " "

[hg_branch]
symbol = ""

[java]
symbol = ""

[julia]
symbol = ""

[nim]
symbol = ""

[nix_shell]
symbol = ""

[nodejs]
symbol = ""

[perl]
symbol = ""

[php]
symbol = ""

[python]
symbol = ""

[ruby]
symbol = ""

[rust]
symbol = ""

[swift]
symbol = ""

0 comments on commit cdf74c2

Please sign in to comment.