Remove evil curses
gem install dispel
require 'dispel'
# draw app and redraw after each keystroke
Dispel::Screen.open do |screen|
screen.draw "Initial state, press any key!\n\n Oh boy!"
Dispel::Keyboard.output do |key|
break if key == :"Ctrl+c"
screen.draw "Looks like you pressed #{key} (Ctrl+c to quit)"
end
end
require 'dispel'
# draw app and redraw after each keystroke
Dispel::Screen.open(colors: true) do |screen|
map = Dispel::StyleMap.new(3) # number of lines
map.add(:reverse, 0, 1..5) # :normal / :reverse / color, line, characters
map.add(["#aa0000", "#00aa00"], 0, 5..8) # foreground red, background green
screen.draw "Shiny Rainbows!\nDefault\nand more!", map, [0,3] # text, styles, cursor position
Dispel::Keyboard.output { break }
end
require 'dispel'
# draw app and redraw after each keystroke
Dispel::Screen.open do |screen|
Dispel::Keyboard.output timeout: 0.5 do |key|
if key == :timeout
screen.draw "The time is #{Time.now}"
elsif key == :"Ctrl+c"
break
else
screen.draw "You pressed #{key}"
end
end
end
- resize event should triggered instantly after resizing, not after first key press
Michael Grosser
michael@grosser.it
License: MIT