Merge pull request #3 from dopefishh/standard-maybe
[CleanReadLine.git] / ReadLine.dcl
index da953d7..222f949 100644 (file)
@@ -1,8 +1,62 @@
 definition module ReadLine
 
-/*
-       Reads a line from stdin with the readline library
-       The value in the String argument will be used as a prompt
-       To enable history the Boolean variable has to be set to True
-*/
-readLine :: !String !Bool !*env -> (!String, !*env)
+import StdClass
+from Data.Maybe import :: Maybe
+
+:: HistoryItem = {line :: String, timestamp :: String}
+:: HistoryState = {entries :: [HistoryItem], offset :: Int, flags :: Int}
+
+instance toString HistoryItem
+instance toString HistoryState
+
+//Non-library functions
+setReadLineName :: !String !*env -> *env
+
+//Readline
+readLine :: !String !Bool !*env -> (!Maybe String, !*env)
+
+//Initializing History and State Management
+usingHistory :: !*env -> *env 
+historyGetHistoryState :: !*env -> (!HistoryState, !*env)
+historySetHistoryState :: !HistoryState !*env -> *env
+
+//History List Management
+addHistory :: !String !*env -> *env
+addHistoryTime :: !String !*env -> *env
+removeHistory :: !Int !*env -> (!HistoryItem, !*env)
+replaceHistoryEntry :: !Int !String !*env -> (!HistoryItem, !*env)
+clearHistory :: !*env -> *env
+stifleHistory :: !Int !*env -> *env
+unstifleHistory :: !*env -> *env
+historyIsStifled :: !*env -> (!Int, !*env)
+
+//Information About the History List
+historyList :: !*env -> (![HistoryItem], !*env)
+whereHistory :: !*env -> (!Int, !*env)
+currentHistory :: !*env -> (!Maybe HistoryItem, !*env)
+historyGet :: !Int !*env -> (!Maybe HistoryItem, !*env)
+historyGetTime :: HistoryItem -> String
+historyTotalBytes :: !*env -> (!Int, !*env)
+
+//Moving Around the History List
+historySetPos :: !Int !*env -> (!Int, !*env)
+previousHistory :: !*env -> (!Maybe HistoryItem, !*env)
+nextHistory :: !*env -> (!Maybe HistoryItem, !*env)
+
+//Searching the History List
+historySearch :: !String !Int !*env-> (!Int, !*env)
+historySearchPrefix :: !String !Int !*env-> (!Int, !*env)
+historySearchPos :: !String !Int !Int !*env-> (!Int, !*env)
+
+//Managing the History File
+readHistory :: !String !*env -> (!Bool, !*env)
+readHistoryRange :: !String !Int !Int !*env -> (!Bool, !*env)
+writeHistory :: !String !*env -> (!Bool, !*env)
+appendHistory :: !Int !String !*env -> (!Bool, !*env)
+historyTruncateFile :: !String !Int !*env -> (!Bool, !*env)
+
+//History Expansion
+historyExpand :: !String !*env -> (!String, !Int, !*env)
+getHistoryEvent :: !String !Int !Int !*env -> (!Maybe String, !Int, !*env)
+historyTokenize :: !String !*env -> ([String], !*env)
+historyArgExtract :: !Int !Int !String !*env -> (!Maybe String, !*env)