jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.92k stars 608 forks source link

256 OutputMode support prototype #76

Closed djcas9 closed 8 years ago

djcas9 commented 8 years ago

Known issue with gray-scale colors

jroimartin commented 8 years ago

Relates to #72.

jroimartin commented 8 years ago

@mephux please take into account that after submitting the review I edited/removed some of my initial comments.

djcas9 commented 8 years ago

@jroimartin all changes made - the only one Im confused on is the escape part. It seems the logic that's already in parseOne works for 256 support.

The only annoying part is 38 is used for FG and 48 for BG and if we use a case for catching 0...256 it will call into that.

Any ideas?

djcas9 commented 8 years ago

also https://github.com/mephux/komanda-cli/blob/256/komanda/gui.go#L28 usage

djcas9 commented 8 years ago

The lib i was using for 256 output was github.com/aybabtme/rgbterm. Maybe we should just add helpers to gocui for writing color strings? then we can use:

ESC[ … 38;2;<r>;<g>;<b> … m Select RGB foreground color
ESC[ … 48;2;<r>;<g>;<b> … m Select RGB background color

and pass in straight r/g/b values vs a converted rgb value.

djcas9 commented 8 years ago

@jroimartin, Last comment for tonight. I changed my code just to use the 256 terminal code vs. trying to convert RGB to the closest match. https://github.com/mephux/komanda-cli/blob/256/komanda/color/color.go

Still, have issues with the colors being wrong.. i.e., Red for some reason doesn't want to work.. haha dunno, will continue in the morning. It's getting closer at least.

screenshot

djcas9 commented 8 years ago

@jroimartin ok, it's ready to rock&roll - also added a 256 color example. Guess it just comes down to how the mode is set and making the code not so ugly.

jroimartin commented 8 years ago

Great! I'll give it a look in the next days.

djcas9 commented 8 years ago

@jroimartin awesome, thanks - small update, fixed the _examples. See https://github.com/mephux/komanda-cli/tree/256 for screenshots of a super colorful gocui app. haha

jroimartin commented 8 years ago

BTW I love the screenshots of komanda-cli with 256-colors support! :D

djcas9 commented 8 years ago

@jroimartin thanks

Ok, I fixed everything outside the support for Normal with 256. Maybe I'm missing something but I'm not sure that will be possible?

awnumar commented 8 years ago

@mephux 256 with normal support should be possible though.

djcas9 commented 8 years ago

@libeclipse @jroimartin just added that per the comments above.. it works.. just tested it in my project.

djcas9 commented 8 years ago

@jroimartin ok, that should be it -- sorry for making this such a pain in the ass. I had to learn all about terminal escaping. lol

jroimartin commented 8 years ago

Not at all! It's a great PR :)

djcas9 commented 8 years ago

@jroimartin fixed

jroimartin commented 8 years ago

Cool! I think we are ready to merge. Can you squash your commits?

djcas9 commented 8 years ago

@jroimartin sure - one sec

djcas9 commented 8 years ago

@jroimartin done - thanks!

jroimartin commented 8 years ago

Perfect! Let me do a couple of style changes (removing some empty lines) and update the AUTHORS file and will merge :)

djcas9 commented 8 years ago

@jroimartin roger, thanks for the help along the way!

jroimartin commented 8 years ago

Merged! Thanks a lot for your contribution! :D

BTW I did a couple of style changes and added 8-colors escape sequences to _examples/colors256.go.

djcas9 commented 8 years ago

@jroimartin no problem! Thanks for accepting it. :)