From 7544578122fb83ce660236cea5e0b51abe09662e Mon Sep 17 00:00:00 2001 From: TimonPost Date: Tue, 26 Jun 2018 21:28:25 +0200 Subject: [PATCH] Some fixes --- .idea/workspace.xml | 316 +++++++++--------- .../bin.rs | 7 +- src/kernel/windows_kernel/kernel.rs | 6 +- src/manager/manager.rs | 12 +- src/shared/screen.rs | 10 +- src/state/commands/win_commands.rs | 2 +- src/style/styles/styledobject.rs | 3 +- 7 files changed, 175 insertions(+), 181 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 249856c..2632656 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,18 +2,13 @@ - - - - - - + + - - - - - + + + + @@ -272,7 +259,6 @@ - @@ -348,6 +334,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -360,6 +372,7 @@ + @@ -546,14 +559,15 @@ + - - + @@ -581,22 +595,22 @@ - - + + - + - + @@ -622,7 +636,6 @@ - @@ -684,13 +697,6 @@ - - - - - - - @@ -755,13 +761,6 @@ - - - - - - - @@ -776,13 +775,6 @@ - - - - - - - @@ -794,10 +786,6 @@ - - - - @@ -815,13 +803,6 @@ - - - - - - - @@ -833,10 +814,6 @@ - - - - @@ -858,10 +835,6 @@ - - - - @@ -869,10 +842,6 @@ - - - - @@ -885,75 +854,102 @@ - + - - - - - - + + - + - - - - - - - - - - - - - - - - + + - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs b/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs index b952917..31ab94b 100644 --- a/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs +++ b/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs @@ -33,11 +33,6 @@ use std::process::exit; fn main() { let context = Context::new(); - - use crossterm::terminal::terminal; - - let curs = terminal(context.clone()); - curs.exit(); - thread::sleep(time::Duration::from_secs(3)); + alternate_screen::print_wait_screen_on_alternate_window(); } \ No newline at end of file diff --git a/src/kernel/windows_kernel/kernel.rs b/src/kernel/windows_kernel/kernel.rs index bdd4694..5971fcb 100644 --- a/src/kernel/windows_kernel/kernel.rs +++ b/src/kernel/windows_kernel/kernel.rs @@ -9,9 +9,10 @@ use winapi::shared::minwindef::{TRUE, FALSE}; use winapi::um::wincon; use winapi::um::wincon:: { + WriteConsoleOutputCharacterA, SetConsoleWindowInfo, SetConsoleCursorPosition, SetConsoleTextAttribute, SetConsoleScreenBufferSize, CreateConsoleScreenBuffer,SetConsoleActiveScreenBuffer, SetConsoleCursorInfo, GetLargestConsoleWindowSize, GetConsoleScreenBufferInfo, - FillConsoleOutputCharacterA, FillConsoleOutputAttribute,WriteConsoleOutputCharacterA,WriteConsoleOutputAttribute, + FillConsoleOutputCharacterA, FillConsoleOutputAttribute,WriteConsoleOutputAttribute, CONSOLE_SCREEN_BUFFER_INFO, SMALL_RECT, COORD, CHAR_INFO, PSMALL_RECT, CONSOLE_CURSOR_INFO }; @@ -339,7 +340,8 @@ pub fn write_char_buffer(handle: HANDLE, buf: &[u8]) // write to console unsafe { - ::winapi::um::consoleapi::WriteConsoleW(handle, utf16.as_ptr(), utf16.len() as u32, &mut cells_written, NULL); +// WriteConsoleOutputCharacterA() +// ::winapi::um::consoleapi::WriteConsoleW(handle, utf16.as_ptr(), utf16.len() as u32, &mut cells_written, NULL); WriteConsoleOutputCharacterA(handle, ptr, str_length, current_pos, &mut cells_written); } diff --git a/src/manager/manager.rs b/src/manager/manager.rs index 080e477..5a9ed3c 100644 --- a/src/manager/manager.rs +++ b/src/manager/manager.rs @@ -20,15 +20,15 @@ impl ScreenManager { /// Create new screen manager instance whereon screen related actions can be performed. pub fn new() -> ScreenManager { - #[cfg(target_os = "windows")] - let screen_manager = functions::get_module::>(Box::from(WinApiScreenManager::new()), Box::from(AnsiScreenManager::new())).unwrap(); - - #[cfg(not(target_os = "windows"))] - let screen_manager = Box::from(AnsiScreenManager::new()) as Box; +// #[cfg(target_os = "windows")] +// let screen_manager = functions::get_module::>(Box::from(WinApiScreenManager::new()), Box::from(AnsiScreenManager::new())).unwrap(); +// +// #[cfg(not(target_os = "windows"))] +// let screen_manager = Box::from(AnsiScreenManager::new()) as Box; ScreenManager { - screen_manager: screen_manager + screen_manager: Box::new(WinApiScreenManager::new()) } } diff --git a/src/shared/screen.rs b/src/shared/screen.rs index 251688d..5472c82 100644 --- a/src/shared/screen.rs +++ b/src/shared/screen.rs @@ -95,9 +95,11 @@ impl Drop for AlternateScreen // Get the alternate screen command to enable and disable alternate screen based on the current platform fn get_to_alternate_screen_command(context: Rc) -> u16 { - #[cfg(target_os = "windows")] - let command = functions::get_module::>(win_commands::ToAlternateScreenBufferCommand::new(), shared_commands::ToAlternateScreenBufferCommand::new(), context).unwrap(); +// #[cfg(target_os = "windows")] +// let command = functions::get_module::>(win_commands::ToAlternateScreenBufferCommand::new(), shared_commands::ToAlternateScreenBufferCommand::new(), context).unwrap(); +// +// #[cfg(not(target_os = "windows"))] +// shared_commands::ToAlternateScreenBufferCommand::new(context.clone()) - #[cfg(not(target_os = "windows"))] - shared_commands::ToAlternateScreenBufferCommand::new(context.clone()) + win_commands::ToAlternateScreenBufferCommand::new(context.clone()) } \ No newline at end of file diff --git a/src/state/commands/win_commands.rs b/src/state/commands/win_commands.rs index cab2dcc..389104d 100644 --- a/src/state/commands/win_commands.rs +++ b/src/state/commands/win_commands.rs @@ -190,7 +190,7 @@ impl IStateCommand for ToAlternateScreenBufferCommand let b: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::() { Some(b) => { b }, - None => panic!("&a isn't a B!") + None => panic!("") }; b.set_alternate_handle(new_handle); diff --git a/src/style/styles/styledobject.rs b/src/style/styles/styledobject.rs index 8fcaa3f..950d9c6 100644 --- a/src/style/styles/styledobject.rs +++ b/src/style/styles/styledobject.rs @@ -131,7 +131,7 @@ macro_rules! impl_fmt reset = true; } -// #[cfg(unix)] + #[cfg(unix)] for attr in self.object_style.attrs.iter() { let mutex = &self.context.screen_manager; { @@ -146,7 +146,6 @@ macro_rules! impl_fmt let mutex = &self.context.screen_manager; { let mut screen = mutex.lock().unwrap(); - screen.flush(); }