repl: fix `list` command deleting '/'; adapt the logo to the terminal size (#13462)
parent
8119a297f7
commit
efdbe9d92c
|
@ -214,6 +214,7 @@ fn print_welcome_screen() {
|
|||
file_main := term.highlight_command('main.v')
|
||||
cmd_run := term.highlight_command('v run main.v')
|
||||
vbar := term.bright_green('|')
|
||||
width, _ := term.get_terminal_size() // get the size of the terminal
|
||||
vlogo := [
|
||||
term.bright_blue(r' ____ ____ '),
|
||||
term.bright_blue(r' \ \ / / '),
|
||||
|
@ -222,13 +223,30 @@ fn print_welcome_screen() {
|
|||
term.bright_blue(r' \ / '),
|
||||
term.bright_blue(r' \__/ '),
|
||||
]
|
||||
eprintln('${vlogo[0]}')
|
||||
eprintln('${vlogo[1]} $vbar Welcome to the V REPL (for help with V itself, type $cmd_exit, then run $cmd_help).')
|
||||
eprintln('${vlogo[2]} $vbar NB: the REPL is highly experimental. For best V experience, use a text editor,')
|
||||
eprintln('${vlogo[3]} $vbar save your code in a $file_main file and execute: $cmd_run')
|
||||
eprintln('${vlogo[4]} $vbar ${version.full_v_version(false)}')
|
||||
eprintln('${vlogo[5]} $vbar Use Ctrl-C or ${term.highlight_command('exit')} to exit, or ${term.highlight_command('help')} to see other available commands')
|
||||
eprintln('')
|
||||
help_text := [
|
||||
'Welcome to the V REPL (for help with V itself, type $cmd_exit, then run $cmd_help).',
|
||||
'NB: the REPL is highly experimental. For best V experience, use a text editor, ',
|
||||
'save your code in a $file_main file and execute: $cmd_run',
|
||||
version.full_v_version(false),
|
||||
'Use Ctrl-C or ${term.highlight_command('exit')} to exit, or ${term.highlight_command('help')} to see other available commands',
|
||||
]
|
||||
if width >= 97 {
|
||||
eprintln('${vlogo[0]}')
|
||||
eprintln('${vlogo[1]} $vbar ${help_text[0]}')
|
||||
eprintln('${vlogo[2]} $vbar ${help_text[1]}')
|
||||
eprintln('${vlogo[3]} $vbar ${help_text[2]}')
|
||||
eprintln('${vlogo[4]} $vbar ${help_text[3]}')
|
||||
eprintln('${vlogo[5]} $vbar ${help_text[4]}')
|
||||
eprintln('')
|
||||
} else {
|
||||
if width >= 14 {
|
||||
left_margin := ' '.repeat(int(width / 2 - 7))
|
||||
for l in vlogo {
|
||||
println(left_margin + l)
|
||||
}
|
||||
}
|
||||
println(help_text.join('\n'))
|
||||
}
|
||||
}
|
||||
|
||||
fn run_repl(workdir string, vrepl_prefix string) {
|
||||
|
@ -313,9 +331,7 @@ fn run_repl(workdir string, vrepl_prefix string) {
|
|||
}
|
||||
if r.line == 'list' {
|
||||
source_code := r.current_source_code(true, true)
|
||||
println('//////////////////////////////////////////////////////////////////////////////////////')
|
||||
println(source_code)
|
||||
println('//////////////////////////////////////////////////////////////////////////////////////')
|
||||
println('\n${source_code.replace('\n\n', '\n')}')
|
||||
continue
|
||||
}
|
||||
// Save the source only if the user is printing something,
|
||||
|
|
Loading…
Reference in New Issue