glog: Fix coloring when scrolling
Due to the formatting placeholders sitting on the previous line, the coloring of the topmost line disappeared when scrolling (as the escape sequence scrolled away). This had the background that I wanted the code that sets up the format string to be very readable and if possible very close to the actual output. And since the colors have all different lengths I decided to place them on the previous line to have them out of the way. Fix this by placing the placeholders on the same output line while still maintaining a readable format string (code). This is done by joining the array without placing newlines so that it can now have multiple elements for one output line and formatting those as wished.
This commit is contained in:
@@ -24,23 +24,23 @@ git rev-parse || return
|
|||||||
# abbreviated commit hash (yellow), title and ref names
|
# abbreviated commit hash (yellow), title and ref names
|
||||||
local formatshort='--pretty=format:%C(yellow)%h %Creset%s%C(auto)%d'
|
local formatshort='--pretty=format:%C(yellow)%h %Creset%s%C(auto)%d'
|
||||||
# Verbose format for the preview window on the right
|
# Verbose format for the preview window on the right
|
||||||
# This array is stitched together with newlines later
|
|
||||||
local -a format=(
|
local -a format=(
|
||||||
'--pretty=format:%C(yellow)' # newline created by this eaten by %-
|
'--pretty=format:'
|
||||||
'%-Commit: %H%C(auto)' # yellow commit hash
|
'%C(yellow)' 'Commit: ' '%H' '%n' # commit hash
|
||||||
' %D%Cblue' # auto colored ref names (if any)
|
'%C(auto)' ' ' '%D' '%n' # ref names (if any)
|
||||||
'Author: %aN <%aE>%Cred' # blue author mail
|
'%C(blue)' 'Author: ' '%aN <%aE>' '%n' # author mail
|
||||||
'AuthorDate: %ad%Cblue' # red author date
|
'%C(red)' 'AuthorDate: ' '%ad' '%n' # author date
|
||||||
'Commit: %cN <%cE>%Cred' # blue commiter mail
|
'%C(blue)' 'Commit: ' '%cN <%cE>' '%n' # commiter mail
|
||||||
'CommitDate: %cd%Cblue' # red commit date
|
'%C(red)' 'CommitDate: ' '%cd' '%n' # commit date
|
||||||
'Signer: %GS%Cgreen' # signer name
|
'%C(blue)' 'Signer: ' '%GS' '%n' # signer name
|
||||||
'Key (%G?): %GK' # pgp key used to sign
|
'%C(green)' 'Key (%G?): ' '%GK' '%n' # pgp key used to sign
|
||||||
'%Creset%C(bold)' # empty line
|
'%n'
|
||||||
' %s%Creset' # bold white subject
|
'%C(reset)%C(bold)' ' %s%C(reset)' '%n' # subject
|
||||||
'' # newline
|
'%n'
|
||||||
'%-b' # body
|
'%-b' # body
|
||||||
'' # newline
|
'%n'
|
||||||
)
|
)
|
||||||
|
format="${(j::)format}"
|
||||||
|
|
||||||
# Ignore the graph part at the beginning, then capture the commit hash and throw
|
# Ignore the graph part at the beginning, then capture the commit hash and throw
|
||||||
# away the rest of the line.
|
# away the rest of the line.
|
||||||
@@ -56,7 +56,7 @@ EOT
|
|||||||
fzf_preview[construct]="$REPLY"
|
fzf_preview[construct]="$REPLY"
|
||||||
|
|
||||||
read -r -d '' <<EOT
|
read -r -d '' <<EOT
|
||||||
git show "${(j:%n:)format}" "$date" --color=always --patch-with-stat "\$out"
|
git show "$format" "$date" --color=always --patch-with-stat "\$out"
|
||||||
EOT
|
EOT
|
||||||
fzf_preview[patch]="$fzf_preview[construct] { $REPLY"
|
fzf_preview[patch]="$fzf_preview[construct] { $REPLY"
|
||||||
# Get file arguments after (and including) `--` and wrap each in double quotes
|
# Get file arguments after (and including) `--` and wrap each in double quotes
|
||||||
@@ -75,7 +75,7 @@ fzf_preview[patch]+="${pager:+ | }$pager; }"
|
|||||||
fzf_preview[files_only]+="${pager:+ | }$pager; }"
|
fzf_preview[files_only]+="${pager:+ | }$pager; }"
|
||||||
|
|
||||||
read -r -d '' <<EOT
|
read -r -d '' <<EOT
|
||||||
git show "${(j:%n:)format}" "$date" --color=always --stat "\$out"
|
git show "$format" "$date" --color=always --stat "\$out"
|
||||||
EOT
|
EOT
|
||||||
fzf_preview[stat]="$fzf_preview[construct] { $REPLY; }"
|
fzf_preview[stat]="$fzf_preview[construct] { $REPLY; }"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user