module Phi
  module_function
  private
  def visible_forms_count
    Phi::SCREEN.forms.select{|f| f.visible}.size
  end
  public
  def alive?
    @alive
  end
  
  def mainloop
    @first_forms_count = visible_forms_count
    @alive = true
    while alive?
      @alive = visible_forms_count >= @first_forms_count
      Phi::APPLICATION.process_messages
    end
  end
end

