1 implementation module ReadLine
5 import code from "readLine.o"
8 readLine :: !String !Bool !*env -> (!String, !*env)
9 readLine s h e = code {
10 ccall cleanReadLine "SI:S:A"
13 setReadLineName :: !String !*env -> !*env
14 setReadLineName s e = code {
15 ccall cleanSetReadLineName "S:V:A"
18 //Initializing History and State Management
19 usingHistory :: !*env -> !*env
20 usingHistory e = code {
21 ccall cleanUsingHistory ":V:A"
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)
30 getState :: !*env -> (!Int, !Int, !Int, !*env)
32 ccall cleanGetState ":VIII:A"
34 getItems :: !Int !*env -> (![HistoryItem], !*env)
35 getItems 0 e = ([], e)
37 # (line, timestamp, e) = getItem (i-1) e
38 # (rest, e) = getItems (i-1) e
39 = ([{line=line,timestamp=timestamp}:rest], e)
41 getItem :: !Int !*env -> (!String, !String, !*env)
43 ccall cleanGetHistoryItem "I:VSS:A"
47 historySetHistoryState :: !HistoryState !*env -> !*env
48 historySetHistoryState {entries,offset,flags} e
49 # e = initNewHistoryState offset flags (length entries) e
50 # e = setItems entries 0 e
53 initNewHistoryState :: !Int !Int !Int !*env -> !*env
54 initNewHistoryState o f l e = code {
55 ccall cleanInitNewHistoryState "III:V:A"
57 setItems :: ![HistoryItem] !Int !*env -> !*env
60 # e = setItem i x.line x.timestamp e
63 setItem :: !Int !String !String !*env -> !*env
64 setItem i l t e = code {
65 ccall cleanSetNewHistoryEntry "ISS:V:A"
68 commit :: !*env -> !*env
70 ccall cleanCommitSetHistory ":V:A"
73 //History List Management
74 addHistory :: !String !*env -> !*env
75 addHistory s e = code {
76 ccall cleanAddHistory "S:V:A"
79 clearHistory :: !*env -> !*env
80 clearHistory e = code {
81 ccall cleanClearHistory ":V:A"
84 //Information About the History List
86 //Moving Around the History List
88 //Searching the History List
89 historySearch :: !String !Int !*env-> (!Int, !*env)
90 historySearch s i e = code {
91 ccall cleanHistorySearch "SI:I:A"
94 historySearchPrefix :: !String !Int !*env-> (!Int, !*env)
95 historySearchPrefix s i e = code {
96 ccall cleanHistorySearchPrefix "SI:I:A"
99 historySearchPos :: !String !Int !Int !*env-> (!Int, !*env)
100 historySearchPos s i1 i2 e = code {
101 ccall cleanHistorySearchPos "SI:I:A"
105 //Managing the History File
106 readHistory :: !String !*env -> (!Bool, !*env)
107 readHistory s e = code {
108 ccall cleanReadHistory "S:I:A"
111 readHistoryRange :: !String !Int !Int !*env -> (!Bool, !*env)
112 readHistoryRange s i1 i2 e = code {
113 ccall cleanReadHistoryRange "SII:I:A"
116 writeHistory :: !String !*env -> (!Bool, !*env)
117 writeHistory s e = code {
118 ccall cleanWriteHistory "S:I:A"
121 appendHistory :: !Int !String !*env -> (!Bool, !*env)
122 appendHistory i s e = code {
123 ccall cleanWriteHistory "IS:I:A"
126 historyTruncateFile :: !String !Int !*env -> (!Bool, !*env)
127 historyTruncateFile i s e = code {
128 ccall cleanWriteHistory "SI:I:A"