lucc / nvimpager

Use nvim as a pager to view manpages, diffs, etc with nvim's syntax highlighting
Other
372 stars 20 forks source link

Can't generate right RGB color with 256 colors using cat mode. #22

Closed kevinhwang91 closed 4 years ago

kevinhwang91 commented 4 years ago

Such as darkblue morning go wrong with 256 colors but work fine in true color. neovim version: v0.4.3 terminal: gnome-terminal | alacritty

cat test_sh.sh

#!/bin/sh

echo 'hello'

nvimpager -c test_sh.sh | nvim

[0;34;4-1m#!/bin/sh

[0;1;38;5;130;4-1mecho[0;31;4-1m [0;1;38;5;130;4-1m'[0;31;4-1mhello[0;1;38;5;130;4-1m'

=^[

lucc commented 4 years ago

I can reproduce your result (with hexdump which is better for "showing" non printable bytes):

$ ./nvimpager -c test_sh.sh -c 'colo morning' -u NORC  | hexdump -C
00000000  1b 5b 30 3b 33 34 3b 34  2d 31 6d 23 21 2f 62 69  |.[0;34;4-1m#!/bi|
00000010  6e 2f 73 68 0a 0a 1b 5b  30 3b 31 3b 33 38 3b 35  |n/sh...[0;1;38;5|
00000020  3b 31 33 30 3b 34 2d 31  6d 65 63 68 6f 1b 5b 30  |;130;4-1mecho.[0|
00000030  3b 33 31 3b 34 2d 31 6d  20 1b 5b 30 3b 31 3b 33  |;31;4-1m .[0;1;3|
00000040  38 3b 35 3b 31 33 30 3b  34 2d 31 6d 27 1b 5b 30  |8;5;130;4-1m'.[0|
00000050  3b 33 31 3b 34 2d 31 6d  68 65 6c 6c 6f 1b 5b 30  |;31;4-1mhello.[0|
00000060  3b 31 3b 33 38 3b 35 3b  31 33 30 3b 34 2d 31 6d  |;1;38;5;130;4-1m|
00000070  27 1b 5b 30 6d 0a                                 |'.[0m.|
00000076

What should the output look like? You could show the desired output with hexdump -C or upload the file with ansi escapes.

kevinhwang91 commented 4 years ago

I posted the issue in neovim, maybe it's a bug of neovim's api. https://github.com/neovim/neovim/issues/11680

kevinhwang91 commented 4 years ago

PR of neovim/neovim#11685 had merged into master branch. Waiting for the next release of neovim to solve this issue.

lucc commented 4 years ago

Thank you for solving it.