Added release 19.05.

git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@2152 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
jfiat
2019-05-19 11:17:36 +00:00
parent 2c8d6d6f35
commit 5c23b7c968
2939 changed files with 62245 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
[[Property:modification_date|Wed, 17 Apr 2019 14:06:41 GMT]]
[[Property:publication_date|Wed, 17 Apr 2019 14:02:25 GMT]]
[[Property:uuid|5CA34C5D-30F1-4D6F-9FE4-B555E541EA8C]]
[[Property:weight|4000]]
[[Property:title|Managing CTRL+C in console application]]
Normally, if the user uses the CTRL+C keys, the Eiffel application detect it as an error and throw an exception of type <code>OPERATING_SYSTEM_SIGNAL_FAILURE</code>.
To manage the CTRL+C keys, you can use a <code>rescue</code> clause to detect the exception and a <code>retry</code> mechanism to cancel the exception handling done by the Eiffel runtime.
To detect the exception, you can <code>inherit</code> from the <code>EXCEPTIONS</code> class and use an attachment test on <code>Exception_manager.last_exception</code>.
Note that this code does not work on Windows. If used on Windows, the application will quit, but the <code>rescue</code> call is not launched.
<code>
note
description: "Show how to quit an application using CTRL+C (without trace)."
author: "Louis Marchand"
date: "Wed, 25 Apr 2018 23:12:33 +0000"
revision: "0.1"
class
APPLICATION
inherit
EXCEPTIONS
create
make
feature {NONE} -- Initialization
make
-- Launch `Current'.
local
l_ctrl_c:BOOLEAN
do
if not l_ctrl_c then
from until False loop
io.standard_default.put_string ("Press CTRL+C%N")
io.input.read_line
end
else
io.standard_default.put_string ("%NClosing...%N")
end
rescue
if attached {OPERATING_SYSTEM_SIGNAL_FAILURE}
Exception_manager.last_exception then
l_ctrl_c := True
retry
end
end
end
</code>