Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Removed debug messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed Oct 3, 2023
1 parent 6c76cdc commit 38ed9a9
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
1 change: 0 additions & 1 deletion src/com/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl Com for ComRawImpl {
Ok(()) => Ok(buf.len()),
Err(ref e) => {
if e.kind() == io::ErrorKind::WouldBlock {
println!("sleep1");
std::thread::sleep(Duration::from_millis(100));
return self.send(buf);
}
Expand Down
13 changes: 9 additions & 4 deletions src/com/telnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ mod telnet_option {
impl ComTelnetImpl {
pub fn connect(connection_data: &super::OpenConnectionData) -> TermComResult<Self> {
let tcp_stream = TcpStream::connect(&connection_data.address)?;
tcp_stream.set_nonblocking(true)?;
tcp_stream.set_write_timeout(Some(Duration::from_millis(2000)))?;
tcp_stream.set_read_timeout(Some(Duration::from_millis(2000)))?;
Ok(Self {
Expand Down Expand Up @@ -483,16 +482,24 @@ impl Com for ComTelnetImpl {
}

fn read_data(&mut self) -> TermComResult<Option<Vec<u8>>> {
let mut buf = [0; 1024 * 8];
let mut buf = [0; 1024 * 256];
self.tcp_stream.set_nonblocking(false)?;
if self.tcp_stream.peek(&mut buf)? == 0 {
return Ok(None);
}

match self.tcp_stream.read(&mut buf) {
Ok(size) => {
self.tcp_stream.set_nonblocking(true)?;

if self.use_raw_transfer {
Ok(Some(buf[0..size].to_vec()))
} else {
self.parse(&buf[0..size])
}
}
Err(ref e) => {
self.tcp_stream.set_nonblocking(true)?;
if e.kind() == io::ErrorKind::WouldBlock {
return Ok(None);
}
Expand Down Expand Up @@ -520,8 +527,6 @@ impl Com for ComTelnetImpl {
Ok(()) => Ok(buf.len()),
Err(ref e) => {
if e.kind() == io::ErrorKind::WouldBlock {
println!("sleep2");

std::thread::sleep(Duration::from_millis(100));
return self.send(buf);
}
Expand Down
53 changes: 31 additions & 22 deletions src/ui/buffer_update_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,36 @@ impl BufferUpdateThread {
}
}
}

match ch {
b'\\' => print!("\\\\"),
b'\n' => println!("\\n"),
b'\r' => print!("\\r"),
b'\"' => print!("\\\""),
_ => {
if ch < b' ' || ch == b'\x7F' {
print!("\\x{ch:02X}");
} else if ch > b'\x7F' {
print!("\\u{{{ch:02X}}}");
} else {
print!("{}", char::from_u32(ch as u32).unwrap());
}
}
}
if self.print_char(buffer_view, ch) {
set_buffer_dirty = true;
}
if let Some((protocol_type, download)) = self.auto_file_transfer.try_transfer(ch) {
self.auto_transfer = Some((protocol_type, download));
}
}

if has_data {
buffer_view.get_buffer_mut().update_hyperlinks();
}
if set_buffer_dirty {
self.last_update = Instant::now();
buffer_view.get_edit_state_mut().is_buffer_dirty = true;
ctx.request_repaint();
return false;
}
/*
Expand All @@ -98,50 +114,43 @@ impl BufferUpdateThread {
}
}
}*/

/*
match ch {
b'\\' => print!("\\\\"),
b'\n' => println!("\\n"),
b'\r' => print!("\\r"),
b'\"' => print!("\\\""),
_ => {
if ch < b' ' || ch == b'\x7F' {
print!("\\x{ch:02X}");
} else if ch > b'\x7F' {
print!("\\u{{{ch:02X}}}");
} else {
print!("{}", char::from_u32(ch as u32).unwrap());
}
}
}*/

*/
true
}

pub fn print_char(&self, buffer_view: &mut BufferView, c: u8) -> bool {
let result = buffer_view.print_char(c as char);
match result {
Ok(icy_engine::CallbackAction::SendString(result)) => {
println!("send string: '{}'", result.replace("\x1B", "\\x1b"));
if let Some(con) = self.connection.lock().as_mut() {
if con.is_connected() {
let r = con.send(result.as_bytes().to_vec());
// check_error!(self, r, false);
if let Err(r) = r {
log::error!("{r}");
}
}
}
}
Ok(icy_engine::CallbackAction::PlayMusic(music)) => {
let r = self.sound_thread.lock().play_music(music);
// check_error!(self, r, false);
if let Err(r) = r {
log::error!("{r}");
}
}
Ok(icy_engine::CallbackAction::Beep) => {
let r = self.sound_thread.lock().beep();
// check_error!(self, r, false);
if let Err(r) = r {
log::error!("{r}");
}
}
Ok(icy_engine::CallbackAction::ChangeBaudEmulation(baud_emulation)) => {
if let Some(con) = self.connection.lock().as_mut() {
let r = con.set_baud_rate(baud_emulation.get_baud_rate());
// check_error!(self, r, false);
if let Err(r) = r {
log::error!("{r}");
}
}
}
Ok(icy_engine::CallbackAction::ResizeTerminal(_, _)) => {
Expand Down
4 changes: 0 additions & 4 deletions src/ui/com_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,9 @@ impl MainWindow {
while data.thread_is_running {
if data.is_connected {
if !data.read_data() {
println!("sleep5");

std::thread::sleep(Duration::from_millis(25));
}
} else {
println!("sleep6");

std::thread::sleep(Duration::from_millis(100));
}
data.handle_receive();
Expand Down
4 changes: 0 additions & 4 deletions src/ui/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ impl DataConnection for Connection {

fn read_u8(&mut self) -> TerminalResult<u8> {
while !self.is_data_available()? {
println!("sleep7");

std::thread::sleep(Duration::from_millis(10));
}
Ok(self.buf.pop_front().unwrap())
Expand All @@ -45,8 +43,6 @@ impl DataConnection for Connection {
fn read_exact(&mut self, size: usize) -> TerminalResult<Vec<u8>> {
while self.buf.len() < size {
self.fill_buffer()?;
println!("sleep8");

std::thread::sleep(Duration::from_millis(10));
}

Expand Down

0 comments on commit 38ed9a9

Please sign in to comment.