aforeman / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Key for "break operation" #374

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If you start to draw something that is taking too long time (e.g. a long thick 
line with a complicated effect) it would be nice to be able to stop the 
operation with a key.

In DPII, the space bar works like this, if I remember correctly.

Original issue reported on code.google.com by per.eric...@gmail.com on 13 Aug 2010 at 10:01

GoogleCodeExporter commented 8 years ago

Original comment by pulkoma...@gmail.com on 22 Aug 2010 at 1:40

GoogleCodeExporter commented 8 years ago
Technically, I can see one method to make it work:
Implement a SDL event filter that recognizes SDLK_ESC keypress events. It 
should increment a volatile counter called 'Esc_in_queue'. Get_input() would 
decrement this counter when the event is consumed. Then, the operation steps 
that draw the brush several times (lines, splines, circles etc.) only need to 
check Esc_in_queue(>0) in their loop.

Original comment by yrizoud on 27 Aug 2010 at 8:20

GoogleCodeExporter commented 8 years ago
That's the easy part :)

The problem is undoing an unfinished operation. The operation would ave to free 
all the temporary allocated memory clean up, ensure everything is in correct 
state,  and trigger an undo to ensure they didn't mess up with the data.

An alternative is to use setlongjmp() to allow an easy recovery. But I'm not 
sure that's portable...

Original comment by pulkoma...@gmail.com on 28 Aug 2010 at 2:28