Cargo fmt and update

This commit is contained in:
NGnius (Graham) 2022-03-16 16:27:08 -04:00
parent 2e75abd893
commit 494537a2cf
9 changed files with 184 additions and 81 deletions

32
Cargo.lock generated
View file

@ -453,9 +453,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-channel" name = "crossbeam-channel"
version = "0.5.2" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" checksum = "fdbfe11fe19ff083c48923cf179540e8cd0535903dc35e178a1fdeeb59aef51f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
@ -474,10 +474,11 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.9.7" version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
dependencies = [ dependencies = [
"autocfg",
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"lazy_static 1.4.0", "lazy_static 1.4.0",
@ -487,9 +488,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-queue" name = "crossbeam-queue"
version = "0.3.4" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dd435b205a4842da59efd07628f921c096bc1cc0a156835b4fa0bcb9a19bcce" checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
@ -497,9 +498,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.7" version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"lazy_static 1.4.0", "lazy_static 1.4.0",
@ -929,9 +930,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.119" version = "0.2.120"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09"
[[package]] [[package]]
name = "libdbus-sys" name = "libdbus-sys"
@ -987,7 +988,7 @@ version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50fe05791a7f418b59d6cddebdc293d77c9c1f652adbff855c071d4507cd883b" checksum = "50fe05791a7f418b59d6cddebdc293d77c9c1f652adbff855c071d4507cd883b"
dependencies = [ dependencies = [
"nom 7.1.0", "nom 7.1.1",
] ]
[[package]] [[package]]
@ -1272,13 +1273,12 @@ dependencies = [
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.0" version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [ dependencies = [
"memchr 2.4.1", "memchr 2.4.1",
"minimal-lexical", "minimal-lexical",
"version_check",
] ]
[[package]] [[package]]
@ -2246,9 +2246,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.86" version = "1.0.88"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" checksum = "ebd69e719f31e88618baa1eaa6ee2de5c9a1c004f1e9ecdb58e8352a13f20a01"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -1,7 +1,7 @@
use std::fmt::{Debug, Display, Error, Formatter};
use std::convert::From; use std::convert::From;
use std::fmt::{Debug, Display, Error, Formatter};
use crate::lang::{SyntaxError, RuntimeError, MpsLanguageError}; use crate::lang::{MpsLanguageError, RuntimeError, SyntaxError};
use crate::tokens::ParseError; use crate::tokens::ParseError;
#[derive(Debug)] #[derive(Debug)]

View file

@ -6,8 +6,8 @@ use std::path::Path;
use super::lang::{MpsLanguageDictionary, MpsLanguageError, MpsOp}; use super::lang::{MpsLanguageDictionary, MpsLanguageError, MpsOp};
use super::tokens::MpsToken; use super::tokens::MpsToken;
use super::MpsContext; use super::MpsContext;
use super::MpsItem;
use super::MpsError; use super::MpsError;
use super::MpsItem;
/// The script interpreter. /// The script interpreter.
/// Use MpsRunner for a better interface. /// Use MpsRunner for a better interface.
@ -91,8 +91,7 @@ where
if next_item.is_none() { if next_item.is_none() {
is_stmt_done = true; is_stmt_done = true;
} }
next_item next_item.map(|item| item.map_err(|e| error_with_ctx(e, self.tokenizer.current_line())))
.map(|item| item.map_err(|e| error_with_ctx(e, self.tokenizer.current_line())))
} else { } else {
/*if self.tokenizer.end_of_file() { /*if self.tokenizer.end_of_file() {
return None; return None;

View file

@ -347,12 +347,12 @@ fn find_last_open_curly(tokens: &VecDeque<MpsToken>) -> Option<usize> {
if bracket_depth == 0 && curly_found { if bracket_depth == 0 && curly_found {
return Some(i + 1); return Some(i + 1);
} }
}, }
MpsToken::OpenBracket | MpsToken::CloseBracket => { MpsToken::OpenBracket | MpsToken::CloseBracket => {
if bracket_depth == 0 { if bracket_depth == 0 {
return None; return None;
} }
}, }
_ => {} _ => {}
} }
if token.is_open_curly() { if token.is_open_curly() {

View file

@ -16,8 +16,8 @@ mod type_primitives;
pub(crate) mod utility; pub(crate) mod utility;
pub use dictionary::MpsLanguageDictionary; pub use dictionary::MpsLanguageDictionary;
pub use error::{RuntimeError, RuntimeMsg, RuntimeOp, SyntaxError};
pub(crate) use error::MpsLanguageError; pub(crate) use error::MpsLanguageError;
pub use error::{RuntimeError, RuntimeMsg, RuntimeOp, SyntaxError};
pub use filter::{ pub use filter::{
MpsFilterFactory, MpsFilterPredicate, MpsFilterStatement, MpsFilterStatementFactory, MpsFilterFactory, MpsFilterPredicate, MpsFilterStatement, MpsFilterStatementFactory,
}; };

View file

@ -3,7 +3,7 @@ use std::iter::Iterator;
use super::lang::MpsLanguageDictionary; use super::lang::MpsLanguageDictionary;
use super::tokens::{MpsTokenReader, MpsTokenizer}; use super::tokens::{MpsTokenReader, MpsTokenizer};
use super::{MpsContext, MpsInterpretor, MpsItem, MpsError}; use super::{MpsContext, MpsError, MpsInterpretor, MpsItem};
pub struct MpsRunnerSettings<T: MpsTokenReader> { pub struct MpsRunnerSettings<T: MpsTokenReader> {
pub vocabulary: MpsLanguageDictionary, pub vocabulary: MpsLanguageDictionary,

View file

@ -1,5 +1,5 @@
use mps_interpreter::MpsError;
use mps_interpreter::tokens::{MpsToken, MpsTokenizer, ParseError}; use mps_interpreter::tokens::{MpsToken, MpsTokenizer, ParseError};
use mps_interpreter::MpsError;
use mps_interpreter::*; use mps_interpreter::*;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::io::Cursor; use std::io::Cursor;

View file

@ -179,7 +179,10 @@ impl SystemControlWrapper {
fn enqueued(item: MpsItem, dbus_ctrl: &Sender<DbusControl>) { fn enqueued(item: MpsItem, dbus_ctrl: &Sender<DbusControl>) {
//println!("Got enqueued item {}", &item.title); //println!("Got enqueued item {}", &item.title);
let file_uri = item.field("filename").and_then(|x| x.to_owned().to_str()).map(|x| format!("file://{}", x)); let file_uri = item
.field("filename")
.and_then(|x| x.to_owned().to_str())
.map(|x| format!("file://{}", x));
dbus_ctrl dbus_ctrl
.send(DbusControl::SetMetadata(Metadata { .send(DbusControl::SetMetadata(Metadata {
length: None, length: None,

View file

@ -2,7 +2,7 @@
use std::io::{self, Write}; use std::io::{self, Write};
use console::{Term, Key}; use console::{Key, Term};
use mps_interpreter::MpsRunner; use mps_interpreter::MpsRunner;
use mps_player::{MpsController, MpsPlayer}; use mps_player::{MpsController, MpsPlayer};
@ -58,7 +58,12 @@ pub fn repl(args: CliArgs) {
}; };
let mut state = ReplState::new(writer, term); let mut state = ReplState::new(writer, term);
if let Some(playlist_file) = &args.playlist { if let Some(playlist_file) = &args.playlist {
writeln!(state.terminal, "Playlist mode (output: `{}`)", playlist_file).expect("Failed to write to terminal output"); writeln!(
state.terminal,
"Playlist mode (output: `{}`)",
playlist_file
)
.expect("Failed to write to terminal output");
let mut player = player_builder(); let mut player = player_builder();
let mut playlist_writer = let mut playlist_writer =
io::BufWriter::new(std::fs::File::create(playlist_file).unwrap_or_else(|_| { io::BufWriter::new(std::fs::File::create(playlist_file).unwrap_or_else(|_| {
@ -80,7 +85,8 @@ pub fn repl(args: CliArgs) {
.expect("Failed to flush playlist to file"); .expect("Failed to flush playlist to file");
}); });
} else { } else {
writeln!(state.terminal, "Playback mode (output: audio device)").expect("Failed to write to terminal output"); writeln!(state.terminal, "Playback mode (output: audio device)")
.expect("Failed to write to terminal output");
let ctrl = MpsController::create_repl(player_builder); let ctrl = MpsController::create_repl(player_builder);
read_loop(&args, &mut state, || { read_loop(&args, &mut state, || {
if args.wait { if args.wait {
@ -107,20 +113,38 @@ pub fn repl(args: CliArgs) {
fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F) -> ! { fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F) -> ! {
prompt(state, args); prompt(state, args);
loop { loop {
match state.terminal.read_key().expect("Failed to read terminal input") { match state
.terminal
.read_key()
.expect("Failed to read terminal input")
{
Key::Char(read_c) => { Key::Char(read_c) => {
if state.cursor_rightward_position == 0 { if state.cursor_rightward_position == 0 {
write!(state.terminal, "{}", read_c).expect("Failed to write to terminal output"); write!(state.terminal, "{}", read_c)
.expect("Failed to write to terminal output");
state.statement_buf.push(read_c); state.statement_buf.push(read_c);
state.current_line.push(read_c); state.current_line.push(read_c);
} else { } else {
write!(state.terminal, "{}", read_c).expect("Failed to write to terminal output"); write!(state.terminal, "{}", read_c)
for i in state.current_line.len() - state.cursor_rightward_position .. state.current_line.len() { .expect("Failed to write to terminal output");
write!(state.terminal, "{}", state.current_line[i]).expect("Failed to write to terminal output"); for i in state.current_line.len() - state.cursor_rightward_position
..state.current_line.len()
{
write!(state.terminal, "{}", state.current_line[i])
.expect("Failed to write to terminal output");
} }
state.terminal.move_cursor_left(state.cursor_rightward_position).expect("Failed to write to terminal output"); state
state.statement_buf.insert(state.statement_buf.len() - state.cursor_rightward_position, read_c); .terminal
state.current_line.insert(state.current_line.len() - state.cursor_rightward_position, read_c); .move_cursor_left(state.cursor_rightward_position)
.expect("Failed to write to terminal output");
state.statement_buf.insert(
state.statement_buf.len() - state.cursor_rightward_position,
read_c,
);
state.current_line.insert(
state.current_line.len() - state.cursor_rightward_position,
read_c,
);
} }
match read_c { match read_c {
'"' | '`' => { '"' | '`' => {
@ -133,9 +157,17 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
} }
} }
'(' => state.bracket_depth += 1, '(' => state.bracket_depth += 1,
')' => if state.bracket_depth != 0 { state.bracket_depth -= 1 }, ')' => {
if state.bracket_depth != 0 {
state.bracket_depth -= 1
}
}
'{' => state.curly_depth += 1, '{' => state.curly_depth += 1,
'}' => if state.curly_depth != 0 { state.curly_depth -= 1 }, '}' => {
if state.curly_depth != 0 {
state.curly_depth -= 1
}
}
';' => { ';' => {
if state.in_literal.is_none() { if state.in_literal.is_none() {
state state
@ -153,7 +185,10 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
//println!("Got {}", statement_result.unwrap()); //println!("Got {}", statement_result.unwrap());
repl_commands(statement_result); repl_commands(statement_result);
state.statement_buf.clear(); state.statement_buf.clear();
} else if state.bracket_depth == 0 && state.in_literal.is_none() && state.curly_depth == 0 { } else if state.bracket_depth == 0
&& state.in_literal.is_none()
&& state.curly_depth == 0
{
state.statement_buf.push(';'); state.statement_buf.push(';');
state state
.writer .writer
@ -166,7 +201,7 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
} }
_ => {} _ => {}
} }
}, }
Key::Backspace => { Key::Backspace => {
if state.cursor_rightward_position == 0 { if state.cursor_rightward_position == 0 {
if let Some(c) = state.statement_buf.pop() { if let Some(c) = state.statement_buf.pop() {
@ -180,32 +215,54 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
} else { } else {
state.in_literal = Some(c); state.in_literal = Some(c);
} }
}, }
'(' => if state.bracket_depth != 0 { state.bracket_depth -= 1 }, '(' => {
if state.bracket_depth != 0 {
state.bracket_depth -= 1
}
}
')' => state.bracket_depth += 1, ')' => state.bracket_depth += 1,
'{' => if state.curly_depth != 0 { state.curly_depth -= 1 }, '{' => {
if state.curly_depth != 0 {
state.curly_depth -= 1
}
}
'}' => state.curly_depth += 1, '}' => state.curly_depth += 1,
_ => {}, _ => {}
} }
match c { match c {
'\n' | '\r' => { '\n' | '\r' => {
// another line, cannot backspace that far // another line, cannot backspace that far
state.statement_buf.push(c); state.statement_buf.push(c);
}, }
_ => { _ => {
state.current_line.pop(); state.current_line.pop();
state.terminal.move_cursor_left(1).expect("Failed to write to terminal output"); state
write!(state.terminal, " ").expect("Failed to write to terminal output"); .terminal
state.terminal.flush().expect("Failed to flush terminal output"); .move_cursor_left(1)
state.terminal.move_cursor_left(1).expect("Failed to write to terminal output"); .expect("Failed to write to terminal output");
write!(state.terminal, " ")
.expect("Failed to write to terminal output");
state
.terminal
.flush()
.expect("Failed to flush terminal output");
state
.terminal
.move_cursor_left(1)
.expect("Failed to write to terminal output");
} }
} }
} }
} else { } else {
if state.current_line.len() != state.cursor_rightward_position { if state.current_line.len() != state.cursor_rightward_position {
// if not at start of line // if not at start of line
let removed_char = state.current_line.remove(state.current_line.len()-state.cursor_rightward_position-1); let removed_char = state
state.statement_buf.remove(state.statement_buf.len()-state.cursor_rightward_position-1); .current_line
.remove(state.current_line.len() - state.cursor_rightward_position - 1);
state.statement_buf.remove(
state.statement_buf.len() - state.cursor_rightward_position - 1,
);
// re-sync unclosed syntax tracking // re-sync unclosed syntax tracking
match removed_char { match removed_char {
'"' | '`' => { '"' | '`' => {
@ -216,33 +273,55 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
} else { } else {
state.in_literal = Some(removed_char); state.in_literal = Some(removed_char);
} }
}, }
'(' => if state.bracket_depth != 0 { state.bracket_depth -= 1 }, '(' => {
if state.bracket_depth != 0 {
state.bracket_depth -= 1
}
}
')' => state.bracket_depth += 1, ')' => state.bracket_depth += 1,
'{' => if state.curly_depth != 0 { state.curly_depth -= 1 }, '{' => {
if state.curly_depth != 0 {
state.curly_depth -= 1
}
}
'}' => state.curly_depth += 1, '}' => state.curly_depth += 1,
_ => {}, _ => {}
} }
// re-print end of line to remove character in middle // re-print end of line to remove character in middle
state.terminal.move_cursor_left(1).expect("Failed to write to terminal output"); state
for i in state.current_line.len() - state.cursor_rightward_position .. state.current_line.len() { .terminal
write!(state.terminal, "{}", state.current_line[i]).expect("Failed to write to terminal output"); .move_cursor_left(1)
.expect("Failed to write to terminal output");
for i in state.current_line.len() - state.cursor_rightward_position
..state.current_line.len()
{
write!(state.terminal, "{}", state.current_line[i])
.expect("Failed to write to terminal output");
} }
write!(state.terminal, " ").expect("Failed to write to terminal output"); write!(state.terminal, " ").expect("Failed to write to terminal output");
state.terminal.move_cursor_left(state.cursor_rightward_position + 1).expect("Failed to write to terminal output"); state
.terminal
.move_cursor_left(state.cursor_rightward_position + 1)
.expect("Failed to write to terminal output");
}
} }
} }
},
Key::Enter => { Key::Enter => {
state.terminal.write_line("").expect("Failed to write to terminal output"); state
.terminal
.write_line("")
.expect("Failed to write to terminal output");
let statement = state.statement_buf.iter().collect::<String>(); let statement = state.statement_buf.iter().collect::<String>();
let statement_result = statement.trim(); let statement_result = statement.trim();
if statement_result.starts_with('?') { if statement_result.starts_with('?') {
//println!("Got {}", statement_result.unwrap()); //println!("Got {}", statement_result.unwrap());
repl_commands(statement_result); repl_commands(statement_result);
state.statement_buf.clear(); state.statement_buf.clear();
} else if state.bracket_depth == 0 && state.in_literal.is_none() && state.curly_depth == 0 { } else if state.bracket_depth == 0
&& state.in_literal.is_none()
&& state.curly_depth == 0
{
state.statement_buf.push(';'); state.statement_buf.push(';');
let complete_statement = state.statement_buf.iter().collect::<String>(); let complete_statement = state.statement_buf.iter().collect::<String>();
state state
@ -257,19 +336,23 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
// history // history
let last_line = state.current_line.iter().collect::<String>(); let last_line = state.current_line.iter().collect::<String>();
state.current_line.clear(); state.current_line.clear();
if !last_line.is_empty() && ((!state.history.is_empty() && state.history[state.history.len()-1] != last_line) || state.history.is_empty()) { if !last_line.is_empty()
&& ((!state.history.is_empty()
&& state.history[state.history.len() - 1] != last_line)
|| state.history.is_empty())
{
state.history.push(last_line); state.history.push(last_line);
} }
state.selected_history = 0; state.selected_history = 0;
prompt(state, args); prompt(state, args);
}, }
Key::ArrowUp => { Key::ArrowUp => {
if state.selected_history != state.history.len() { if state.selected_history != state.history.len() {
state.selected_history += 1; state.selected_history += 1;
display_history_line(state, args); display_history_line(state, args);
} }
}, }
Key::ArrowDown => { Key::ArrowDown => {
if state.selected_history > 1 { if state.selected_history > 1 {
state.selected_history -= 1; state.selected_history -= 1;
@ -277,7 +360,10 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
} else if state.selected_history == 1 { } else if state.selected_history == 1 {
state.selected_history = 0; state.selected_history = 0;
state.line_number -= 1; state.line_number -= 1;
state.terminal.clear_line().expect("Failed to write to terminal output"); state
.terminal
.clear_line()
.expect("Failed to write to terminal output");
prompt(state, args); prompt(state, args);
// clear stale input buffer // clear stale input buffer
state.statement_buf.clear(); state.statement_buf.clear();
@ -286,42 +372,57 @@ fn read_loop<F: FnMut()>(args: &CliArgs, state: &mut ReplState, mut execute: F)
state.bracket_depth = 0; state.bracket_depth = 0;
state.curly_depth = 0; state.curly_depth = 0;
} }
}, }
Key::ArrowLeft => { Key::ArrowLeft => {
if state.current_line.len() > state.cursor_rightward_position { if state.current_line.len() > state.cursor_rightward_position {
state.terminal.move_cursor_left(1).expect("Failed to write to terminal output"); state
.terminal
.move_cursor_left(1)
.expect("Failed to write to terminal output");
state.cursor_rightward_position += 1; state.cursor_rightward_position += 1;
} }
}, }
Key::ArrowRight => { Key::ArrowRight => {
if state.cursor_rightward_position != 0 { if state.cursor_rightward_position != 0 {
state.terminal.move_cursor_right(1).expect("Failed to write to terminal output"); state
.terminal
.move_cursor_right(1)
.expect("Failed to write to terminal output");
state.cursor_rightward_position -= 1; state.cursor_rightward_position -= 1;
} }
}, }
_ => continue _ => continue,
} }
//println!("Read {}", read_buf[0]); //println!("Read {}", read_buf[0]);
} }
} }
#[inline(always)] #[inline(always)]
fn prompt(state: &mut ReplState, args: &CliArgs) { fn prompt(state: &mut ReplState, args: &CliArgs) {
write!(state.terminal, "{}{}", state.line_number, args.prompt).expect("Failed to write to terminal output"); write!(state.terminal, "{}{}", state.line_number, args.prompt)
.expect("Failed to write to terminal output");
state.line_number += 1; state.line_number += 1;
state.terminal.flush().expect("Failed to flush terminal output"); state
.terminal
.flush()
.expect("Failed to flush terminal output");
} }
#[inline(always)] #[inline(always)]
fn display_history_line(state: &mut ReplState, args: &CliArgs) { fn display_history_line(state: &mut ReplState, args: &CliArgs) {
// get historical line // get historical line
state.line_number -= 1; state.line_number -= 1;
state.terminal.clear_line().expect("Failed to write to terminal output"); state
.terminal
.clear_line()
.expect("Failed to write to terminal output");
prompt(state, args); prompt(state, args);
let new_statement = state.history[state.history.len() - state.selected_history].trim(); let new_statement = state.history[state.history.len() - state.selected_history].trim();
state.terminal.write(new_statement.as_bytes()).expect("Failed to write to terminal output"); state
.terminal
.write(new_statement.as_bytes())
.expect("Failed to write to terminal output");
// clear stale input buffer // clear stale input buffer
state.statement_buf.clear(); state.statement_buf.clear();
state.current_line.clear(); state.current_line.clear();