clean up
This commit is contained in:
parent
4f92c0c24f
commit
cb08b6b984
@ -21,7 +21,7 @@ pub fn pos() {
|
|||||||
let screen = Screen::default();
|
let screen = Screen::default();
|
||||||
let mut cursor = cursor(&screen);
|
let mut cursor = cursor(&screen);
|
||||||
// get the cursor position.
|
// get the cursor position.
|
||||||
let (x, y) = cursor.pos();
|
let (_x, _y) = cursor.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Move the cursor 3 up | demonstration.
|
/// Move the cursor 3 up | demonstration.
|
||||||
|
@ -21,7 +21,7 @@ pub fn read_async_until() {
|
|||||||
|
|
||||||
let mut stdin = input.read_until_async(b'\r').bytes();
|
let mut stdin = input.read_until_async(b'\r').bytes();
|
||||||
|
|
||||||
for i in 0..100 {
|
for _i in 0..100 {
|
||||||
terminal.clear(ClearType::All);
|
terminal.clear(ClearType::All);
|
||||||
cursor.goto(1, 1);
|
cursor.goto(1, 1);
|
||||||
let a = stdin.next();
|
let a = stdin.next();
|
||||||
@ -49,7 +49,7 @@ pub fn read_async() {
|
|||||||
|
|
||||||
let mut stdin = input.read_async().bytes();
|
let mut stdin = input.read_async().bytes();
|
||||||
|
|
||||||
for i in 0..100 {
|
for _i in 0..100 {
|
||||||
let a = stdin.next();
|
let a = stdin.next();
|
||||||
|
|
||||||
println!("pressed key: {:?}", a);
|
println!("pressed key: {:?}", a);
|
||||||
|
@ -35,7 +35,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
input_buf.lock().unwrap().clear();
|
input_buf.lock().unwrap().clear();
|
||||||
}
|
}
|
||||||
Some(Ok(val)) =>
|
Some(Ok(_val)) =>
|
||||||
{
|
{
|
||||||
input_buf.lock().unwrap().push(a.unwrap().unwrap() as char);
|
input_buf.lock().unwrap().push(a.unwrap().unwrap() as char);
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ fn log(input_buf: Arc<Mutex<String>>, screen: &Screen) -> Vec<thread::JoinHandle
|
|||||||
for i in 0..1
|
for i in 0..1
|
||||||
{
|
{
|
||||||
let input_buffer = input_buf.clone();
|
let input_buffer = input_buf.clone();
|
||||||
let clone_stdout = screen.stdout.clone();
|
let _clone_stdout = screen.stdout.clone();
|
||||||
|
|
||||||
let crossterm = Crossterm::from(screen.stdout.clone());
|
let crossterm = Crossterm::from(screen.stdout.clone());
|
||||||
|
|
||||||
|
@ -82,14 +82,14 @@ fn new_sync_flag(initial_state: bool) -> (SyncFlagTx, SyncFlagRx) {
|
|||||||
|
|
||||||
fn main()
|
fn main()
|
||||||
{
|
{
|
||||||
let (results_tx, results_rx): (Sender<String>, Receiver<String>) = mpsc::channel();
|
let (_results_tx, _results_rx): (Sender<String>, Receiver<String>) = mpsc::channel();
|
||||||
let (mut more_jobs_tx, more_jobs_rx) = new_sync_flag(true);
|
let (mut more_jobs_tx, more_jobs_rx) = new_sync_flag(true);
|
||||||
|
|
||||||
// queue with all log entry's.
|
// queue with all log entry's.
|
||||||
let queue = WorkQueue::new();
|
let queue = WorkQueue::new();
|
||||||
|
|
||||||
// queue x logs with different threads.
|
// queue x logs with different threads.
|
||||||
let thread_handles = log_with_different_threads(more_jobs_tx.clone(), queue.clone());
|
let _thread_handles = log_with_different_threads(more_jobs_tx.clone(), queue.clone());
|
||||||
|
|
||||||
// a thread that will log all logs in the queue.
|
// a thread that will log all logs in the queue.
|
||||||
handle_incoming_logs(more_jobs_rx.clone(), queue.clone());
|
handle_incoming_logs(more_jobs_rx.clone(), queue.clone());
|
||||||
|
@ -12,10 +12,10 @@ pub fn use_crossterm_cursor()
|
|||||||
let crossterm = Crossterm::new(&screen);
|
let crossterm = Crossterm::new(&screen);
|
||||||
|
|
||||||
// pass a reference to the current screen.
|
// pass a reference to the current screen.
|
||||||
let cursor = crossterm.cursor();
|
let _cursor = crossterm.cursor();
|
||||||
let color = crossterm.color();
|
let _color = crossterm.color();
|
||||||
let terminal = crossterm.terminal();
|
let _terminal = crossterm.terminal();
|
||||||
let style = crossterm.style("").with(Color::Black).on(Color::Green);
|
let _style = crossterm.style("").with(Color::Black).on(Color::Green);
|
||||||
|
|
||||||
// perform some actions with the instances above.
|
// perform some actions with the instances above.
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ pub fn get_terminal_size() -> (u16, u16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the cursor position based on the current platform.
|
/// Get the cursor position based on the current platform.
|
||||||
pub fn get_cursor_position(stdout: &Arc<TerminalOutput>) -> (u16, u16) {
|
pub fn get_cursor_position(_stdout: &Arc<TerminalOutput>) -> (u16, u16) {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
return pos().expect("Valide position");
|
return pos().expect("Valide position");
|
||||||
// return pos().unwrap_or_else(|x| { return (0,0) });
|
// return pos().unwrap_or_else(|x| { return (0,0) });
|
||||||
|
@ -32,7 +32,7 @@ impl RawScreen {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
let mut command = win_commands::RawModeCommand::new();
|
let mut command = win_commands::RawModeCommand::new();
|
||||||
|
|
||||||
let result = command.enable();
|
let _result = command.enable();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ pub fn terminal_size() -> (u16, u16) {
|
|||||||
|
|
||||||
pub fn pos() -> io::Result<(u16, u16)>
|
pub fn pos() -> io::Result<(u16, u16)>
|
||||||
{
|
{
|
||||||
let screen = Screen::new(false);
|
let _screen = Screen::new(false);
|
||||||
|
|
||||||
// if we enable raw modes with screen, this could cause problems if raw mode is already enabled in applicaition.
|
// if we enable raw modes with screen, this could cause problems if raw mode is already enabled in applicaition.
|
||||||
// I am not completely happy with this approach so feel free to find an other way.
|
// I am not completely happy with this approach so feel free to find an other way.
|
||||||
@ -226,7 +226,7 @@ pub fn disable_raw_mode() -> io::Result<()>
|
|||||||
pub fn get_tty() -> io::Result<fs::File> {
|
pub fn get_tty() -> io::Result<fs::File> {
|
||||||
let mut tty_f: fs::File = unsafe { ::std::mem::zeroed() };
|
let mut tty_f: fs::File = unsafe { ::std::mem::zeroed() };
|
||||||
|
|
||||||
let fd = unsafe {
|
let _fd = unsafe {
|
||||||
if libc::isatty(libc::STDIN_FILENO) == 1 {
|
if libc::isatty(libc::STDIN_FILENO) == 1 {
|
||||||
libc::STDIN_FILENO
|
libc::STDIN_FILENO
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,7 +15,7 @@ impl UnixInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ITerminalInput for UnixInput {
|
impl ITerminalInput for UnixInput {
|
||||||
fn read_line(&self, screen_manger: &Arc<TerminalOutput>) -> io::Result<String> {
|
fn read_line(&self, _screen_manger: &Arc<TerminalOutput>) -> io::Result<String> {
|
||||||
let mut rv = String::new();
|
let mut rv = String::new();
|
||||||
io::stdin().read_line(&mut rv)?;
|
io::stdin().read_line(&mut rv)?;
|
||||||
let len = rv.trim_right_matches(&['\r', '\n'][..]).len();
|
let len = rv.trim_right_matches(&['\r', '\n'][..]).len();
|
||||||
@ -23,11 +23,11 @@ impl ITerminalInput for UnixInput {
|
|||||||
Ok(rv)
|
Ok(rv)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_char(&self, screen_manger: &Arc<TerminalOutput>) -> io::Result<char> {
|
fn read_char(&self, _screen_manger: &Arc<TerminalOutput>) -> io::Result<char> {
|
||||||
read_char()
|
read_char()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_async(&self, screen_manger: &Arc<TerminalOutput>) -> AsyncReader {
|
fn read_async(&self, _screen_manger: &Arc<TerminalOutput>) -> AsyncReader {
|
||||||
let (send, recv) = mpsc::channel();
|
let (send, recv) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@ -41,7 +41,7 @@ impl ITerminalInput for UnixInput {
|
|||||||
AsyncReader { recv: recv }
|
AsyncReader { recv: recv }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_until_async(&self, delimiter: u8, screen_manger: &Arc<TerminalOutput>) -> AsyncReader {
|
fn read_until_async(&self, delimiter: u8, _screen_manger: &Arc<TerminalOutput>) -> AsyncReader {
|
||||||
let (send, recv) = mpsc::channel();
|
let (send, recv) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
@ -36,7 +36,7 @@ mod winapi_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn write_ansi()
|
fn write_ansi()
|
||||||
{
|
{
|
||||||
let screen = Screen::default();
|
let _screen = Screen::default();
|
||||||
let output = AnsiOutput::new();
|
let output = AnsiOutput::new();
|
||||||
|
|
||||||
let bytes = "test".as_bytes();
|
let bytes = "test".as_bytes();
|
||||||
@ -47,7 +47,7 @@ fn write_ansi()
|
|||||||
#[test]
|
#[test]
|
||||||
fn write_str_ansi()
|
fn write_str_ansi()
|
||||||
{
|
{
|
||||||
let screen = Screen::default();
|
let _screen = Screen::default();
|
||||||
let output = AnsiOutput::new();
|
let output = AnsiOutput::new();
|
||||||
|
|
||||||
let bytes = "test".as_bytes();
|
let bytes = "test".as_bytes();
|
||||||
|
@ -216,7 +216,7 @@ impl <'a, D: Display + 'a> DisplayableObject<'a, D>
|
|||||||
|
|
||||||
impl<'a, D: Display + 'a> Display for DisplayableObject<'a, D>
|
impl<'a, D: Display + 'a> Display for DisplayableObject<'a, D>
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
fn fmt(&self, _f: &mut Formatter) -> Result<(), Error> {
|
||||||
self.styled_object.paint(&self.screen);
|
self.styled_object.paint(&self.screen);
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ impl ITerminal for AnsiTerminal {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn terminal_size(&self, stdout: &Arc<TerminalOutput>) -> (u16, u16) {
|
fn terminal_size(&self, _stdout: &Arc<TerminalOutput>) -> (u16, u16) {
|
||||||
functions::get_terminal_size()
|
functions::get_terminal_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user