Sha256: 915555a8b4a4c414d63b6981494176c27b18a5e52d3138b59e726e19cb2a5c4e
Contents?: true
Size: 926 Bytes
Versions: 1
Compression:
Stored size: 926 Bytes
Contents
require "ffi-ncurses" require_relative "rurses/version" require_relative "rurses/panel_stack" require_relative "rurses/window" module Rurses SPECIAL_KEYS = Hash[ FFI::NCurses::KeyDefs .constants .select { |name| name.to_s.start_with?("KEY_") } .map { |name| [ FFI::NCurses::KeyDefs.const_get(name), name.to_s.sub(/\AKEY_/, "").to_sym ] } ] module_function def curses FFI::NCurses end def program(modes: [ ]) @stdscr = Window.new(curses_ref: curses.initscr, standard_screen: true) @stdscr.change_modes(modes) yield(@stdscr) ensure curses.endwin end def stdscr @stdscr end def get_key case (char = curses.getch) when curses::KeyDefs::KEY_CODE_YES..curses::KeyDefs::KEY_MAX SPECIAL_KEYS[char] when curses::ERR nil else char.chr end end def update_screen curses.doupdate end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rurses-0.1.0 | lib/rurses.rb |