Skip to content

Commit

Permalink
Switch to using crossterm instead of termion in the REPL
Browse files Browse the repository at this point in the history
This will allow for the REPL to be used on Windows, but has the side-effect of
making the REPL untestable via stdin, due to
crossterm-rs/crossterm#396
  • Loading branch information
irh committed Oct 22, 2021
1 parent a1bbf19 commit 838e12a
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 206 deletions.
129 changes: 94 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ koto_tempfile = { path = "../../libs/tempfile", version = "^0.8.0"}
koto_toml = { path = "../../libs/toml", version = "^0.8.0"}
koto_yaml = { path = "../../libs/yaml", version = "^0.8.0"}

crossterm = "0.22.1" # A crossplatform terminal library for manipulating terminals.
indexmap = "1.4.0"
termion = "1.5.5"

[dependencies.pulldown-cmark]
# Markdown parsing
Expand Down
10 changes: 5 additions & 5 deletions src/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod help;
mod repl;

use {
crossterm::tty::IsTty,
koto::{bytecode::Chunk, Koto, KotoSettings},
repl::{Repl, ReplSettings},
std::{
Expand Down Expand Up @@ -137,8 +138,7 @@ fn run() -> Result<(), ()> {
Some(script),
)
}
} else if termion::is_tty(&stdin) || std::env::var_os("KOTO_FORCE_REPL_MODE").is_some() {
// Forcing REPL mode is useful for testing the behaviour of the REPL
} else if stdin.is_tty() {
(None, None)
} else {
let mut script = String::new();
Expand Down Expand Up @@ -186,6 +186,8 @@ fn run() -> Result<(), ()> {
return Err(());
}
}

Ok(())
} else {
let mut repl = Repl::with_settings(
ReplSettings {
Expand All @@ -194,8 +196,6 @@ fn run() -> Result<(), ()> {
},
koto_settings,
);
repl.run();
repl.run().map_err(|_| ())
}

Ok(())
}
Loading

0 comments on commit 838e12a

Please sign in to comment.