I donβt know, this is what you are looking for, but maybe you can use my idea.
Since I no longer have information about what you are trying to accomplish, what is your input, etc., this example will be very simple.
Let's say we have a class to work with called PlaylistDemo, which will create a playlist with songs:
class PlaylistDemo attr_accessor :position def initialize songs @playlist = Array.new songs.each { |song| @playlist << song } @position = 0 end def show_playlist @playlist.each_with_index.map do |song, index| position == index ? "[#{song}]" : " #{song} " end end end
Prepare some songs:
# From billboard.com songs = [ "Taylor Swift - Blank Space", "Mark Ronson Featuring Bruno Mars - Uptown Funk!", "Hozier - Take Me To Church", "Meghan Trainor - Lips Are Movin", "Meghan Trainor - All About That Bass" ]
And go ahead and create an object:
pd = PlaylistDemo.new(songs)
Now my idea is to use dispel to manipulate the position and see exactly where you are (and update the "user interface" accordingly).
For this, I prepared a function that will make the user interface for your CLI application:
def show_ui playlist_obj ["\n", playlist_obj.show_playlist, "\nCurrent position: #{playlist_obj.position + 1} "].join("\n") end
The final piece of code:
Dispel::Screen.open do |screen| screen.draw show_ui(pd) Dispel::Keyboard.output do |key| case key when :up then pd.position -= 1 when :down then pd.position += 1 when "q" then break end screen.draw show_ui(pd) end end
You can also use colorize , but for this you need puts .
Please, not that I did not set a limit for the position, as this is just an example.
See my example here:

Full code: http://paste.debian.net/139651/