Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
allow for checking if diag.escape? and raise DialogError if output oc…
Browse files Browse the repository at this point in the history
…curs on either DIALOG_ESC or DIALOG_ERROR exit codes
  • Loading branch information
diclophis committed Mar 30, 2015
1 parent ff5fc3e commit e029efd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/base.rb
Expand Up @@ -9,6 +9,7 @@ module Dialog
Cancel = No = 1
Help = 2
Extra = 3
Escape = 255
Error = -1

# Base class collecting common options and handlers for a dialog
Expand Down Expand Up @@ -187,6 +188,11 @@ def help?
@exitstatus == Help
end

# Predicate, testing if the dialog was left using the Help button
def escape?
@exitstatus == Escape
end

# Gets the fixed-position box options
#
# Returns a duplicate, so subclasses can use destructive
Expand Down Expand Up @@ -274,7 +280,7 @@ def wait
@exitstatus = status.exitstatus
@output = @stderr.read

if @exitstatus == 255
if @exitstatus == Escape || @exitstatus == Error
# Raise an exception if dialog printed an error message
# If not, the user just exited the dialog using ESC
raise DialogError.new(commandline_arguments), @output unless @output.empty?
Expand Down

0 comments on commit e029efd

Please sign in to comment.