version 0.3
[CleanReadLine.git] / ReadLine.dcl
1 definition module ReadLine
2
3 import StdClass
4
5 :: Maybe a = Nothing | Just a
6 :: HistoryItem = {line :: String, timestamp :: String}
7 :: HistoryState = {entries :: [HistoryItem], offset :: Int, flags :: Int}
8
9 instance toString HistoryItem
10 instance toString HistoryState
11
12 //Maybe functions
13 isNothing :: !(Maybe .x) -> Bool
14 isJust :: !(Maybe .x) -> Bool
15 fromJust :: !(Maybe .x) -> .x
16
17 //Non-library functions
18 setReadLineName :: !String !*env -> *env
19
20 //Readline
21 readLine :: !String !Bool !*env -> (!Maybe String, !*env)
22
23 //Initializing History and State Management
24 //Note that this HAS to be executed when you want to add entries when the
25 //history has not been used
26 usingHistory :: !*env -> *env
27 historyGetHistoryState :: !*env -> (!HistoryState, !*env)
28 historySetHistoryState :: !HistoryState !*env -> *env
29
30 //History List Management
31 addHistory :: !String !*env -> *env
32 addHistoryTime :: !String !*env -> *env
33 removeHistory :: !Int !*env -> (!HistoryItem, !*env)
34 replaceHistoryEntry :: !Int !String !*env -> (!HistoryItem, !*env)
35 clearHistory :: !*env -> *env
36 stifleHistory :: !Int !*env -> *env
37 unstifleHistory :: !*env -> *env
38 historyIsStifled :: !*env -> (!Int, !*env)
39
40 //Information About the History List
41 historyList :: !*env -> (![HistoryItem], !*env)
42 whereHistory :: !*env -> (!Int, !*env)
43 currentHistory :: !*env -> (!Maybe HistoryItem, !*env)
44 historyGet :: !Int !*env -> (!Maybe HistoryItem, !*env)
45 historyGetTime :: HistoryItem -> String
46 historyTotalBytes :: !*env -> (!Int, !*env)
47
48 //Moving Around the History List
49 //TODO
50
51 //Searching the History List
52 //Note that the return integers are just success flags. The actual found item
53 //will be the current history position and the int is the offset of the search
54 //within that item...
55 historySearch :: !String !Int !*env-> (!Int, !*env)
56 historySearchPrefix :: !String !Int !*env-> (!Int, !*env)
57 historySearchPos :: !String !Int !Int !*env-> (!Int, !*env)
58
59 //Managing the History File
60 readHistory :: !String !*env -> (!Bool, !*env)
61 readHistoryRange :: !String !Int !Int !*env -> (!Bool, !*env)
62 writeHistory :: !String !*env -> (!Bool, !*env)
63 appendHistory :: !Int !String !*env -> (!Bool, !*env)
64 historyTruncateFile :: !String !Int !*env -> (!Bool, !*env)