history state added
[CleanReadLine.git] / ReadLine.icl
index b8c3053..cb4cfbb 100644 (file)
@@ -4,8 +4,103 @@ import StdEnv
 
 import code from "readLine.o"
 
+//Readline
 readLine :: !String !Bool !*env -> (!String, !*env)
 readLine s h e = code {
                        ccall cleanReadLine "SI:S:A"
        }
 
+setReadLineName :: !String !*env -> !*env
+setReadLineName s e = code inline {
+                       ccall cleanSetReadLineName "S-"
+       }
+
+//Initializing History and State Management
+usingHistory :: !*env -> !*env
+usingHistory e = code inline {
+                       ccall cleanUsingHistory "-"
+       }
+
+historyGetHistoryState :: !*env -> (!HistoryState, !*env)
+historyGetHistoryState e
+# (offset, num, flags, e) = getState e
+# (entries, e) = getItems num e
+= ({HistoryState | entries=entries, offset=offset, flags=flags}, e)
+       where
+               getState :: !*env -> (!Int, !Int, !Int, !*env)
+               getState e= code inline {
+                       ccall cleanGetState "-III"
+               }
+               getItems :: !Int !*env -> (![HistoryItem], !*env)
+               getItems 0 e = ([], e)
+               getItems i e
+               # (line, timestamp, e) = getItem (i-1) e
+               # (rest, e) = getItems (i-1) e
+               = ([{line=line,timestamp=timestamp}:rest], e)
+
+               getItem :: !Int !*env -> (!String, !String, !*env)
+               getItem i e = code inline {
+                       ccall cleanGetHistoryItem "I-SS"
+               }
+               
+
+historySetHistoryState :: !HistoryState !*env -> !*env
+historySetHistoryState hs e = abort "Not Implemented"
+
+//History List Management
+addHistory :: !String !*env -> !*env
+addHistory s e = code inline {
+                       ccall cleanAddHistory "S-"
+       }
+
+clearHistory :: !*env -> !*env
+clearHistory e = code inline{
+                       ccall cleanClearHistory "-"
+       }
+
+//Information About the History List
+
+//Moving Around the History List
+
+//Searching the History List
+historySearch :: !String !Int !*env-> (!Int, !*env)
+historySearch s i e = code {
+                       ccall cleanHistorySearch "SI:I:A"
+       }
+
+historySearchPrefix :: !String !Int !*env-> (!Int, !*env)
+historySearchPrefix s i e = code {
+                       ccall cleanHistorySearchPrefix "SI:I:A"
+       }
+       
+historySearchPos :: !String !Int !Int !*env-> (!Int, !*env)
+historySearchPos s i1 i2 e = code {
+                       ccall cleanHistorySearchPos "SI:I:A"
+       }
+       
+
+//Managing the History File
+readHistory :: !String !*env -> (!Bool, !*env)
+readHistory s e = code {
+                       ccall cleanReadHistory "S:I:A"
+       }
+
+readHistoryRange :: !String !Int !Int !*env -> (!Bool, !*env)
+readHistoryRange s i1 i2 e = code {
+                       ccall cleanReadHistoryRange "SII:I:A"
+       }
+
+writeHistory :: !String !*env -> (!Bool, !*env)
+writeHistory s e = code {
+                       ccall cleanWriteHistory "S:I:A"
+       }
+
+appendHistory :: !Int !String !*env -> (!Bool, !*env)
+appendHistory i s e = code {
+                       ccall cleanWriteHistory "IS:I:A"
+       }
+               
+historyTruncateFile :: !String !Int !*env -> (!Bool, !*env)
+historyTruncateFile i s e = code {
+                       ccall cleanWriteHistory "SI:I:A"
+       }