Created
December 4, 2019 08:10
-
-
Save ba0f3/8c3823c694b9b4925c69ac295bb5d1d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import prompt, unicode, terminal | |
proc autoComplete(line: seq[Rune], cursorpos: int): seq[string] {.gcsafe.} = | |
if line.len == 0: | |
return @[] | |
if $line == "hi": | |
result = @["Hello", "Xin chao", "Bonjour"] | |
else: | |
result = @["Chuc mung"] | |
for i in 0..<result.len: | |
var s = result[i] | |
result[i] = s[cursorpos..<s.len] | |
var p = Prompt.init(autoComplete = autoComplete) | |
p.setIndicator("Nim> ") | |
p.setStatusbar(@[("aa", "bb"), ("Date", "2019-12-04")]) | |
p.showPrompt() | |
while true: | |
var text = p.readLine() | |
if text == "q": | |
p.hidePrompt() | |
break | |
p.writeLine(text) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment