ratatui / ansi-to-tui

Convert ansi colored text to tui::text::Text
https://crates.io/crates/ansi-to-tui
MIT License
57 stars 21 forks source link

panicked at 'called `Option::unwrap()` on a `None` value' #10

Closed kamiyaa closed 2 years ago

kamiyaa commented 2 years ago

Occurs on line: https://github.com/uttarayan21/ansi-to-tui/blob/master/src/ansi.rs#L69

This happens when we try to parse binary data. Issue here: https://github.com/kamiyaa/joshuto/issues/114

I believe the proper behavior here is to return an Err

uttarayan21 commented 2 years ago

I didn't notice the unwrap, thanks for pointing out the line number. Can you build it and let me know if its fixed.

I'll publish a release then. Feel free to reopen if not fixed.

kamiyaa commented 2 years ago

Thanks! I changed the dependency to latest git and it looks like its working now :+1:

kamiyaa commented 2 years ago

Although, now the colors don't seem to be working correctly :thinking:

Colors on 5127c8c

image

Colors on 0.4.1

image

Correct Bat Colors

image

uttarayan21 commented 2 years ago

Okay thats unexpected. I just changed the unwrap to match and send an error if none. I look into it tomorrow.

uttarayan21 commented 2 years ago

Hi, sorry for the absence. Had a lot going on recently. Can you provide an example preview script ? I'm not sure how to use it.

Currently the logic has gotten way to convoluted for me to understand, I'm rolling it back to the first implementation I did and proceeding from there.

kamiyaa commented 2 years ago

Hi, sorry for the absence. Had a lot going on recently. Can you provide an example preview script ? I'm not sure how to use it.

Currently the logic has gotten way to convoluted for me to understand, I'm rolling it back to the first implementation I did and proceeding from there.

I think if you just try cat some_binary_file and try processing that with your library, it will produce the unwrap error.

But I'm mostly concerned about the output not being properly colorized. ie. bat some_text_file and the preview is not colorized properly under tui

wendajiang commented 2 years ago
   ██  ██████                                
   ██  ██████                                
   ██  ██████                                
   ██  ██████                                
   ██  ██████                                
   ██  ██████                                
   ██  ██████                            ██  
   ██  ██████                            ██  
   ██  ██████                            ██  
   ██  ██████                            ██  
   ██  ██████                    ██████  ██  
   ██  ██████                    ██████  ██  
   ██  ██████             █████  ██████  ██  
   ██  ██████             █████  ██████  ██  
   ██  ██████  █████  ██  █████  ██████  ██  
   ██  ██████  █████  ██  █████  ██████  ██  
   ██  ██████  █████  ██  █████  ██████  ██  

when i revert this commit, the color is normal, like this

image

And this commit cause all color is black, I will look inside why.

sayanarijit commented 2 years ago

If possible, take a look at #13