Compare commits
2 Commits
better_ter
...
multiline_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16fdf37ba3 | ||
|
|
3256935946 |
@@ -20,8 +20,6 @@ phf = "0.7.12"
|
|||||||
includedir = "0.2.0"
|
includedir = "0.2.0"
|
||||||
linefeed = "0.5.0"
|
linefeed = "0.5.0"
|
||||||
regex = "0.2"
|
regex = "0.2"
|
||||||
cursive = "0.10"
|
|
||||||
ncurses = "5.98.0"
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
includedir_codegen = "0.2.0"
|
includedir_codegen = "0.2.0"
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ extern crate getopts;
|
|||||||
extern crate linefeed;
|
extern crate linefeed;
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
extern crate colored;
|
extern crate colored;
|
||||||
extern crate ncurses;
|
|
||||||
extern crate cursive;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
@@ -23,7 +21,6 @@ use std::io::Read;
|
|||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
|
||||||
mod new_repl;
|
|
||||||
mod repl;
|
mod repl;
|
||||||
mod language;
|
mod language;
|
||||||
mod webapp;
|
mod webapp;
|
||||||
@@ -83,11 +80,8 @@ pub fn repl_main(generators: Vec<PLIGenerator>) {
|
|||||||
|
|
||||||
match option_matches.free[..] {
|
match option_matches.free[..] {
|
||||||
[] | [_] => {
|
[] | [_] => {
|
||||||
/*
|
|
||||||
let mut repl = repl::Repl::new(languages, initial_index);
|
let mut repl = repl::Repl::new(languages, initial_index);
|
||||||
repl.run();
|
repl.run();
|
||||||
*/
|
|
||||||
new_repl::run();
|
|
||||||
}
|
}
|
||||||
[_, ref filename, _..] => {
|
[_, ref filename, _..] => {
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
use cursive::Cursive;
|
|
||||||
use cursive::views::{Dialog, TextView};
|
|
||||||
|
|
||||||
pub fn run() {
|
|
||||||
println!("YOLO");
|
|
||||||
let mut siv = Cursive::default();
|
|
||||||
siv.add_layer(Dialog::around(TextView::new("FUCKO"))
|
|
||||||
.title("YOLO SWAGGGGG")
|
|
||||||
.button("exit", |s| { s.quit() }));
|
|
||||||
siv.run();
|
|
||||||
}
|
|
||||||
@@ -33,7 +33,7 @@ impl Repl {
|
|||||||
languages,
|
languages,
|
||||||
current_language_index,
|
current_language_index,
|
||||||
interpreter_directive_sigil: ':',
|
interpreter_directive_sigil: ':',
|
||||||
line_reader
|
line_reader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,16 +90,7 @@ impl Repl {
|
|||||||
},
|
},
|
||||||
Ok(ReadResult::Eof) => break,
|
Ok(ReadResult::Eof) => break,
|
||||||
Ok(ReadResult::Signal(_)) => break,
|
Ok(ReadResult::Signal(_)) => break,
|
||||||
Ok(ReadResult::Input(ref input)) => {
|
Ok(ReadResult::Input(input)) => self.input_loop(input),
|
||||||
self.line_reader.add_history_unique(input.to_string());
|
|
||||||
let output = match input.chars().nth(0) {
|
|
||||||
Some(ch) if ch == self.interpreter_directive_sigil => self.handle_interpreter_directive(input),
|
|
||||||
_ => Some(self.input_handler(input)),
|
|
||||||
};
|
|
||||||
if let Some(o) = output {
|
|
||||||
println!("=> {}", o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(());
|
self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(());
|
||||||
@@ -107,6 +98,42 @@ impl Repl {
|
|||||||
println!("Exiting...");
|
println!("Exiting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn input_loop(&mut self, input: String) {
|
||||||
|
use linefeed::ReadResult;
|
||||||
|
if input == "" {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if input.chars().nth(0).unwrap() == self.interpreter_directive_sigil {
|
||||||
|
if let Some(output) = self.handle_interpreter_directive(&input) {
|
||||||
|
println!("{}", output);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut lines = input;
|
||||||
|
self.line_reader.set_prompt("> ").unwrap();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
match self.line_reader.read_line() {
|
||||||
|
Err(e) => {
|
||||||
|
println!("Terminal read error: {}", e);
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
Ok(ReadResult::Eof) => break,
|
||||||
|
Ok(ReadResult::Signal(_)) => break,
|
||||||
|
Ok(ReadResult::Input(input)) => {
|
||||||
|
lines.push('\n'); //TODO not sure if this is needed?
|
||||||
|
lines.push_str(&input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.line_reader.add_history_unique(lines.clone());
|
||||||
|
let output = self.input_handler(&lines);
|
||||||
|
println!("=> {}", output);
|
||||||
|
}
|
||||||
|
|
||||||
fn input_handler(&mut self, input: &str) -> String {
|
fn input_handler(&mut self, input: &str) -> String {
|
||||||
let ref mut language = self.languages[self.current_language_index];
|
let ref mut language = self.languages[self.current_language_index];
|
||||||
let interpreter_output = language.execute_pipeline(input, &self.options);
|
let interpreter_output = language.execute_pipeline(input, &self.options);
|
||||||
|
|||||||
Reference in New Issue
Block a user