Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Strip color codes for ascii length calc #1220

Closed
wants to merge 1 commit into from
Closed

Conversation

fydo
Copy link

@fydo fydo commented Mar 14, 2019

Ascii images with lots of color codes would result in too large of a gap between the image and information. This uses a function to strip out color codes during the routine that determines ascii_len (and ultimately, text_padding) for ascii images.

Ascii images with lots of color codes would result in too large of a gap between the image and information. This uses a function to strip out color codes during the routine that determines ascii_len (and ultimately, text_padding) for ascii images.
@dylanaraps
Copy link
Owner

Can I see what kind of ascii you're trying to use?

@fydo
Copy link
Author

fydo commented Mar 14, 2019

Certainly! I've uploaded an example here:

https://fydo.net/misc/fydo.asc

@dylanaraps
Copy link
Owner

dylanaraps commented Mar 14, 2019

Neofetch doesn't support ascii files with embedded colors. Instead the colors are defined like this:

${c6}  .--.---.
 ( \\'--'/ )
( '..-...' )
 '.'-._.'.'
${c1}  <'-.,.->
     `\(  _
      <\\ / \
     __ \\|_/
    /  \\ \\
     '--'.\\ >
           \\

I'll look into a simpler method of stripping the escape characters.

@fydo
Copy link
Author

fydo commented Mar 14, 2019

I did see that way of defining the colors in the documentation (and being able to re-assign the color numbers at runtime is great) but it does lack the ability to provide background colors or do other fancy stuff like bold or italic escape codes.

Please let me know if you need anything else from me for this pull request. Thank you!

@konimex
Copy link
Contributor

konimex commented May 4, 2019

but it does lack the ability to provide background colors or do other fancy stuff like bold or italic escape codes.

For background color, I think you can modify color() (or add a new function like bcolor() which deals exclusively with background colors, whichever you prefer) in your PR, adding your own case like printf '\e[48;5;%bm' "$1" and then set it in set_colors() like b1="$(bcolor "$1")" or something like that.

@dylanaraps dylanaraps closed this Jan 23, 2020
@fydo
Copy link
Author

fydo commented Jan 23, 2020

I see this pull request was closed. Was this issue ever resolved? I see v6.1.0 is still exhibiting the issue where ascii color codes are causing the right info box to shift to the right (in some cases even off of the console window) due to the incorrect length calculation. Thanks in advance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants