expanding implemented
[CleanReadLine.git] / ReadLine.icl
index 71d64df..fa23473 100644 (file)
@@ -248,6 +248,49 @@ historyTruncateFile i s e = code {
        }
 
 historyExpand :: !String !*env -> (!String, !Int, !*env)
-getHistoryEvent :: !String !Int !Int !*env -> (!String, !*env)
+historyExpand s e = code {
+               ccall cleanHistoryExpand "S:VSI:A"      
+       }
+
+getHistoryEvent :: !String !Int !Int !*env -> (!Maybe String, !Int, !*env)
+getHistoryEvent s i1 i2 e
+# (string, cindex, null, e) = getHistoryEventItem s i1 i2 e
+= (if null Nothing (Just string), cindex, e)
+       where
+               getHistoryEventItem :: !String !Int !Int !*env -> (!String, !Int, !Bool, !*env)
+               getHistoryEventItem s i1 i2 e = code {
+                               ccall cleanGetHistoryEvent "SII:VSII:A"
+                       }
+
 historyTokenize :: !String !*env -> ([String], !*env)
-historyArgExtract :: !Int !Int !String !*env -> (!String, !*env)
+historyTokenize s e
+# (i, e) = historyTokenizeInit s e
+= historyTokenizeItems i e
+//= ([], e)
+       where
+               historyTokenizeInit :: !String !*env -> (!Int, !*env)
+               historyTokenizeInit s e = code {
+                               ccall cleanHistoryTokenizeInit "S:I:A"
+                       }
+
+               historyTokenizeItems :: !Int !*env -> (![String], !*env)
+               historyTokenizeItems 0 e = ([], e)
+               historyTokenizeItems i e
+               # (token, e) = historyTokenizeItem (i-1) e
+               # (rest, e) = historyTokenizeItems (i-1) e
+               = ([token:rest], e)
+
+               historyTokenizeItem :: !Int !*env -> (!String, !*env)
+               historyTokenizeItem i e = code {
+                               ccall cleanHistoryTokenizeItem "I:S:A"
+                       }
+
+historyArgExtract :: !Int !Int !String !*env -> (!Maybe String, !*env)
+historyArgExtract i1 i2 s e
+# (string, null, e) = historyArgExtractItem i1 i2 s e
+= (if null Nothing (Just string), e)
+       where
+               historyArgExtractItem :: !Int !Int !String !*env -> (!String, !Bool, !*env)
+               historyArgExtractItem i1 i2 s e = code {
+                               ccall cleanHistoryArgExtract "IIS:VSI:A"
+                       }