lib/reterm/init.rb
# Initializes the RETerm subsystem before invoking block.
# After block is finished regardless of execution state
# (return, exception, etc) this will cleanup the terminal
# environment before returning control to the TTY.
#
# This method is the first method the user should invoke
# after requiring the reterm library.
#
# @example
#   init_reterm {
#     win = Window.new :rows => 20, :cols => 40
#     # ... more UI logic
#   }
#
Initializes the RETerm subsystem before invoking block.
After block is finished regardless of execution state
(return, exception, etc) this will cleanup the terminal
environment before returning control to the TTY.

This method is the first method the user should invoke
after requiring the reterm library.
Initializes the RETerm subsystem before invoking block . After block is finished regardless of execution state ( return exception etc ) this will cleanup the terminal environment before returning control to the TTY . This method is the first method the user should invoke after requiring the reterm library .
def init_reterm(opts={}, &bl)
    @@shutdown = false
    @@reterm_opts = opts
    err = nil
    min = opts[:min_size]
    begin
      Terminal.load(min)
      ENV["ESCDELAY"] = 100.to_s
      stdscr = Ncurses::initscr
      initialized = true
      Ncurses::start_color
      Ncurses::noecho
      Ncurses::cbreak
      disable_cursor! unless !!opts[:cursor]
      Ncurses::keypad(stdscr, true)
      no_mouse = opts[:nomouse] || (opts.key?(:mouse) && !opts[:mouse])
      Ncurses::mousemask(MouseInput::ALL_EVENTS, []) unless no_mouse
      track_resize if opts[:resize]
      bl.call
    rescue => e
      err = e
    ensure
      stop_track_resize
      Ncurses.curs_set(1) if !!initialized
      Window.top.each { |w| w.finalize! }
      CDK::SCREEN.endCDK if cdk_enabled?
      Ncurses.endwin if !!initialized
    end
    if err
      puts "Unhandled error:"
      puts "  " + err.to_s
      puts err.backtrace
              .collect { |b|
                "    " + b
              }.join("\n")
    end
  end
def init_reterm ( opts = { } , & bl ) @@shutdown = false @@reterm_opts = opts err = nil min = opts [ :min_size ] begin Terminal . load ( min ) ENV [ "ESCDELAY" ] = 100 . to_s stdscr = Ncurses :: initscr initialized = true Ncurses :: start_color Ncurses :: noecho Ncurses :: cbreak disable_cursor! unless ! ! opts [ :cursor ] Ncurses :: keypad ( stdscr , true ) no_mouse = opts [ :nomouse ] || ( opts . key? ( :mouse ) && ! opts [ :mouse ] ) Ncurses :: mousemask ( MouseInput :: ALL_EVENTS , [ ] ) unless no_mouse track_resize if opts [ :resize ] bl . call rescue => e err = e ensure stop_track_resize Ncurses . curs_set ( 1 ) if ! ! initialized Window . top . each { | w | w . finalize! } CDK :: SCREEN . endCDK if cdk_enabled? Ncurses . endwin if ! ! initialized end if err puts "Unhandled error:" puts "  " + err . to_s puts err . backtrace . collect { | b | "    " + b } . join ( "\n" ) end end
Initializes the RETerm subsystem before invoking block.
Initializes the RETerm subsystem before invoking block .
# XXX: must load terminal info before changing terminal settings #      (else causes crash... not sure why) # But we also check min dimensions here # shorten up the esc delay time #`reset -Q` # XXX only way to guarantee a full reset (see above)
opts
<not_specific>
bl
<not_specific>
example
None