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

tools: make the mini greeting text in the REPL more informative

This commit is contained in:
Delyan Angelov 2022-03-20 23:22:46 +02:00
parent 7216b5df11
commit aaf87e04a2
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -208,11 +208,21 @@ fn (mut r Repl) parse_import(line string) {
} }
} }
fn highlight_console_command(command string) string {
return term.bright_white(term.bright_bg_black(' $command '))
}
fn highlight_repl_command(command string) string {
return term.bright_white(term.bg_blue(' $command '))
}
fn print_welcome_screen() { fn print_welcome_screen() {
cmd_exit := term.highlight_command('exit') cmd_exit := highlight_repl_command('exit')
cmd_help := term.highlight_command('v help') cmd_list := highlight_repl_command('list')
file_main := term.highlight_command('main.v') cmd_help := highlight_repl_command('help')
cmd_run := term.highlight_command('v run main.v') cmd_v_help := highlight_console_command('v help')
cmd_v_run := highlight_console_command('v run main.v')
file_main := highlight_console_command('main.v')
vbar := term.bright_green('|') vbar := term.bright_green('|')
width, _ := term.get_terminal_size() // get the size of the terminal width, _ := term.get_terminal_size() // get the size of the terminal
vlogo := [ vlogo := [
@ -224,11 +234,11 @@ fn print_welcome_screen() {
term.bright_blue(r' \__/ '), term.bright_blue(r' \__/ '),
] ]
help_text := [ help_text := [
'Welcome to the V REPL (for help with V itself, type $cmd_exit, then run $cmd_help).', 'Welcome to the V REPL (for help with V itself, type $cmd_exit, then run $cmd_v_help).',
'Note: the REPL is highly experimental. For best V experience, use a text editor, ', 'Note: 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', 'save your code in a $file_main file and execute: $cmd_v_run',
version.full_v_version(false), '${version.full_v_version(false)} . Use $cmd_list to see the accumulated program so far.',
'Use Ctrl-C or ${term.highlight_command('exit')} to exit, or ${term.highlight_command('help')} to see other available commands', 'Use Ctrl-C or $cmd_exit to exit, or $cmd_help to see other available commands.',
] ]
if width >= 97 { if width >= 97 {
eprintln('${vlogo[0]}') eprintln('${vlogo[0]}')