触发 Rebol 控制台的关闭事件?
如何在退出控制台之前触发 Rebol 控制台的关闭事件以执行一些自定义处理程序?
How to trigger close event for Rebol Console to execute some custom handler before one quit the console ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我不明白你为什么需要这个。如果您从控制台运行脚本,那么您的脚本肯定“知道”何时即将退出。
也许您正在经历系统关闭或类似情况?在这种情况下,您需要查看系统端口。
请参阅 http://www.rebol.org/ml-display-thread .r?m=rmlNFFJ
有关捕获不同操作系统的关闭事件的示例。
Well, I don't understand why you need this. If you're running a script from the console, then surely your script "knows" when it is about to quit.
Maybe you're after a system shutdown or similar? In that case you need to look at the system ports.
See http://www.rebol.org/ml-display-thread.r?m=rmlNFFJ
for an example of trapping the shutdown event for different OSes.
AFAIK REBOL 没有为此提供钩子。如果您想使用系统端口挂钩来完成此操作,则必须运行事件循环。
如果您有想要触发的行为,我要做的第一件事就是添加一个简单的 SHUTDOWN 夹层,以替换 QUIT,并在那里完成您的工作。您可以将其视为一项功能或限制,这意味着用户可以根据需要通过使用关闭按钮来避免您的逻辑。
AFAIK REBOL doesn't offer a hook for that. And if you wanted to do it with a system port hook, you would have to have an event loop running.
If you have behavior you want to trigger, the first thing I would do is add a simple SHUTDOWN mezzanine, to replace QUIT, and do your work there. You could view that as a feature or a limitation, meaning the user can avoid your logic by using the close button if they want.