nothing is inline anymore
[CleanReadLine.git] / ReadLine.icl
1 implementation module ReadLine
2
3 import StdEnv
4
5 import code from "readLine.o"
6
7 //Readline
8 readLine :: !String !Bool !*env -> (!String, !*env)
9 readLine s h e = code {
10 ccall cleanReadLine "SI:S:A"
11 }
12
13 setReadLineName :: !String !*env -> !*env
14 setReadLineName s e = code {
15 ccall cleanSetReadLineName "S:V:A"
16 }
17
18 //Initializing History and State Management
19 usingHistory :: !*env -> !*env
20 usingHistory e = code {
21 ccall cleanUsingHistory ":V:A"
22 }
23
24 historyGetHistoryState :: !*env -> (!HistoryState, !*env)
25 historyGetHistoryState e
26 # (offset, num, flags, e) = getState e
27 # (entries, e) = getItems num e
28 = ({HistoryState | entries=entries, offset=offset, flags=flags}, e)
29 where
30 getState :: !*env -> (!Int, !Int, !Int, !*env)
31 getState e= code {
32 ccall cleanGetState ":VIII:A"
33 }
34 getItems :: !Int !*env -> (![HistoryItem], !*env)
35 getItems 0 e = ([], e)
36 getItems i e
37 # (line, timestamp, e) = getItem (i-1) e
38 # (rest, e) = getItems (i-1) e
39 = ([{line=line,timestamp=timestamp}:rest], e)
40
41 getItem :: !Int !*env -> (!String, !String, !*env)
42 getItem i e = code {
43 ccall cleanGetHistoryItem "I:VSS:A"
44 }
45
46
47 historySetHistoryState :: !HistoryState !*env -> !*env
48 historySetHistoryState hs e = abort "Not Implemented"
49
50 //History List Management
51 addHistory :: !String !*env -> !*env
52 addHistory s e = code {
53 ccall cleanAddHistory "S:V:A"
54 }
55
56 clearHistory :: !*env -> !*env
57 clearHistory e = code {
58 ccall cleanClearHistory ":V:A"
59 }
60
61 //Information About the History List
62
63 //Moving Around the History List
64
65 //Searching the History List
66 historySearch :: !String !Int !*env-> (!Int, !*env)
67 historySearch s i e = code {
68 ccall cleanHistorySearch "SI:I:A"
69 }
70
71 historySearchPrefix :: !String !Int !*env-> (!Int, !*env)
72 historySearchPrefix s i e = code {
73 ccall cleanHistorySearchPrefix "SI:I:A"
74 }
75
76 historySearchPos :: !String !Int !Int !*env-> (!Int, !*env)
77 historySearchPos s i1 i2 e = code {
78 ccall cleanHistorySearchPos "SI:I:A"
79 }
80
81
82 //Managing the History File
83 readHistory :: !String !*env -> (!Bool, !*env)
84 readHistory s e = code {
85 ccall cleanReadHistory "S:I:A"
86 }
87
88 readHistoryRange :: !String !Int !Int !*env -> (!Bool, !*env)
89 readHistoryRange s i1 i2 e = code {
90 ccall cleanReadHistoryRange "SII:I:A"
91 }
92
93 writeHistory :: !String !*env -> (!Bool, !*env)
94 writeHistory s e = code {
95 ccall cleanWriteHistory "S:I:A"
96 }
97
98 appendHistory :: !Int !String !*env -> (!Bool, !*env)
99 appendHistory i s e = code {
100 ccall cleanWriteHistory "IS:I:A"
101 }
102
103 historyTruncateFile :: !String !Int !*env -> (!Bool, !*env)
104 historyTruncateFile i s e = code {
105 ccall cleanWriteHistory "SI:I:A"
106 }