import code from "readLine.o"
+//Maybe
+isNothing :: !(Maybe .x) -> Bool
+isNothing Nothing = True
+isNothing _ = False
+
+isJust :: !(Maybe .x) -> Bool
+isJust Nothing = False
+isJust _ = True
+
+fromJust :: !(Maybe .x) -> .x
+fromJust (Just x) = x
+
instance toString HistoryItem where
toString {line,timestamp} = line +++ " (" +++ timestamp +++ ")"
instance toString HistoryState where
ccall cleanReadLine "SI:VSI:A"
}
-setReadLineName :: !String !*env -> !*env
+setReadLineName :: !String !*env -> *env
setReadLineName s e = code {
ccall cleanSetReadLineName "S:V:A"
}
//Initializing History and State Management
-usingHistory :: !*env -> !*env
+usingHistory :: !*env -> *env
usingHistory e = code {
ccall cleanUsingHistory ":V:A"
}
}
-historySetHistoryState :: !HistoryState !*env -> !*env
+historySetHistoryState :: !HistoryState !*env -> *env
historySetHistoryState {entries,offset,flags} e
# e = initNewHistoryState offset flags (length entries) e
# e = setItems entries 0 e
= commit e
where
- initNewHistoryState :: !Int !Int !Int !*env -> !*env
+ initNewHistoryState :: !Int !Int !Int !*env -> *env
initNewHistoryState o f l e = code {
ccall cleanInitNewHistoryState "III:V:A"
}
- setItems :: ![HistoryItem] !Int !*env -> !*env
+ setItems :: ![HistoryItem] !Int !*env -> *env
setItems [] _ e = e
setItems [x:xs] i e
# e = setItem i x.line x.timestamp e
= setItems xs (i+1) e
- setItem :: !Int !String !String !*env -> !*env
+ setItem :: !Int !String !String !*env -> *env
setItem i l t e = code {
ccall cleanSetNewHistoryEntry "ISS:V:A"
}
- commit :: !*env -> !*env
+ commit :: !*env -> *env
commit e = code {
ccall cleanCommitSetHistory ":V:A"
}
//History List Management
-addHistory :: !String !*env -> !*env
+addHistory :: !String !*env -> *env
addHistory s e = code {
ccall cleanAddHistory "S:V:A"
}
-addHistoryTime :: !String !*env -> !*env
+addHistoryTime :: !String !*env -> *env
addHistoryTime s e = code {
ccall cleanAddHistoryTime "S:V:A"
}
ccall cleanReplaceHistoryEntry "IS:VSS:A"
}
-clearHistory :: !*env -> !*env
+clearHistory :: !*env -> *env
clearHistory e = code {
ccall cleanClearHistory ":V:A"
}
-stifleHistory :: !Int !*env -> !*env
+stifleHistory :: !Int !*env -> *env
stifleHistory i e = code {
ccall cleanStifleHistory "I:V:A"
}
-unstifleHistory :: !*env -> !*env
+unstifleHistory :: !*env -> *env
unstifleHistory e = code {
ccall cleanUnstifleHistory ":V:A"
}
}
//Moving Around the History List
+historySetPos :: !Int !*env -> (!Int, !*env)
+historySetPos i e = code {
+ ccall cleanHistorySetPos "I:I:A"
+ }
+
+previousHistory :: !*env -> (!Maybe HistoryItem, !*env)
+previousHistory e
+# (line, timestamp, null, e) = previousHistoryItem e
+= (if null Nothing (Just {HistoryItem | line=line, timestamp=timestamp}), e)
+ where
+ previousHistoryItem :: !*env -> (!String, !String, !Bool, !*env)
+ previousHistoryItem e = code {
+ ccall cleanPreviousHistory ":VSSI:A"
+ }
+
+nextHistory :: !*env -> (!Maybe HistoryItem, !*env)
+nextHistory e
+# (line, timestamp, null, e) = nextHistoryItem e
+= (if null Nothing (Just {HistoryItem | line=line, timestamp=timestamp}), e)
+ where
+ nextHistoryItem :: !*env -> (!String, !String, !Bool, !*env)
+ nextHistoryItem e = code {
+ ccall cleanNextHistory ":VSSI:A"
+ }
//Searching the History List
historySearch :: !String !Int !*env-> (!Int, !*env)
historyTruncateFile i s e = code {
ccall cleanWriteHistory "SI:I:A"
}
+
+historyExpand :: !String !*env -> (!String, !Int, !*env)
+getHistoryEvent :: !String !Int !Int !*env -> (!String, !*env)
+historyTokenize :: !String !*env -> ([String], !*env)
+historyArgExtract :: !Int !Int !String !*env -> (!String, !*env)