Sha256: 28b315ea9b41ddcbb43c52df6bd92f1b64c68f1f24e8bfccebe8e03e45b478d3
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'vedeu/support/input' require 'vedeu/support/terminal' module Vedeu ModeSwitch = Class.new(StandardError) class Application # :nocov: def self.start(options = {}) new(options).start end def initialize(options = {}) @options = options end def start Terminal.open(mode) do Terminal.set_cursor_mode Vedeu.events.trigger(:_clear_) runner { main_sequence } end end private attr_reader :options def runner if interactive? interactive { yield } else run_once { yield } end end def main_sequence Input.capture end def interactive? options.fetch(:interactive) end def interactive loop { yield } rescue ModeSwitch if Terminal.raw_mode? Application.start({ mode: :cooked }) else Application.start({ mode: :raw }) end end def run_once yield end def mode options.fetch(:mode) end def options defaults.merge!(@options) end def defaults { interactive: true, mode: :raw } end # :nocov: end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.7 | lib/vedeu/application.rb |