Project

dispel

0.02
No commit activity in last 3 years
No release in over 3 years
Remove evil curses
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Remove evil curses

Install

gem install dispel

Usage

Black and white

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

Colors

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

Periodical refresh

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

Example applications

TODO

  • resize event should triggered instantly after resizing, not after first key press

Author

Michael Grosser
michael@grosser.it
License: MIT
Build Status