Added last history function descriptions
[CleanReadLine.git] / ReadLine.icl
index 790db28..71d64df 100644 (file)
@@ -4,6 +4,18 @@ import StdEnv
 
 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
@@ -167,6 +179,30 @@ historyTotalBytes e = code {
        }
 
 //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)
@@ -210,3 +246,8 @@ historyTruncateFile :: !String !Int !*env -> (!Bool, !*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)