-- | Displays a Save-As dialog and writes the proof-script.
askSaveProofScript :: GA.GraphInfo -> IORef IntState -> IO ()
askSaveProofScript gi ch = do
  h <- readIORef ch
  case undoList $ i_hist h of
   [] -> infoDialog "Information" "The history is empty. No file written."
   _ -> do
     ff <- getProofScriptFileName $ rmSuffix $ filename h
     maybeFilePath <- fileSaveDialog ff [ ("Proof Script", ["*.hpf"])
                                        , ("All Files", ["*"])] Nothing
     case maybeFilePath of
       Just fPath -> do
         GA.showTemporaryMessage gi "Saving proof script ..."
         saveCommandHistory ch fPath
         GA.showTemporaryMessage gi $ "Proof script saved to " ++ fPath ++ "!"
       Nothing -> GA.showTemporaryMessage gi "Aborted!"

-- Saves the history of commands in a file.
askSaveProofScript :: GA.GraphInfo -> IORef IntState -> IO ()
askSaveProofScript gi ch = do
  h <- readIORef ch
  case undoList $ i_hist h of
   [] -> infoDialog "Information" "The history is empty. No file written."
   _ -> do
     ff <- getProofScriptFileName $ rmSuffix $ filename h
     maybeFilePath <- fileSaveDialog ff [ ("Proof Script", ["*.hpf"])
                                        , ("All Files", ["*"])] Nothing
     case maybeFilePath of
       Just fPath -> do
         GA.showTemporaryMessage gi "Saving proof script ..."
         saveCommandHistory ch fPath
         GA.showTemporaryMessage gi $ "Proof script saved to " ++ fPath ++ "!"
       Nothing -> GA.showTemporaryMessage gi "Aborted!"

-- Saves the history of commands in a file.
askSaveProofScript gi ch = do
  h <- readIORef ch
  case undoList $ i_hist h of
   [] -> infoDialog "Information" "The history is empty. No file written."
   _ -> do
     ff <- getProofScriptFileName $ rmSuffix $ filename h
     maybeFilePath <- fileSaveDialog ff [ ("Proof Script", ["*.hpf"])
                                        , ("All Files", ["*"])] Nothing
     case maybeFilePath of
       Just fPath -> do
         GA.showTemporaryMessage gi "Saving proof script ..."
         saveCommandHistory ch fPath
         GA.showTemporaryMessage gi $ "Proof script saved to " ++ fPath ++ "!"
       Nothing -> GA.showTemporaryMessage gi "Aborted!"

-- Saves the history of commands in a file.