Commit | Line | Data |
---|---|---|
7511317b DM |
1 | MalReadline := Object clone do ( |
2 | historyLoaded := false | |
3 | historyFile := (System getEnvironmentVariable("HOME")) .. "/.mal-history" | |
4 | ||
5 | loadHistory := method( | |
6 | if(File exists(historyFile), ReadLine loadHistory(historyFile)) | |
7 | historyLoaded = true | |
8 | ) | |
9 | ||
10 | readLine := method(prompt, | |
11 | if(historyLoaded not, loadHistory) | |
12 | line := ReadLine readLine(prompt) | |
13 | if(line isNil, return(nil)) | |
14 | if(line isEmpty, return(line)) | |
15 | ReadLine addHistory(line) | |
16 | ReadLine saveHistory(historyFile) | |
17 | line | |
18 | ) | |
19 | ) |