Added Maybe-related functions; restricted imports from .dcl
[CleanReadLine.git] / ReadLine.dcl
index 540886a..7828e88 100644 (file)
@@ -1,17 +1,60 @@
 definition module ReadLine
 
+import StdClass
+
+:: Maybe a = Nothing | Just a
+:: HistoryItem = {line :: String, timestamp :: String}
+:: HistoryState = {entries :: [HistoryItem], offset :: Int, flags :: Int}
+
+instance toString HistoryItem
+instance toString HistoryState
+
+//Maybe functions
+isNothing :: !(Maybe .x) -> Bool
+isJust    :: !(Maybe .x) -> Bool
+fromJust  :: !(Maybe .x) -> .x
+
+//Non-library functions
+setReadLineName :: !String !*env -> *env
+
 //Readline
-readLine :: !String !Bool !*env -> (!String, !*env)
+readLine :: !String !Bool !*env -> (!Maybe String, !*env)
 
 //Initializing History and State Management
+//Note that this HAS to be executed when you want to add entries when the
+//history has not been used
+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
+//TODO
 
 //Searching the History List
+//Note that the return integers are just success flags. The actual found item
+//will be the current history position and the int is the offset of the search
+//within that item...
+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)