require 'curses' require 'iconv' include Curses class CursesController include EntriesController include FeedsController include EntryController def log(statement) LOGGER.debug(statement) end def show_help(text) @command_window.escape_help_prompt @help_window = Curses::Window.new(@scr.maxy - 4, @scr.maxx, 0, 0) @text_area = Curses::Window.new(@scr.maxy - 4, @scr.maxx - 4, 2, 5) @help_window.clear @text_area.addstr(PREAMBLE) @text_area.addstr(text) @text_area.addstr(FOOTER) @help_window.refresh @text_area.refresh @scr.getch @text_area.close @help_window.close end PREAMBLE = <, . Go to next entry in the list <, , Go to previous entry in the list Actions q Quit the program s, * Flag an entry. Flagged entries appears in a virtual feed called "Flagged Entries." \\ Show raw entry content markup END def initialize(formatter) # Formatter is the Display class. Should change the variable names to match the class # names or vice versa. @formatter = formatter @scr = init_screen noecho cbreak Color.init curs_set(0) @scr.keypad = true log "Screen width: #{@scr.maxx} | Screen height: #{@scr.maxy}." log "Command window initilized." end def key_buffer(initial_char) c = initial_char buffer = [] printable = (33..126).to_a while printable.include?(c) && c.chr =~ /\d/ LOGGER.debug("detecting a multiplier: #{c.chr}") # TODO This code doesn't work right buffer << c.chr.to_i c = @scr.getch end return c, buffer end def control_key(character) character[0] - 64 end end