fixed issue 1, changed function type of readline
[CleanReadLine.git] / ReadLine.dcl
1 definition module ReadLine
2
3 import StdEnv
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 //Non-library functions
13 setReadLineName :: !String !*env -> !*env
14
15 //Readline
16 readLine :: !String !Bool !*env -> (!Maybe String, !*env)
17
18 //Initializing History and State Management
19 //Note that this HAS to be executed when you want to add entries when the
20 //history has not been used
21 usingHistory :: !*env -> !*env
22 historyGetHistoryState :: !*env -> (!HistoryState, !*env)
23 historySetHistoryState :: !HistoryState !*env -> !*env
24
25 //History List Management
26 addHistory :: !String !*env -> !*env
27 addHistoryTime :: !String !*env -> !*env
28 removeHistory :: !Int !*env -> (!HistoryItem, !*env)
29 replaceHistoryEntry :: !Int !String !*env -> (!HistoryItem, !*env)
30 clearHistory :: !*env -> !*env
31 stifleHistory :: !Int !*env -> !*env
32 unstifleHistory :: !*env -> !*env
33 historyIsStifled :: !*env -> (!Int, !*env)
34
35 //Information About the History List
36 historyList :: !*env -> (![HistoryItem], !*env)
37 whereHistory :: !*env -> (!Int, !*env)
38 currentHistory :: !*env -> (!Maybe HistoryItem, !*env)
39 historyGet :: !Int !*env -> (!Maybe HistoryItem, !*env)
40 historyGetTime :: HistoryItem -> String
41 historyTotalBytes :: !*env -> (!Int, !*env)
42
43 //Moving Around the History List
44 //TODO
45
46 //Searching the History List
47 //Note that the return integers are just success flags. The actual found item
48 //will be the current history position and the int is the offset of the search
49 //within that item...
50 historySearch :: !String !Int !*env-> (!Int, !*env)
51 historySearchPrefix :: !String !Int !*env-> (!Int, !*env)
52 historySearchPos :: !String !Int !Int !*env-> (!Int, !*env)
53
54 //Managing the History File
55 readHistory :: !String !*env -> (!Bool, !*env)
56 readHistoryRange :: !String !Int !Int !*env -> (!Bool, !*env)
57 writeHistory :: !String !*env -> (!Bool, !*env)
58 appendHistory :: !Int !String !*env -> (!Bool, !*env)
59 historyTruncateFile :: !String !Int !*env -> (!Bool, !*env)