You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reedline = { version = "0.38.0", features = ["external_printer"] }
I am on windows cmd.
Right after i start my test programm my console is cleared, in rust rover its not cleared, i think it doesnt support to be cleared
Steps to reproduce
i am not really sure how its caused but i will provide my code
Screenshots/Screencaptures
Desktop.2024.12.24.-.23.44.52.01.mp4
my code
use crate::plugin::api::API;
use crate::server::command::CommandSender;
use crate::server::ProxyServer;
use core::str;
use env_logger::{Builder, Target, WriteStyle};
use log::error;
use reedline::{
EditMode, Emacs, ExternalPrinter, Prompt, PromptEditMode, PromptHistorySearch,
PromptHistorySearchStatus, Reedline, ReedlineEvent, ReedlineRawEvent, Signal,
};
use std::borrow::Cow;
use std::fmt::Arguments;
use std::io;
use std::io::Write;
use std::sync::{Mutex, RwLock};
pub mod auth;
pub mod chat;
pub mod haproxy;
pub mod plugin;
pub mod server;
pub mod util;
pub mod version;
/********** pipe all the writes ***********/
struct SharedWriter {
printer: Box<ExternalPrinter<String>>,
}
impl Write for SharedWriter {
fn write(&mut self, _: &[u8]) -> io::Result<usize> {
unreachable!("write");
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
let str = String::from_utf8_lossy(buf);
self.printer
.print(str.to_string())
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
Ok(())
}
fn write_fmt(&mut self, _: Arguments<'_>) -> io::Result<()> {
unreachable!("write_fmt");
}
}
/********** pipe all the writes ***********/
/********** custom prompt ***********/
struct CrustPrompt;
impl Prompt for CrustPrompt {
fn render_prompt_left(&self) -> Cow<str> {
Cow::Borrowed("")
}
fn render_prompt_right(&self) -> Cow<str> {
Cow::Borrowed("")
}
fn render_prompt_indicator(&self, _: PromptEditMode) -> Cow<str> {
"> ".into()
}
fn render_prompt_multiline_indicator(&self) -> Cow<str> {
Cow::Borrowed(":::")
}
fn render_prompt_history_search_indicator(
&self,
history_search: PromptHistorySearch,
) -> Cow<str> {
let prefix = match history_search.status {
PromptHistorySearchStatus::Passing => "",
PromptHistorySearchStatus::Failing => "failing ",
};
Cow::Owned(format!(
"({}reverse-search: {}) ",
prefix, history_search.term
))
}
}
struct EmacsWrapper {
emacs: Emacs,
}
impl EditMode for EmacsWrapper {
fn parse_event(&mut self, event: ReedlineRawEvent) -> ReedlineEvent {
let event = self.emacs.parse_event(event);
match event {
ReedlineEvent::ClearScreen => {
unreachable!("CLEAR SCREEN");
panic!("CLEAR SCREEN");
}
_ => event,
}
}
fn edit_mode(&self) -> PromptEditMode {
PromptEditMode::Custom(">".to_owned())
}
}
fn main() {
println!("Starting...");
if std::env::var("RUST_LOG").is_err() {
#[cfg(debug_assertions)]
std::env::set_var("RUST_LOG", "info");
#[cfg(not(debug_assertions))]
std::env::set_var("RUST_LOG", "info");
}
let emacs = Emacs::default();
let printer = ExternalPrinter::default();
let mut line_editor = Reedline::create()
.with_external_printer(printer.clone())
.with_edit_mode(Box::new(EmacsWrapper { emacs }));
Builder::from_default_env()
.write_style(WriteStyle::Always)
.target(Target::Pipe(Box::new(SharedWriter {
printer: Box::new(printer),
})))
.try_init()
.unwrap();
server::run_server();
loop {
if let Ok(sig) = line_editor.read_line(&CrustPrompt) {
match sig {
Signal::Success(input) => {
let executed = ProxyServer::instance()
.command_registry()
.execute(&CommandSender::Console, &input);
if !executed {
error!("Unknown command.");
}
}
Signal::CtrlD | Signal::CtrlC => {
API.shutdown_proxy(None);
}
}
continue;
}
break;
}
}
The text was updated successfully, but these errors were encountered:
Platform Windows
Terminal software idk?
reedline = { version = "0.38.0", features = ["external_printer"] }
I am on windows cmd.
Right after i start my test programm my console is cleared, in rust rover its not cleared, i think it doesnt support to be cleared
Steps to reproduce
i am not really sure how its caused but i will provide my code
Screenshots/Screencaptures
Desktop.2024.12.24.-.23.44.52.01.mp4
my code
The text was updated successfully, but these errors were encountered: