1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

Revert "repl: add readline for user input "

This reverts commit 83732642ac.
This commit is contained in:
Alexander Medvednikov 2019-10-17 03:37:30 +03:00
parent 83732642ac
commit 5faa7e7861

View File

@ -4,11 +4,8 @@
module compiler module compiler
import ( import os
os import term
term
readline
)
struct Repl { struct Repl {
mut: mut:
@ -77,7 +74,6 @@ pub fn run_repl() []string {
println('Use Ctrl-C or `exit` to exit') println('Use Ctrl-C or `exit` to exit')
file := '.vrepl.v' file := '.vrepl.v'
temp_file := '.vrepl_temp.v' temp_file := '.vrepl_temp.v'
mut prompt := '>>> '
defer { defer {
os.rm(file) os.rm(file)
os.rm(temp_file) os.rm(temp_file)
@ -85,26 +81,22 @@ pub fn run_repl() []string {
os.rm(temp_file.left(temp_file.len - 2)) os.rm(temp_file.left(temp_file.len - 2))
} }
mut r := Repl{} mut r := Repl{}
mut readline := readline.Readline{}
vexe := os.args[0] vexe := os.args[0]
for { for {
if r.indent == 0 { if r.indent == 0 {
prompt = '>>> ' print('>>> ')
} }
else { else {
prompt = '... ' print('... ')
} }
mut line := readline.read_line(prompt) or { r.line = os.get_raw_line()
break if r.line.trim_space() == '' && r.line.ends_with('\n') {
}
if line.trim_space() == '' && line.ends_with('\n') {
continue continue
} }
line = line.trim_space() r.line = r.line.trim_space()
if line.len <= -1 || line == '' || line == 'exit' { if r.line.len == -1 || r.line == '' || r.line == 'exit' {
break break
} }
r.line = line
if r.line == '\n' { if r.line == '\n' {
continue continue
} }