1178N/ADescription : utilitary functions used throughout the CMDL interface
1178N/ACopyright : uni-bremen and DFKI
1178N/AMaintainer : r.pascanu@jacobs-university.de
1178N/Aused throughout the CMDL interface and could not be found in
0N/Aadd2hist :: [UndoRedoElem] -> CmdlState -> CmdlState
0N/A = let intst = add2history (CommentCmd "") (intState st) descr
1178N/A-- | Given a list of selected theory generate an Id comorphism to the
0N/A-- first selected theory
1178N/AgetIdComorphism :: [Int_NodeInfo] -> Maybe AnyComorphism
4033N/AgetIdComorphism ls = case ls of
1178N/A case sublogicOfTheory st of
4033N/A G_sublogics lid sub -> Just $ Comorphism (mkIdComorphism lid sub)
4033N/A-- | Generates the string containing the prompter
0N/AgeneratePrompter :: CmdlState -> String
4033N/AgeneratePrompter st = (case i_state $ intState st of
4033N/A [] -> delExtension (fileLoaded pst)
1178N/A Element sm _ : r -> theoryName sm ++ if null r then "" else ".."
4033N/A cm = if null (elements ist)
4033N/A else if cComorphism ist /= getIdComorphism (elements ist)
4033N/A in els ++ cm) ++ prompterHead (prompter st)
1178N/A-- | Given a list of node names and the list of all nodes
0N/A-- the function returns all the nodes that have their name
4033N/A-- in the name list but are also goals
1178N/AobtainGoalNodeList :: CmdlState -> [String] -> [LNode DGNodeLab]
1178N/A -> ([String],[LNode DGNodeLab])
1178N/AobtainGoalNodeList state input ls
0N/A = let (l1,l2) = obtainNodeList input ls
1178N/A let nwth = getTh Dont_translate nb state
1178N/A Just th -> nodeContainsGoals (nb,nd) th) l2
4033N/A-- | Returns the list of all nodes that are goals,
1178N/A-- taking care of the up to date status
1178N/AgetAllGoalNodes :: CmdlState -> [LNode DGNodeLab]
1178N/A = case i_state $ intState st of
4033N/A let nwth = getTh Dont_translate nb st
4033N/A Just th -> nodeContainsGoals (nb,nd) th) $
0N/A-- | Returns the list of all goal edges taking care of the
0N/AgetAllGoalEdges :: CmdlState -> [LEdge DGLinkLab]
0N/A = case i_state $ intState st of
4033N/A filter edgeContainsGoals $ getAllEdges ist
1178N/A-- Returns the selected DGNodes along with a possible error message
0N/AgetSelectedDGNodes :: IntIState -> (String, [LNode DGNodeLab])
4033N/AgetSelectedDGNodes dgState =
1178N/A let nds = map (\ (Element _ n) -> n) $ elements dgState
4033N/A dg = lookupDGraph (i_ln dgState) (i_libEnv dgState)
4033N/A nds' = zip nds $ map (labDG dg) nds
1178N/A in (if null nds' then "No node(s) selected!" else "", nds')
4033N/A-- Returns the selected DGNodes
0N/A-- or if the selection is empty the DGNodes specified by the input string
4033N/AgetInputDGNodes :: String -> IntIState -> (String, [LNode DGNodeLab])
4033N/AgetInputDGNodes input dgState =
1178N/A then getSelectedDGNodes dgState
0N/A else let (nds,_,_,errs) = decomposeIntoGoals input
4033N/A tmpErrs = prettyPrintErrList errs
0N/A _ -> let lsNodes = getAllNodes dgState
1178N/A (errs',listNodes) = obtainNodeList nds lsNodes
1178N/A tmpErrs' = tmpErrs ++ prettyPrintErrList errs'
0N/A-- Returns the selected Nodes
1178N/A-- or if the selection is empty the Nodes specified by the input string
1178N/AgetInputNodes :: String -> IntIState -> (String, [Node])
0N/AgetInputNodes input dgState =
4033N/A let (errors, nodes) = getInputDGNodes input dgState
0N/A in (errors, map (\ x -> case x of (n, _) -> n) nodes)
0N/A--local function that computes the theory of a node
0N/A--that takes into consideration translated theories in
0N/A--the selection too and returns the theory as a string
0N/AgetTh :: CmdlUseTranslation -> Int -> CmdlState -> Maybe G_theory
-- compute the theory for a given node
fn n = case i_state $ intState st of
Just ist -> computeTheory (i_libEnv ist) (i_ln ist) n
case i_state $ intState st of
case find (\y -> case y of
case mapG_theory cm sth of
Result _ Nothing -> Just sth
Result _ (Just sth') -> Just sth'
-- | Generates the base channels to be used (stdin and stdout)
baseChannels :: [CmdlChannel]
= let ch_in = CmdlChannel {
genErrorMsg :: String -> CmdlState -> CmdlState
genMessage :: String -> String -> CmdlState -> CmdlState
genMessage warnings msg st