Question about colorize and methods

Hello, actually I’m working in the output design of this part of my function:

puts "#{ISM::Default::Option::SoftwareInstall::InstallQuestion.colorize.mode(:underline)}" + 
                                "[" + "#{ISM::Default::Option::SoftwareInstall::YesReplyOption.colorize(:green)}" + 
                                "/" + "#{ISM::Default::Option::SoftwareInstall::NoReplyOption.colorize(:red)}" + "]"

                        loop do
                            userInput = gets
                            if userInput == ISM::Default::Option::SoftwareInstall::YesReplyOption
                                userAgreement = true
                            if userInput == ISM::Default::Option::SoftwareInstall::NoReplyOption

First question, can I change ONLY the color of the underline ?

My second question is, just after my String before the loop, I have a gets method. How can I do to have my cursor just after my text, and not in a newline after

AFAIK terminal coloring only supports foreground and background color and the underline is always the foreground color.

This is unfortunately not trivial to achieve. I’d recommend using a dedicated library for terminal UI such as readline or curses if you want this.

Oh sad … okay thanks you

If you mean something like this:

Install? [Y/n] ▋

instead of

Install? [Y/n]

Then you can achieve that by changing puts to print. puts adds an implicit newline at the end of the output, but print does not.


Yes it’s what I mean, I will try that, thanks you

It’s perfect, thanks you very much.

My mistake is I was thinking the problem came from the gets command. I don’t know why I was thinking that