User Interrupt window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

User Interrupt window

Jim O'Brien
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

marcel.taeumel
Hi, there.

1) Subclass StandardToolSet.
2) There, implement #interrupt:label: as you want it.
3) Set your new tool set via "ToolSet register: MyToolSet" and "ToolSet default: MyToolSet".

Note that ToolSet is an AppRegistry and hence a wrapper whereas StandardToolSet is an actual tool set. :-) Other app registries include WebBrowser and SoundService.

The user interrupt is not implemented with exceptions but a watchdog process and a special semaphore. See EventSensor >> #userInterruptWatcher for more information.

Best,
Marcel

Am 09.12.2017 18:09:51 schrieb obrienj <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Ron Teitelbaum
In reply to this post by Jim O'Brien
Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Jim O'Brien
Squeak complains that it doesn't know InputSensor.



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 10:06 AM
UTC Time: December 9, 2017 6:06 PM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Ron Teitelbaum
You can use Sensor instead.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 2:56 PM, obrienj <[hidden email]> wrote:
Squeak complains that it doesn't know InputSensor.



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 10:06 AM
UTC Time: December 9, 2017 6:06 PM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Jim O'Brien
Tried that but Sensor doesn't know interruptSemaphore



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 12:35 PM
UTC Time: December 9, 2017 8:35 PM
To: obrienj <[hidden email]>
A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

You can use Sensor instead.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 2:56 PM, obrienj <[hidden email]> wrote:
Squeak complains that it doesn't know InputSensor.



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 10:06 AM
UTC Time: December 9, 2017 6:06 PM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Ron Teitelbaum
I see.  You are right.  It's an instance var but there is no accessor for it.  

You will need to add an accessor for it to override the emergency evaluator.  

EventSensor >> interruptSemaphore
    "return the interruptSemaphore. Used for overriding the emergency evaluator on MyClass"
    ^interruptSemaphore

Then it should work.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 3:38 PM, obrienj <[hidden email]> wrote:
Tried that but Sensor doesn't know interruptSemaphore



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 12:35 PM
UTC Time: December 9, 2017 8:35 PM
To: obrienj <[hidden email]>
A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

You can use Sensor instead.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 2:56 PM, obrienj <[hidden email]> wrote:
Squeak complains that it doesn't know InputSensor.



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 10:06 AM
UTC Time: December 9, 2017 6:06 PM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list





_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Jim O'Brien
Now Squeak complains that installInterruptWatcher is an unknown selector. 



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 12:48 PM
UTC Time: December 9, 2017 8:48 PM
To: obrienj <[hidden email]>
A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

I see.  You are right.  It's an instance var but there is no accessor for it.  

You will need to add an accessor for it to override the emergency evaluator.  

EventSensor >> interruptSemaphore
    "return the interruptSemaphore. Used for overriding the emergency evaluator on MyClass"
    ^interruptSemaphore

Then it should work.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 3:38 PM, obrienj <[hidden email]> wrote:
Tried that but Sensor doesn't know interruptSemaphore



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 12:35 PM
UTC Time: December 9, 2017 8:35 PM
To: obrienj <[hidden email]>
A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

You can use Sensor instead.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 2:56 PM, obrienj <[hidden email]> wrote:
Squeak complains that it doesn't know InputSensor.



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 10:06 AM
UTC Time: December 9, 2017 6:06 PM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list





_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Ron Teitelbaum

Notice the colon on the selector. Check instance side of EventSensor for method.

Ron


On Sat, Dec 9, 2017, 11:46 PM obrienj <[hidden email]> wrote:
Now Squeak complains that installInterruptWatcher is an unknown selector. 



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 12:48 PM
UTC Time: December 9, 2017 8:48 PM
To: obrienj <[hidden email]>
A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

I see.  You are right.  It's an instance var but there is no accessor for it.  

You will need to add an accessor for it to override the emergency evaluator.  

EventSensor >> interruptSemaphore
    "return the interruptSemaphore. Used for overriding the emergency evaluator on MyClass"
    ^interruptSemaphore

Then it should work.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 3:38 PM, obrienj <[hidden email]> wrote:
Tried that but Sensor doesn't know interruptSemaphore



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 12:35 PM
UTC Time: December 9, 2017 8:35 PM
To: obrienj <[hidden email]>
A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

You can use Sensor instead.

All the best,

Ron Teitelbaum

On Sat, Dec 9, 2017 at 2:56 PM, obrienj <[hidden email]> wrote:
Squeak complains that it doesn't know InputSensor.



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 10:06 AM
UTC Time: December 9, 2017 6:06 PM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

Hi OBrien J

One way to do this is to install a new interruptWatcher on Sensor.  

On the class you want to handle the message do something like

Sensor installInterruptWatcher:[self userInterruptWatcher].

Yourclass >> userInterruptWatcher
"Wait for user interrupts and open a notifier on the active process when one occurs."
| interruptSemaphore |
interruptSemaphore := InputSensor interruptSemaphore.
[true] whileTrue: [
interruptSemaphore wait.
self signal: #userInterrupt.
].

Then implement your handler with something like onUserInterrupt to respond to the signal.  Or you could just call a method in your class to handle the interrupt.  

Hope that helps!

All the best,

Ron Teitelbaum 


On Sat, Dec 9, 2017 at 12:09 PM, obrienj <[hidden email]> wrote:
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.




_______________________________________________
Beginners mailing list




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Jim O'Brien
In reply to this post by marcel.taeumel
Hi Marcel,

I made MyToolSet, a subclass of StandardToolSet, and added a copy of #interrupt:label to it.

I next created HaltExperiment as an Object subclass and added this simple, infinite loop method:

infiniteLoop
| x |
ToolSet register:  MyToolSet.
ToolSet default:  MyToolSet.
Transcript clear. x := 0.
[x >= 0] whileTrue: [x := x + 1. Transcript show: 'x = ', x; cr.].

As a test, I commented out the code in StandardToolSet’s #interrupt:label:, which stops the User Interrupt window from appearing but also causes Squeak to freeze after typing the interrupt key. Unfortunately, running HaltExperiment new infiniteLoop didn't restore the appearance of the User Interrupt window or stop Squeak from freezing even though MyToolSet has a complete copy of #interrupt:label:.

What am I doing wrong? How do I implement MyToolSet's #interrupt:label so that a dialog window appears with its own message to the user when infiniteLoop is interrupted?

Thanks,
Jim



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 9:54 AM
UTC Time: December 9, 2017 5:54 PM

Hi, there.

1) Subclass StandardToolSet.
2) There, implement #interrupt:label: as you want it.
3) Set your new tool set via "ToolSet register: MyToolSet" and "ToolSet default: MyToolSet".

Note that ToolSet is an AppRegistry and hence a wrapper whereas StandardToolSet is an actual tool set. :-) Other app registries include WebBrowser and SoundService.

The user interrupt is not implemented with exceptions but a watchdog process and a special semaphore. See EventSensor >> #userInterruptWatcher for more information.

Best,
Marcel

Am 09.12.2017 18:09:51 schrieb obrienj <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.





_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

marcel.taeumel
Hi Jim,

well, the Debugger takes care of re-spawning a new UI process in case the interrupted one was the UI process. :-) You should do that, too:

interrupt: process label: string
"ToolSet register: self; default: self"
Project current spawnNewProcessIfThisIsUI: process.
self inform: string.

Best,
Marcel


Am 14.12.2017 17:30:06 schrieb obrienj <[hidden email]>:

Hi Marcel,

I made MyToolSet, a subclass of StandardToolSet, and added a copy of #interrupt:label to it.

I next created HaltExperiment as an Object subclass and added this simple, infinite loop method:

infiniteLoop
| x |
ToolSet register:  MyToolSet.
ToolSet default:  MyToolSet.
Transcript clear. x := 0.
[x >= 0] whileTrue: [x := x + 1. Transcript show: 'x = ', x; cr.].

As a test, I commented out the code in StandardToolSet’s #interrupt:label:, which stops the User Interrupt window from appearing but also causes Squeak to freeze after typing the interrupt key. Unfortunately, running HaltExperiment new infiniteLoop didn't restore the appearance of the User Interrupt window or stop Squeak from freezing even though MyToolSet has a complete copy of #interrupt:label:.

What am I doing wrong? How do I implement MyToolSet's #interrupt:label so that a dialog window appears with its own message to the user when infiniteLoop is interrupted?

Thanks,
Jim



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 9:54 AM
UTC Time: December 9, 2017 5:54 PM

Hi, there.

1) Subclass StandardToolSet.
2) There, implement #interrupt:label: as you want it.
3) Set your new tool set via "ToolSet register: MyToolSet" and "ToolSet default: MyToolSet".

Note that ToolSet is an AppRegistry and hence a wrapper whereas StandardToolSet is an actual tool set. :-) Other app registries include WebBrowser and SoundService.

The user interrupt is not implemented with exceptions but a watchdog process and a special semaphore. See EventSensor >> #userInterruptWatcher for more information.

Best,
Marcel

Am 09.12.2017 18:09:51 schrieb obrienj <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.





_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

marcel.taeumel
...hmmm... this test seems to lock the Transcript's input semaphore. So, after CMD+Dot via MyToolSet, any calls to "Transcript show:" will freeze. Interesting.

Any ideas?

Best,
Marcel

Am 15.12.2017 09:22:52 schrieb Marcel Taeumel <[hidden email]>:

Hi Jim,

well, the Debugger takes care of re-spawning a new UI process in case the interrupted one was the UI process. :-) You should do that, too:

interrupt: process label: string
"ToolSet register: self; default: self"
Project current spawnNewProcessIfThisIsUI: process.
self inform: string.

Best,
Marcel


Am 14.12.2017 17:30:06 schrieb obrienj <[hidden email]>:

Hi Marcel,

I made MyToolSet, a subclass of StandardToolSet, and added a copy of #interrupt:label to it.

I next created HaltExperiment as an Object subclass and added this simple, infinite loop method:

infiniteLoop
| x |
ToolSet register:  MyToolSet.
ToolSet default:  MyToolSet.
Transcript clear. x := 0.
[x >= 0] whileTrue: [x := x + 1. Transcript show: 'x = ', x; cr.].

As a test, I commented out the code in StandardToolSet’s #interrupt:label:, which stops the User Interrupt window from appearing but also causes Squeak to freeze after typing the interrupt key. Unfortunately, running HaltExperiment new infiniteLoop didn't restore the appearance of the User Interrupt window or stop Squeak from freezing even though MyToolSet has a complete copy of #interrupt:label:.

What am I doing wrong? How do I implement MyToolSet's #interrupt:label so that a dialog window appears with its own message to the user when infiniteLoop is interrupted?

Thanks,
Jim



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 9:54 AM
UTC Time: December 9, 2017 5:54 PM

Hi, there.

1) Subclass StandardToolSet.
2) There, implement #interrupt:label: as you want it.
3) Set your new tool set via "ToolSet register: MyToolSet" and "ToolSet default: MyToolSet".

Note that ToolSet is an AppRegistry and hence a wrapper whereas StandardToolSet is an actual tool set. :-) Other app registries include WebBrowser and SoundService.

The user interrupt is not implemented with exceptions but a watchdog process and a special semaphore. See EventSensor >> #userInterruptWatcher for more information.

Best,
Marcel

Am 09.12.2017 18:09:51 schrieb obrienj <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.





_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Jim O'Brien
Tried it but nothing changed.

Looking at Debugger's methods, it appears that typing the interrupt key opens a notifier (the User Interrupt window), which gives the user the option to abandon the interrupted process. Is there a way to add a method to a program so that typing the interrupt key simply abandons the running process without the notifier opening?



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 15, 2017 12:45 AM
UTC Time: December 15, 2017 8:45 AM
To: obrienj <[hidden email]>
[hidden email], hosihanh via Squeak-dev <[hidden email]>

Okay, such process-switching code can be tricky. If you keep that suspended process around for a while the Transcript's semaphore will block other semaphore uses. So, try this:

interrupt: process label: string
"ToolSet register: self; default: self"

Project current
spawnNewProcessIfThisIsUI: process;
addDeferredUIMessage: [self inform: string].

process terminate.

If you want to execute more code, better write it into the block sent via #addDeferredUIMessage:. 

Best,
Marce.

Am 15.12.2017 09:29:10 schrieb Marcel Taeumel <[hidden email]>:

...hmmm... this test seems to lock the Transcript's input semaphore. So, after CMD+Dot via MyToolSet, any calls to "Transcript show:" will freeze. Interesting.

Any ideas?

Best,
Marcel

Am 15.12.2017 09:22:52 schrieb Marcel Taeumel <[hidden email]>:

Hi Jim,

well, the Debugger takes care of re-spawning a new UI process in case the interrupted one was the UI process. :-) You should do that, too:

interrupt: process label: string
"ToolSet register: self; default: self"
Project current spawnNewProcessIfThisIsUI: process.
self inform: string.

Best,
Marcel



Am 14.12.2017 17:30:06 schrieb obrienj <[hidden email]>:

Hi Marcel,

I made MyToolSet, a subclass of StandardToolSet, and added a copy of #interrupt:label to it.

I next created HaltExperiment as an Object subclass and added this simple, infinite loop method:

infiniteLoop
| x |
ToolSet register:  MyToolSet.
ToolSet default:  MyToolSet.
Transcript clear. x := 0.
[x >= 0] whileTrue: [x := x + 1. Transcript show: 'x = ', x; cr.].

As a test, I commented out the code in StandardToolSet’s #interrupt:label:, which stops the User Interrupt window from appearing but also causes Squeak to freeze after typing the interrupt key. Unfortunately, running HaltExperiment new infiniteLoop didn't restore the appearance of the User Interrupt window or stop Squeak from freezing even though MyToolSet has a complete copy of #interrupt:label:.

What am I doing wrong? How do I implement MyToolSet's #interrupt:label so that a dialog window appears with its own message to the user when infiniteLoop is interrupted?

Thanks,
Jim



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 9, 2017 9:54 AM
UTC Time: December 9, 2017 5:54 PM

Hi, there.

1) Subclass StandardToolSet.
2) There, implement #interrupt:label: as you want it.
3) Set your new tool set via "ToolSet register: MyToolSet" and "ToolSet default: MyToolSet".

Note that ToolSet is an AppRegistry and hence a wrapper whereas StandardToolSet is an actual tool set. :-) Other app registries include WebBrowser and SoundService.

The user interrupt is not implemented with exceptions but a watchdog process and a special semaphore. See EventSensor >> #userInterruptWatcher for more information.

Best,
Marcel

Am 09.12.2017 18:09:51 schrieb obrienj <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Is there a way to intercept the 'User Interrupt'  window that pops up when the user types the interrupt key and replace it with a customized dialog window? I've used on: do: to intercept Error messages but can't seem to do the same with EventSensor messages.






_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

David T. Lewis
On Thu, Dec 21, 2017 at 09:00:49PM -0500, obrienj wrote:
> Tried it but nothing changed.
>
> Looking at Debugger's methods, it appears that typing the interrupt key opens a notifier (the User Interrupt window), which gives the user the option to abandon the interrupted process. Is there a way to add a method to a program so that typing the interrupt key simply abandons the running process without the notifier opening?
>

Sure, there is probably a way to do that. But the most likely use case for
interrupting the system with the interrupt key is that something is going
wrong. You are trying to interrupt the process in which something bad is
happening, and you want to stop the bad thing from happening in such a way
that you can correct the problem, then proceed from that point.

For this kind of situation, the ideal solution is to open a debugger on
the failing process so that you can interact with it directly, correct the
problem, and then resume the interrupted process after you have addressed
the problem.

That is the reason for providing the notifier that allows you to enter
a debugger, or to do whatever else you may think may be necessary.

Dave

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User Interrupt window

Jim O'Brien
Dave,

Thank you for your reply. I understand the purpose and use of the debugger. I am working on a program that compiles user input that could result in an infinite loop if the user isn't careful. I'd like to avoid the debugger's notifier and simply halt the compiler and let the user edit the input and try again but haven't found a way to do that.

Jim



-------- Original Message --------
Subject: Re: [Newbies] User Interrupt window
Local Time: December 21, 2017 6:58 PM
UTC Time: December 22, 2017 2:58 AM
To: obrienj <[hidden email]>, A friendly place to get answers to even the most basic questions about Squeak. <[hidden email]>

On Thu, Dec 21, 2017 at 09:00:49PM -0500, obrienj wrote:
Tried it but nothing changed.
Looking at Debugger's methods, it appears that typing the interrupt key opens a notifier (the User Interrupt window), which gives the user the option to abandon the interrupted process. Is there a way to add a method to a program so that typing the interrupt key simply abandons the running process without the notifier opening?
 
Sure, there is probably a way to do that. But the most likely use case for
interrupting the system with the interrupt key is that something is going
wrong. You are trying to interrupt the process in which something bad is
happening, and you want to stop the bad thing from happening in such a way
that you can correct the problem, then proceed from that point.
 
For this kind of situation, the ideal solution is to open a debugger on
the failing process so that you can interact with it directly, correct the
problem, and then resume the interrupted process after you have addressed
the problem.
 
That is the reason for providing the notifier that allows you to enter
a debugger, or to do whatever else you may think may be necessary.
 
Dave
 


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners