GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — RustPython/src/shell.rs at main · RustPython/RustPython Expand file tree/ Copy pathshell.rsMore file actions 41 lines (39 loc) · 1.33 KB / Copy pathshell.rsFile metadata and controls41 lines (39 loc) · 1.33 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 mod helper; use rustpython_vm::{ PyResult, VirtualMachine, readline::{Readline, ReadlineResult}, scope::Scope, vm::InteractiveLine, }; /// Enter a repl loop /// /// rustyline takes the role of `PyOS_Readline` with the readline module, /// adding line editing, completion and history. pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> { let mut repl = Readline::new(helper::ShellHelper::new(vm, scope.globals)); let history = dirs::config_dir().map_or_else( || ".repl_history.txt".into(), |mut path| { path.push("rustpython"); path.push("repl_history.txt"); path }, ); let _ = repl.load_history(&history); let result = vm.run_interactive_loop(|prompt| match repl.readline(prompt) { ReadlineResult::Line(line) => { let _ = repl.add_history_entry(line.trim_end()); Ok(Some(InteractiveLine::Text(line))) } ReadlineResult::Eof => Ok(None), ReadlineResult::Interrupt => { Err(vm.new_exception_empty(vm.ctx.exceptions.keyboard_interrupt.to_owned())) } ReadlineResult::Io(_) => Ok(None), #[cfg(unix)] ReadlineResult::OsError(_) => Ok(None), ReadlineResult::Other(_) => Ok(None), }); let _ = repl.save_history(&history); result } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |