From e029efdf9942ae20b6bb297a42079fc1c7c3f862 Mon Sep 17 00:00:00 2001 From: mavenlink Date: Mon, 30 Mar 2015 11:11:02 -0700 Subject: [PATCH] allow for checking if diag.escape? and raise DialogError if output occurs on either DIALOG_ESC or DIALOG_ERROR exit codes --- lib/base.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/base.rb b/lib/base.rb index 71d338e..52af4f2 100644 --- a/lib/base.rb +++ b/lib/base.rb @@ -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 @@ -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 @@ -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?