Safe Haskell | Safe-Inferred |
---|
Functions to save and restore state to and from files.
The naming convention is that load
and save
functions either load
the given file, replace the state with it, and set the SaveFile, or save
the current state and set the SaveFile. read
and write
functions
are lower level and either read the file and return the state, or write the
given state, without messing with the SaveFile.
Synopsis
- soft_quit :: Cmd.CmdT IO Cmd.Status
- hard_quit :: Cmd.CmdT IO Cmd.Status
- save :: Cmd.CmdT IO ()
- load :: FilePath -> Cmd.CmdT IO ()
- load_force :: FilePath -> Cmd.CmdT IO ()
- read :: FilePath -> Cmd.CmdT IO (Ui.State, StateSaveFile)
- read_ :: FilePath -> IO (Either Text Ui.State)
- load_template :: FilePath -> Cmd.CmdT IO ()
- infer_save_type :: FilePath -> IO (Either Text Cmd.SaveFile)
- save_state :: Cmd.CmdT IO ()
- save_state_as :: FilePath -> Cmd.CmdT IO ()
- load_state :: FilePath -> Cmd.CmdT IO ()
- read_state :: FilePath -> Cmd.CmdT IO (Ui.State, StateSaveFile)
- read_state_ :: FilePath -> IO (Either Serialize.UnserializeError Ui.State)
- write_state :: FilePath -> Ui.State -> IO ()
- write_current_state :: FilePath -> Cmd.CmdT IO FilePath
- get_state_path :: Cmd.M m => m (Maybe FilePath)
- state_path_for_repo :: Repo -> FilePath
- infer_state_path :: Id.Namespace -> Cmd.State -> FilePath
- save_git :: Cmd.CmdT IO ()
- save_git_as :: Repo -> Cmd.CmdT IO ()
- load_git :: FilePath -> Maybe Commit -> Cmd.CmdT IO ()
- revert :: Maybe String -> Cmd.CmdT IO ()
- get_git_path :: Cmd.M m => m Repo
- save_allocations :: FilePath -> Cmd.CmdT IO ()
- load_allocations :: FilePath -> Cmd.CmdT IO UiConfig.Allocations
- save_views :: Cmd.State -> Ui.State -> IO ()
quit
soft_quit :: Cmd.CmdT IO Cmd.Status Source #
Warn and abort if there is unsaved data, otherwise quit.
universal
save :: Cmd.CmdT IO () Source #
Save to the current Cmd.state_save_file
, or create a new git repo if
there is none.
load :: FilePath -> Cmd.CmdT IO () Source #
Like read
, but replace the current state and set Cmd.state_save_file
.
read :: FilePath -> Cmd.CmdT IO (Ui.State, StateSaveFile) Source #
Try to guess whether the given path is a git save or state save. If it's a directory, look inside for a .git or .state save.
load_template :: FilePath -> Cmd.CmdT IO () Source #
Like load
, but don't set SaveFile, so you can't overwrite the loaded
file when you save.
infer_save_type :: FilePath -> IO (Either Text Cmd.SaveFile) Source #
Given a path, which is either a file or a directory, try to figure out
what to load. Saves can be either a plain saved state, or a directory
containing either a git repo save.git
, or a state save.state
. If
both are present, the git repo is preferred.
state
save_state :: Cmd.CmdT IO () Source #
save_state_as :: FilePath -> Cmd.CmdT IO () Source #
Save the state to the given file and set Cmd.state_save_file
.
The directory of the filename will become the project directory, so things like the saved REPL history and the ly subdirectory will go there.
read_state_ :: FilePath -> IO (Either Serialize.UnserializeError Ui.State) Source #
Low level read_state
.
path
state_path_for_repo :: Repo -> FilePath Source #
Get a state save path based on a repo path. This is for saving a backup state, or when switching from SaveRepo to SaveState.
infer_state_path :: Id.Namespace -> Cmd.State -> FilePath Source #
Figure out a path for a save state based on the namespace.
git
save_git :: Cmd.CmdT IO () Source #
Save a SavePoint to the git repo in Cmd.state_save_file
, or start a new
one. Set the Cmd.state_save_file
to the repo, so I'll keep saving to
that repo.
:: Repo | Save to this repo, or create it.
|
-> Cmd.CmdT IO () |
get_git_path :: Cmd.M m => m Repo Source #
config
misc
save_views :: Cmd.State -> Ui.State -> IO () Source #
Git repos don't checkpoint views, but because I'm accustomed to them checkpointing everything else I expect the views to always be saved.
So call this when quitting or switching away from a save file to save the views.
They could theoretically checkpoint view changes, but it would be complicated (they mostly come from the GUI, not diff) and inefficient (scrolling emits tons of them).