Skip to content

Instantly share code, notes, and snippets.

@robins35

robins35/app.rb Secret

Last active November 29, 2015 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robins35/f10eae7bc248c3bef855 to your computer and use it in GitHub Desktop.
Save robins35/f10eae7bc248c3bef855 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require_relative 'environment'
begin
window = Ncurses.initscr
Ncurses.raw
Ncurses.keypad(Ncurses.stdscr, true)
#Ncurses.mvaddstr(4, 19, "Hello, world!");
Ncurses.printw("Enter your name > ")
while (Ncurses.getstr(str = "")) != 'q'
Ncurses.printw("#{str.reverse}\n")
Ncurses.printw("Rows and columns are: ")
rows, cols = Ncurses.getmaxyx
Ncurses.printw("%d, %d\n\n", rows, cols)
Ncurses.refresh
end
ensure
Ncurses.endwin
end
require 'ncurses'
module RealRubyNcurses
def getmaxyx(screen = stdscr)
row = col = []
super(screen, row, col)
row + col
end
end
class << Ncurses
prepend RealRubyNcurses
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment