module Menuboy

Constants

VERSION

Public Class Methods

fix_stdin() { || ... } click to toggle source

Use this if you need to re-enable buffering as menuboy disables this by default on STDIN You don’t need this when using system but you’ll want it if you get user input directly

# File lib/menuboy.rb, line 48
def self.fix_stdin
  self.normal_terminal
  yield
  self.raw_terminal
end
keyboard_input(k) click to toggle source
# File lib/menuboy.rb, line 21
def self.keyboard_input k
  puts k
  menu = Menuboy.menus.last
  if k == "q"
    Menuboy.menus.pop
    if next_menu = Menuboy.menus.last
      next_menu.print_help
    else
      exit # no more menus
    end
  else
    menu.handle_input(k)
  end
  Menuboy.menus.last.prompt
end
menus() click to toggle source
normal_terminal() click to toggle source
# File lib/menuboy.rb, line 17
def self.normal_terminal
  Termios::tcsetattr($stdin, Termios::TCSANOW, @termios_normal_attributes)
end
raw_terminal() click to toggle source
# File lib/menuboy.rb, line 10
def self.raw_terminal
  attributes = @termios_normal_attributes.dup
  attributes.lflag &= ~Termios::ECHO
  attributes.lflag &= ~Termios::ICANON
  Termios::tcsetattr($stdin, Termios::TCSANOW, attributes)
end