class Flumtter::Window::Dialog

Public Class Methods

new(*args) click to toggle source
Calls superclass method Flumtter::Window::Base::new
# File lib/flumtter/app/core/windows/dialog.rb, line 6
def initialize(*args)
  super
  @commands = []
end

Public Instance Methods

call(str) click to toggle source
# File lib/flumtter/app/core/windows/dialog.rb, line 15
      def call(str)
        if str == "?"
          Window::Popup.new("Command List", <<~EOF).show
            #{Command.list(@commands)}
          EOF
          raise Dispel::Recall
        else
          @commands.each do |command|
            if m = str.match(command.command)
              return command.call(m)
            end
          end
          raise Dispel::NoCommandError
        end
      end
command(command, help="", &blk) click to toggle source
# File lib/flumtter/app/core/windows/dialog.rb, line 11
def command(command, help="", &blk)
  @commands << Command.new(command, help, &blk)
end
show(recall=false, help=true) { |win| ... } click to toggle source
# File lib/flumtter/app/core/windows/dialog.rb, line 31
def show(recall=false, help=true)
  Dispel::Screen.open do |screen|
    Dispel::Window.open(@hight, @width, 0, 0) do |win|
      win.box(?|,?-,?*)
      win.setpos(win.cury+2, win.curx+1)
      win.addstr @title.title
      win.setpos(win.cury+1, 1)
      win.addstr "¯"*(@title.title.size+2)

      add_multiline_str(win, @body)

      if block_given?
        yield win
      else
        win.setpos(win.cury+2, 1)
        if help
          win.addstr "help: ?".rjust(win.maxx - 2)
          win.setpos(win.cury+1, 1)
        end
        call getstr(win)
      end
    end
  end
rescue Dispel::Recall
  show(recall, help)
rescue Dispel::NoCommandError => e
  Window::Popup::Error.new(e.class.to_s).show
  show(recall, help) if recall
end