forked from kanaka/mal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadline.vb
32 lines (27 loc) · 859 Bytes
/
readline.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Imports System
Imports Mono.Terminal ' LineEditor (getline.cs)
Namespace Mal
Public Class readline
Enum Modes
Terminal
Raw
End Enum
Public Shared mode As Modes = Modes.Terminal
Shared lineedit As LineEditor = Nothing
Public Shared Sub SetMode(new_mode As Modes)
mode = new_mode
End Sub
Public Shared Function Readline(prompt As String) As String
If mode = Modes.Terminal Then
If lineedit Is Nothing Then
lineedit = New LineEditor("Mal")
End If
return lineedit.Edit(prompt, "")
Else
Console.Write(prompt)
Console.Out.Flush()
return Console.ReadLine()
End If
End Function
End Class
End Namespace