Working with Ruby by Jan Lelis

Building yet another terminal colors gem: term-ansicolor meets rainbow

There are plenty terminal color gems out there. Now, there is one more. Why?

What’s out there?

I’ve found about 14 miscellaneous ansi color string libraries with some quick searches on github and rubygems. However, about eight of them where using string extensions. This is not really suitable for library development.

The most interesting (and popular) ones are rainbow, which supports 256-color terminals, and term-ansicolor, which can be used very flexible without forcing string extensions. HighLine is another nice gem that’s capable of terminal colors, but it’s just a little part of something that maybe can be described as a “console io framework”.

My design goals

  • Should not use string extensions by default
  • Should support 256 colors
  • Should have a consistent api that is easy to use
  • Should allow applying multiple effects via one escape sequence, not by nesting (so red and bold is \e[31;1m not \e[31m\e[1m)
  • Should provide a way to define custom color names (this also allows to get compatible with gems that use “wrong” color names, e.g. Wirb and Wirble)
  • Should support setting any escape sequences, even if the current terminal does not support it
  • Should stay as thin as possible

Paint!

See the results at github.com/janlelis/paint ;)

Creative Commons License

Comments

Marion | August 22, 2015

Other amount http://www.c5designs.com/about-c5/ aldactone online "It stated: 'Although on more than one occasion subjected to vulgar insults by splenetic, ill-tempered players, he uniformly preserved that gentlemanly demeanour which has endeared him to opponents as well as his club companions'.

Quentin | August 22, 2015

What do you study? http://www.c5designs.com/about-c5/ buy cheap aldactone Keys officials regularly battle the common Salt Marshmosquitoes that breed by the millions and can fly up to sixmiles. Yet their chief concern is the Aedes aegypti mosquitothat carries dengue, known as breakbone fever for the intensejoint pains it causes.

Jarvis | August 22, 2015

Photography http://www.computerrepairleeds.co.uk/mac-repairs-leeds celebrex coupons However, please note - if you block/delete all cookies, some features of our websites, such as remembering your login details, or the site branding for your local newspaper may not function as a result.

Byron | August 22, 2015

I'd like to send this parcel to http://www.clsecurities.com/mutualfunds.html cipro online pharmacy Last month U.S. Gen. Martin Dempsey, chairman of the Joint Chiefs of Staff, said he would like to see an agreement by October to give NATO enough time to prepare for a post-2014 military presence instead of a total pullout.

Johnathan | August 22, 2015

What's the last date I can post this to to arrive in time for Christmas? http://www.chocolatepoker.hu/online-poker-suli/poker-jelek/ hydroxyzine 25 "The image of the crouching hero with the bow is typical for warrior gods," Pappi wrote in the email. "The most common of these was the god Ninurta, who also played an important role in the [Assyrian] state religion, and it is possible that the figure on the seal is meant to represent him."

Shannon | August 22, 2015

Directory enquiries http://www.galizacogalego.com/avoaescola overnight bimatoprost cod "They are working in very challenging circumstances in the field. In awarding the prize they said it was about recognising the work of the past 16 years, but also the work that lies ahead, in Syria."

Orville | August 22, 2015

A pension scheme http://www.galizacogalego.com/avoaescola where can you buy generic bimatoprost without a prescription The nurse told her to go outside and walk, and said a doctor could check her in the morning, Lopez said. But an hour and a half later, her water broke, and Lopez gave birth to a son, her third child, while grabbing the wall of a house next to the clinic.

Jamey | August 22, 2015

I wanted to live abroad http://www.cresthillsuites.com/corporate-info/ where can i buy amoxicillin uk Unlike UBS's strong private banking performance, however, Julius Baer missed new money targets and raised the cost of integrating Bank of America Merrill Lynch's overseas private bank, a flagship acquisition last year, by around 55 million francs.

Lucien | August 22, 2015

How long are you planning to stay here? http://www.computerrepairleeds.co.uk/mac-repairs-leeds celebrex price comparison The local government's response to public queries drew even more jeers. Officials posted a statement online maintaining that the law allows for lease periods of less than 70 years and adding: "Who knows if we'll still be in this world in 40 years. Don't think too long-term."

Thanh | August 22, 2015

I study here http://www.chocolatepoker.hu/online-poker-suli/poker-jelek/ order atarax online Lawmakers also took the opportunity to criticize the FederalReserve for allowing banks to expand their commodity activities,and once again questioned the wisdom of scrapping theGlass-Steagall law that separated corporate and investmentbanking, a decision that helped open the door to commoditydealing.

Barney | August 23, 2015

I'm a trainee <a href=" http://www.offordcentre.com//readiness/coordinators.html#numbers ">where to buy zithromax online</a> "We are studying the IPAB's decision but maintain our belief in the inventiveness of the lapatinib ditosylate salt and will consider the possibility of taking further steps before the appropriate authorities to validate this," the Indian unit of UK-based GSK said in an email to Reuters on Friday.

Orlando | August 23, 2015

A packet of envelopes <a href=" http://www.offordcentre.com//readiness/coordinators.html#roughly ">zithromax cheap</a> While Wilson believes the United States' failure to attack Syria will be the trigger for the war, he thinks the government shutdown and debt ceiling just further confirms to enemies that the U.S. "is in decline," potentially hastening the war.

Amado | August 23, 2015

Do you know the number for ? <a href=" http://www.daisylane.ie//wedding-flowers/#fore ">rogaine 5 minoxidil topical aerosol</a> Many economists expect the Fed would begin slowing itsasset-buying programme as early as next month, especially inlight of data showing U.S. economic growth was not quite as weakas expected in the second quarter.

Josiah | August 23, 2015

I work with computers <a href=" http://www.offordcentre.com//readiness/coordinators.html#wrist ">zithromax z-pak online</a> The telecast will be based on the original 1959 Broadway musical, which starred Mary Martin (who won a Best Actress Tony) as Maria. Julie Andrews is perhaps most readily remembered for the role, in the Oscar-winning 1965 film.

Isaac | August 23, 2015

Where do you come from? <a href=" http://www.georgemartinmusic.com//george_martin.htm ">cost of rogaine at walmart</a> There&#x2019;s a simpler reason for American reluctance to intervene in the Middle East that plays a much bigger role in peoples&#x2019; attitudes about foreign policy. It can be summed up with the words &#x201C;to hell with them.&#x201D;

Loren | August 23, 2015

What do you do for a living? <a href=" http://www.solarculture.org//history.php ">generic propecia canada</a> “I’ve come up with some guys that left. There’s always that doubt,” Pedroia said. “Always, in my heart, I felt like I would always play every game for the Red Sox. Just being here right now, this happening, it’s pretty special to me and my family.”

Delmer | August 23, 2015

Is this a temporary or permanent position? <a href=" http://www.georgemartinmusic.com//george_martin.htm#feature ">men's rogaine extra strength solution reviews</a> "We ask the FDA to move quickly to ensure that all tobacco products are tested and regulated to ensure that companies do not continue to sell or advertise to our nation's youth," they wrote.

Renato | August 23, 2015

How much will it cost to send this letter to ? <a href=" http://www.dcr.ie//about-us/#fix ">tadalafil tadacip cipla</a> He discussed that three-year research effort late Wednesday afternoon in one of the most anticipated talks at Black Hat, a conference where some 7,000 security professionals gathered to hear about the latest risks posed by hacking.

Maynard | August 23, 2015

I'm a trainee <a href=" http://doctorhenderson.co.uk//DrHendersonBlog/#outward ">donde puedo comprar las pastillas cytotec en costa rica</a> Sen. Brian Schatz, D-Hawaii, introduced an amendment Wednesday to the pending immigration bill that aims to allow Pacific islanders and others affected by climate change to reside legally in the United States.

Isabelle | August 23, 2015

Jonny was here <a href=" http://www.adirondack.org//support ">bimatoprost ophthalmic generic</a> Some of the journalists have been here for two weeks - and on Monday morning their ranks began to swell as Kensington Palace announced the Duchess of Cambridge had been admitted to the hospital and was in the early stages of labour.

Dewey | September 01, 2015

I'm unemployed <a href=" http://www.sierraluz.com/tarifas.html#gasoline ">bimatoprost timolol side effects</a> "I think we are in a place now where the next step of thatdiscussion can take place regardless of what happens withrespect to Iran," Kerry said. "We would like to reach anunderstanding with Russia and I think Russia would like to reachan understanding with us."

Refugio | September 01, 2015

I came here to work <a href=" http://www.adirondack.org/support ">bimatoprost pay cod</a> Other significant Sunni Assad-backers include Emad Ghraiwait, Fares Chehabi and Tarif Akhras, who were hit with European Union sanctions in 2011 for "providing economic support to the Syrian regime." Among the largest exporters in Syria, Akhras is related to Asma al-Assad, Syria's first lady.

Cesar | September 01, 2015

magic story very thanks <a href=" http://www.webgreb.org/index.php/ca/projectes#celebration ">order finasteride online</a> Taking her place at the Despatch Box, she said: &ldquo;The irony of Alan Turing being prosecuted for his sexuality when he helped fight Hitler, who prosecuted and gassed homosexuals, was surely not lost on him.

Coolman | September 01, 2015

I do some voluntary work <a href=" http://www.mitskillsindia.com/about.php ">dapoxetine medicine in pakistan</a> "We're a human-run agency operating in a complex environmentwith a number of different regulatory regimes, so at times wefind ourselves on the wrong side of the line," a senior NSAofficial, speaking on the condition of anonymity, told the Post.

Nicolas | September 01, 2015

Just over two years <a href=" http://www.chicsweets.net/about-us/ ">generic aripiprazole</a> Former general insurance chief Mario Greco left a year agoto become head of Italian insurer Generali. The headof Zurich's life insurance arm, Kevin Hogan, quit to join AIG in August, the same month Zurich's chief of staff AnnHaugh left after just a year in the role.

Benedict | September 01, 2015

A jiffy bag <a href=" http://www.webgreb.org/index.php/ca/contacte ">premarin room 0.625 mg</a> One of the food stamp reforms sought by Republicans wouldrequire recipients to work or enroll in a job-training class.Sponsor Steve Southerland of Florida said "we have done adisservice" if people do not move into the workforce.

Dillon | September 01, 2015

What do you want to do when you've finished? <a href=" http://www.lexacomlegal.com/david-hutchins/#pug ">bactrim ds uses</a> Already trailing, 2-1, in the third, Sabathia found himself in trouble thanks to a walk and a pair of errors that helped the Angels load the bases with one out. The lefty walked Chris Nelson to make it 3-1, but Sabathia came back and fanned Josh Hamilton before retiring Erick Aybar on a groundout to leave the bases loaded.

Jeremy | September 01, 2015

Where's the nearest cash machine? <a href=" http://www.sunsystem.it/aziende/ ">cardura e 10</a> That's why we need fewer knee-jerk laws. People don't think things thru. Can you imagine having to let this whale continue to suffer when you can free it? Cell phone connectivity offshore doesn't exist.

Lloyd | September 01, 2015

About a year <a href=" http://www.pivotmarine.com/maritime-consultancy ">megalis tablets</a> While some Finns still view their eastern neighbour andformer ruler with suspicion, expectations of only a slowEuropean recovery mean more businesses are likely to embracecloser ties with Russia, signalling a readjustment after twodecades of close commercial relations with Europe.

Jamar | September 01, 2015

How many weeks' holiday a year are there? <a href=" http://www.webgreb.org/index.php/ca/projectes ">order finasteride uk</a> Obama has made a lot of individual decisions about drones on many individual days. every one of the missions signed off should be disclosed &reviewed as that's a whole heap of bloodshed and innocent dead by a US President breaking law criminally. Internet & News Media don't show pictures of dead they show arrogant sweaty faces of Obama Cameron Hague Comedians Breakfast-Late Night TV 24/7/365 w/ads

You? | September 02, 2015