cowsay icon indicating copy to clipboard operation
cowsay copied to clipboard

Remove speech bubble from ascii

Open oganm opened this issue 5 years ago • 17 comments

It seems like the default way of specifying animals forces speech bubbles within the elements of the animals object, causing the output to be less pretty compared to the command line alternative.

< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

vs

 ----- 
hello 
 ------ 
    \   ^__^ 
     \  (oo)\ ________ 
        (__)\         )\ /\ 
             ||------w|
             ||      ||

This can be solved by giving the responsibility of creating the speech bubble to say function. Would this be a welcome change? I can look into it if I find some spare time.

oganm avatar Dec 18 '18 04:12 oganm

forces speech bubbles within the elements of the animals object

can you clarify? not sure what you mean

sckott avatar Dec 18 '18 20:12 sckott

You define an animal as

---
%s
---
 \
  \
   animal

Which means the speech bubble will look the same no matter what the input text is. For instance

---
extremely long input that this bubble is clearly not designed for
---
 \
  \
   animal

While if instead animals were defined as

%s
   \
    \
     animal

You could replace the entire speech bubble with one that looks appropriate to the input size.

 _________________________________________________________________________
< extremely long input in a bubble created based on input character count >
 -------------------------------------------------------------------------
 \
  \
   animal

oganm avatar Dec 18 '18 21:12 oganm

Okay.

My cli cowsay has vertical bars instead of carrots, not important really, but just to show you

lorem -s 5 | cowsay
 _________________________________________
/ Lorem ipsum dolor sit amet,             \
| consectetuer adipiscing elit! Aenean    |
| commodo ligula eget dolor? Aenean       |
| massa; Cum sociis natoque penatibus et  |
| magnis dis parturient montes, nascetur  |
| ridiculus mus? Donec quam felis,        |
| ultricies nec, pellentesque eu, pretium |
\ quis, sem!                              /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

I think making this the default would be good. it'd be good to have the bubble envelop the entire string

wrt letting the user specify, can you give a use case? and might it be difficult for the user to know how to give the bubble? i guess you could present options for the bubble that are a set that we know work well.

sckott avatar Dec 18 '18 21:12 sckott

any thoughts on this @oganm ? do you want to submit a PR?

opinions @aedobbyn ? do you want this change or no?

sckott avatar Feb 01 '19 18:02 sckott

Interesting idea! I think I like it.

@sckott's cli cowsay I think looks good because it's more compact than the full width of the terminal.

As far as implementing something like that, for the top and bottom of the bubble I guess you'd just make a line measured by something like

min(options("width")$width, some_max_width)

to ensure that some_max_width isn't greater than the user's console width, where either we or the user determine some_max_width.

Then add |s for all lines except the first and last, which get / and \.

As far as splitting the text up into lines I'm not totally sure but I don't think you wouldn't want to split up the text exactly evenly because that would spread words across multiple lines. So you'd probably want to go with splitting on the last space character without going over min(options("width")$width, some_max_width). Does that sound about like what you had in mind @oganm?

aedobbyn avatar Feb 01 '19 20:02 aedobbyn

Not sure how much it should be based on the terminal size as it might get too unwieldy. Something adjustable with a smaller default would probably look better. The command cowsay seems to limit it to 44 characters by default

oganm avatar Feb 01 '19 23:02 oganm

also sorry about a lack of a PR. didn't have time to look into it

oganm avatar Feb 02 '19 01:02 oganm

Yeah sorry I didn't explain well. The idea is that the maximum width would be some_max_width or 44. We'd have to shrink the speech bubble to less than 44 if the user's console is smaller than that, though. If their console is smaller, then the speech bubble width would just be the user's console width. Does that make sense?

aedobbyn avatar Feb 02 '19 13:02 aedobbyn

makes sense @aedobbyn

sckott avatar Feb 05 '19 19:02 sckott

Cool cool. If you want to put together a PR @oganm, go for it. Another idea would be to kick it to participants at an upcoming unconf I'm planning on going to since this would be a cool thing for people to talk through implementing. (The idea with this unconf is to let participants contribute to existing packages.) It's your idea, though, so very much up to you!

aedobbyn avatar Feb 05 '19 19:02 aedobbyn

If I'm not done by that time feel free to hand it to the unconf. Will try to take a look before that

oganm avatar Feb 06 '19 12:02 oganm

Works for me, thanks @oganm

aedobbyn avatar Feb 06 '19 15:02 aedobbyn

Hey @oganm and @sckott -- planning on using this issue as a jumping-off point at the upcoming unconf I mentioned, if that's okay with you both. Happy to keep you guys in the loop next weekend as people work on it, if you want!

https://github.com/chirunconf/chirunconf19/issues

aedobbyn avatar Mar 05 '19 23:03 aedobbyn

sounds good @aedobbyn

sckott avatar Mar 05 '19 23:03 sckott

yep. it's fine :+1:

oganm avatar Mar 05 '19 23:03 oganm

Awesome, thanks guys!

aedobbyn avatar Mar 06 '19 14:03 aedobbyn

@aedobbyn It would be nice to make this change. Would you want to do it, and have time to?

sckott avatar Oct 14 '23 13:10 sckott