mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
repl: clear screen and help menu
This commit is contained in:
parent
be99a65f2b
commit
232532ba3b
@ -5,6 +5,7 @@
|
||||
module main
|
||||
|
||||
import os
|
||||
import term
|
||||
|
||||
struct Repl {
|
||||
mut:
|
||||
@ -49,6 +50,15 @@ fn (r mut Repl) function_call(line string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
fn repl_help() {
|
||||
println('
|
||||
V $Version
|
||||
help Displays this information.
|
||||
Ctrl-C, Ctrl-D, exit Exits the REPL.
|
||||
clear Clears the screen.
|
||||
')
|
||||
}
|
||||
|
||||
fn run_repl() []string {
|
||||
println('V $Version')
|
||||
println('Use Ctrl-C or `exit` to exit')
|
||||
@ -80,6 +90,14 @@ fn run_repl() []string {
|
||||
if line == '\n' {
|
||||
continue
|
||||
}
|
||||
if line == 'clear' {
|
||||
term.erase_display('2')
|
||||
continue
|
||||
}
|
||||
if line == 'help' {
|
||||
repl_help()
|
||||
continue
|
||||
}
|
||||
if line.starts_with('fn') {
|
||||
r.in_func = true
|
||||
r.functions_name << line.all_after('fn').all_before('(').trim_space()
|
||||
|
Loading…
Reference in New Issue
Block a user