mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-10 23:52:22 +00:00
Add ctrl-c handler to the renderer. (#56)
Former-commit-id: a2a5146eda2277846d207dea91bd8ea39282ad26
This commit is contained in:
parent
8017a1b577
commit
2df8eda745
1 changed files with 6 additions and 1 deletions
|
|
@ -121,7 +121,7 @@ generateFrames :: Animation -> Width -> Height -> FPS -> (FilePath -> IO a) -> I
|
|||
generateFrames ani width_ height_ rate action = withTempDir $ \tmp -> do
|
||||
done <- newMVar (0::Int)
|
||||
let frameName nth = tmp </> printf nameTemplate nth
|
||||
concurrentForM_ frames $ \n -> do
|
||||
handle h $ concurrentForM_ frames $ \n -> do
|
||||
writeFile (frameName n) $ renderSvg width height $ nthFrame n
|
||||
-- runCmd "inkscape"
|
||||
-- [ "--without-gui"
|
||||
|
|
@ -138,6 +138,11 @@ generateFrames ani width_ height_ rate action = withTempDir $ \tmp -> do
|
|||
-- action (tmp </> pngTemplate)
|
||||
action (tmp </> nameTemplate)
|
||||
where
|
||||
h UserInterrupt = do
|
||||
hPutStrLn stderr "\nCtrl-C detected. Trying to generate video with available frames. \
|
||||
\Hit ctrl-c again to abort."
|
||||
return ()
|
||||
h other = throwIO other
|
||||
width = Just $ Num $ fromIntegral width_
|
||||
height = Just $ Num $ fromIntegral height_
|
||||
frames = [0..frameCount-1]
|
||||
|
|
|
|||
Loading…
Reference in a new issue