History.hs revision 55c5e901b5c3466300009135585bc70bd576dcb6
dafcb997e390efa4423883dafd100c975c4095d6Mark AndrewsModule :$Header$
499b34cea04a46823d003d4c0520c8b03e8513cbBrian WellingtonDescription : history management functions
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David LawrenceCopyright : uni-bremen and DFKI
ec5347e2c775f027573ce5648b910361aa926c01Automatic UpdaterLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
d0be1e954bd4674fc27f2616c72adb37cf3525a2David LawrenceMaintainer : r.pascanu@jacobs-university.de
d0be1e954bd4674fc27f2616c72adb37cf3525a2David LawrenceStability : provisional
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David LawrencePortability : portable
dafcb997e390efa4423883dafd100c975c4095d6Mark AndrewsInterfaces.History contains different functions that deal
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence ( undoOneStep
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence , redoOneStep
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater , undoOneStepWithUpdate
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence , redoOneStepWithUpdate
51f90e94e4dcea187628175b50217bc525570b55James Brister , add2history
51f90e94e4dcea187628175b50217bc525570b55James Bristerimport qualified Data.Map as Map
51f90e94e4dcea187628175b50217bc525570b55James Brister-- | Datatype used to differentiate between the two actions (so that code does
51f90e94e4dcea187628175b50217bc525570b55James Brister-- not get duplicated
51f90e94e4dcea187628175b50217bc525570b55James Bristerdata UndoOrRedo =
51f90e94e4dcea187628175b50217bc525570b55James Bristeradd2history :: Command -> IntState -> [UndoRedoElem] -> IntState
51f90e94e4dcea187628175b50217bc525570b55James Bristeradd2history nm st descr = let
51f90e94e4dcea187628175b50217bc525570b55James Brister hst = i_hist st
51f90e94e4dcea187628175b50217bc525570b55James Brister ul = undoList hst
51f90e94e4dcea187628175b50217bc525570b55James Brister nwEl = CmdHistory
51f90e94e4dcea187628175b50217bc525570b55James Brister { command = nm
51f90e94e4dcea187628175b50217bc525570b55James Brister , cmdHistory = descr }
51f90e94e4dcea187628175b50217bc525570b55James Brister in st { i_hist = hst { undoList = nwEl : ul } }
51f90e94e4dcea187628175b50217bc525570b55James Brister-- | Undo or redo a command that modified the development graph
51f90e94e4dcea187628175b50217bc525570b55James BristerundoRedoDgCmd :: UndoOrRedo -> IntState -> LibName
51f90e94e4dcea187628175b50217bc525570b55James Brister -> ([DGChange] -> DGraph -> IO ()) -> IO IntState
51f90e94e4dcea187628175b50217bc525570b55James BristerundoRedoDgCmd actionType state ln update =
51f90e94e4dcea187628175b50217bc525570b55James Brister case i_state state of
51f90e94e4dcea187628175b50217bc525570b55James Brister -- should I return an error message??
51f90e94e4dcea187628175b50217bc525570b55James Brister Nothing -> return state
51f90e94e4dcea187628175b50217bc525570b55James Brister Just dgS -> do
51f90e94e4dcea187628175b50217bc525570b55James Brister -- take ln from the history storage ??
newEnv = Map.insert ln dg' (i_libEnv dgS)
-- (undo/redo)