diff --git a/src/command_bar.rs b/src/command_bar.rs index 59411a5..ded8a81 100644 --- a/src/command_bar.rs +++ b/src/command_bar.rs @@ -10,7 +10,7 @@ use rand::seq::SliceRandom; use std::cmp::{max, min}; use std::collections::btree_map::BTreeMap; use std::collections::HashMap; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::thread; @@ -509,42 +509,6 @@ impl CommandBar { commands } - - #[allow(unused)] - fn load_file(&mut self, filepath: &Path) -> Result { - let Ok(file_read) = std::fs::read(filepath) else { - self.set_error_pop_up(format!("Cannot find {:?} filepath", filepath)); - return Err(()); - }; - - let Ok(file_str) = std::str::from_utf8(file_read.as_slice()) else { - self.set_error_pop_up(format!("The file {:?} has non UTF-8 characters", filepath)); - return Err(()); - }; - - Ok(file_str.to_string()) - } - - #[allow(unused)] - fn send_file(&mut self, filepath: &str, delay: Option) { - if let Ok(str_send) = self.load_file(Path::new(filepath)) { - let str_send_splitted = str_send.split('\n'); - let total = str_send_splitted.clone().collect::>().len(); - let interface = self.interface.lock().unwrap(); - for (i, str_split) in str_send_splitted.enumerate() { - interface.send(UserTxData::File( - i, - total, - filepath.to_string(), - str_split.to_string(), - )); - - if let Some(delay) = delay { - sleep(delay); - } - } - } - } } enum InputEvent { diff --git a/src/messages.rs b/src/messages.rs index 2c09e58..608ba22 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -8,8 +8,6 @@ pub enum UserTxData { Command(String, String), HexString(Vec), PluginSerialTx(String, Vec), - #[allow(unused)] - File(usize, usize, String, String), } #[derive(Clone)] @@ -18,14 +16,12 @@ pub enum SerialRxData { ConfirmData(DateTime, String), ConfirmCommand(DateTime, String, String), ConfirmHexString(DateTime, Vec), - ConfirmFile(DateTime, usize, usize, String, String), Plugin(DateTime, String, String), ConfirmPluginSerialTx(DateTime, String, Vec), FailPlugin(DateTime, String, String), FailData(DateTime, String), FailCommand(DateTime, String, String), FailHexString(DateTime, Vec), - FailFile(DateTime, usize, usize, String, String), FailPluginSerialTx(DateTime, String, Vec), } @@ -60,12 +56,6 @@ impl Into for SerialRxData { Color::Black, Color::Yellow, ), - SerialRxData::ConfirmFile(timestamp, idx, total, filename, content) => ViewData::new( - timestamp, - format!("{}[{}/{}]: <{}>", filename, idx, total, content), - Color::Black, - Color::LightMagenta, - ), SerialRxData::Plugin(timestamp, plugin_name, message) => ViewData::new( timestamp, format!(" [{plugin_name}] {message} "), @@ -96,12 +86,6 @@ impl Into for SerialRxData { Color::White, Color::LightRed, ), - SerialRxData::FailFile(timestamp, idx, total, filename, content) => ViewData::new( - timestamp, - format!("Cannot send {}[{}/{}]: <{}>", filename, idx, total, content), - Color::White, - Color::LightRed, - ), SerialRxData::FailPlugin(timestamp, plugin_name, message) => ViewData::new( timestamp, format!(" [{plugin_name}] {message} "), diff --git a/src/plugin.rs b/src/plugin.rs index ac1f4a0..c7141fe 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -89,7 +89,6 @@ impl Plugin { self.name.as_str() } - #[allow(unused)] pub fn serial_rx_call(&self, msg: Vec) -> SerialRxCall { let lua = Lua::new(); let code = self.code.as_str(); diff --git a/src/serial.rs b/src/serial.rs index 6722e3e..33e7724 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -46,15 +46,6 @@ impl SerialIF { format!("Serial {}:{}bps", self.port, self.baudrate) } - #[allow(unused)] - pub fn set_port(&mut self, _port: String) { - self.port = _port; - } - #[allow(unused)] - pub fn set_baudrate(&mut self, _baudrate: u32) { - self.baudrate = _baudrate; - } - pub fn new(port: &str, baudrate: u32) -> Self { let (serial_tx, serial_rx) = channel(); let (data_tx, data_rx) = channel(); @@ -191,32 +182,6 @@ impl SerialIF { .expect("Cannot send hex string fail"), } } - UserTxData::File(idx, total, filename, content) => { - match serial.write(format!("{content}\n").as_bytes()) { - Ok(_) => { - data_tx - .send(SerialRxData::ConfirmFile( - Local::now(), - idx, - total, - filename, - content, - )) - .expect("Cannot send file confirm"); - } - Err(_) => { - data_tx - .send(SerialRxData::FailFile( - Local::now(), - idx, - total, - filename, - content, - )) - .expect("Cannot send file fail"); - } - } - } } }