Swap when TIPS and SHORT_INSTRUCTIONS print

This commit is contained in:
Richard Feldman 2022-10-25 08:05:01 -04:00
parent de6e7840cb
commit 8a29d50f4e
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B

View file

@ -47,22 +47,14 @@ pub const WELCOME_MESSAGE: &str = concatcp!(
// For when nothing is entered in the repl
// TODO add link to repl tutorial(does not yet exist).
pub const SHORT_INSTRUCTIONS: &str = "Enter an expression, or :help, or :q to quit.\n\n";
pub const SHORT_INSTRUCTIONS: &str = "Enter an expression, or :help, or :q to quit.\n";
// TODO add link to repl tutorial(does not yet exist).
pub const TIPS: &str = concatcp!(
BLUE,
" - ",
END_COL,
"Entered code needs to return something. For example:\n\n",
PINK,
" » foo = 1\n … foo\n\n",
END_COL,
BLUE,
" - ",
END_COL,
"You can use `Ctrl+V`+`Ctrl+J` to make a newline. The repl will also insert a newline if you press enter",
" when the current expression can not be evaluated, e.g. when you type `foo =<ENTER>`.\n\n",
"You can use `Ctrl+V`+`Ctrl+J` to make a newline.\n\n",
BLUE,
" - ",
END_COL,
@ -418,7 +410,7 @@ pub fn main() -> io::Result<()> {
// To debug rustyline:
// <UNCOMMENT> env_logger::init();
// <RUN WITH:> RUST_LOG=rustyline=debug cargo run repl 2> debug.log
print!("{}{}", WELCOME_MESSAGE, TIPS);
print!("{}{}", WELCOME_MESSAGE, SHORT_INSTRUCTIONS);
let mut prev_line_blank = false;
let mut editor = Editor::<ReplHelper>::new();
@ -441,7 +433,7 @@ pub fn main() -> io::Result<()> {
match trim_line.to_lowercase().as_str() {
"" => {
if pending_src.is_empty() {
print!("\n{}", SHORT_INSTRUCTIONS);
print!("\n{}", TIPS);
} else if prev_line_blank {
// After two blank lines in a row, give up and try parsing it
// even though it's going to fail. This way you don't get stuck.
@ -464,7 +456,7 @@ pub fn main() -> io::Result<()> {
}
":help" => {
// TODO add link to repl tutorial(does not yet exist).
println!("Use :q to exit.");
println!("{}", TIPS);
}
":exit" | ":quit" | ":q" => {
break;