Commit | Line | Data |
---|---|---|
ee7cd585 JM |
1 | Imports System |
2 | Imports Mono.Terminal ' LineEditor (getline.cs) | |
3 | ||
4 | Namespace Mal | |
5 | Public Class readline | |
6 | Enum Modes | |
7 | Terminal | |
8 | Raw | |
9 | End Enum | |
10 | ||
11 | Public Shared mode As Modes = Modes.Terminal | |
12 | ||
13 | Shared lineedit As LineEditor = Nothing | |
14 | ||
15 | Public Shared Sub SetMode(new_mode As Modes) | |
16 | mode = new_mode | |
17 | End Sub | |
18 | ||
19 | Public Shared Function Readline(prompt As String) As String | |
20 | If mode = Modes.Terminal Then | |
21 | If lineedit Is Nothing Then | |
22 | lineedit = New LineEditor("Mal") | |
23 | End If | |
24 | return lineedit.Edit(prompt, "") | |
25 | Else | |
26 | Console.Write(prompt) | |
27 | Console.Out.Flush() | |
28 | return Console.ReadLine() | |
29 | End If | |
30 | End Function | |
31 | End Class | |
32 | End Namespace |