diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 476a865..249856c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,14 @@ - + + + + + - - + + @@ -20,6 +24,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -29,99 +100,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + @@ -137,7 +129,6 @@ - term ScreenManager color cursor( @@ -167,6 +158,7 @@ context WinApiScreenManager color( + d crossterm_cursor @@ -208,23 +200,17 @@ @@ -318,6 +310,12 @@ + + + + + + @@ -338,6 +336,12 @@ + + + + + + @@ -541,12 +545,12 @@ - + - @@ -695,13 +699,6 @@ - - - - - - - @@ -737,13 +734,6 @@ - - - - - - - @@ -758,13 +748,6 @@ - - - - - - - @@ -839,20 +822,6 @@ - - - - - - - - - - - - - - @@ -860,49 +829,89 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - - - - - - + + - + - - + + - - - - - - - - - + + @@ -913,43 +922,38 @@ - + - - - - - - + + - + - - - - - - + + - + - - - - - - + + - + - - + + + + + + + + + diff --git a/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs b/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs index 92b3d43..999cc13 100644 --- a/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs +++ b/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs @@ -140,6 +140,16 @@ pub fn show_cursor() cursor.show(); } +/// Show cursor display | demonstration. +pub fn blink_cursor() +{ + let context = Context::new(); + + let cursor = cursor(context.clone()); + cursor.blink(false); + cursor.blink(false); +} + diff --git a/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs b/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs index 4fa45a0..4ae3e38 100644 --- a/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs +++ b/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs @@ -37,6 +37,7 @@ fn print_wait_screen(context: Rc) } } +/// print wait screen on alternate screen, then swich back. pub fn print_wait_screen_on_alternate_window() { let context = Context::new(); @@ -54,6 +55,7 @@ pub fn print_wait_screen_on_alternate_window() println!("Whe are back at the main screen"); } +/// some stress test switch from and to alternate screen. pub fn switch_between_main_and_alternate_screen() { let context = Context::new(); diff --git a/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs b/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs index 8d904f4..937b4c1 100644 --- a/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs +++ b/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs @@ -155,3 +155,14 @@ pub fn resize_terminal() // Get terminal size terminal.set_size(10,10); } + +/// exit the current proccess. +pub fn exit() +{ + let context = Context::new(); + + // Get terminal + let mut terminal = terminal(context.clone()); + // Get terminal size + terminal.exit(); +} diff --git a/src/cursor/ansi_cursor.rs b/src/cursor/ansi_cursor.rs index 83fe35b..d880abe 100644 --- a/src/cursor/ansi_cursor.rs +++ b/src/cursor/ansi_cursor.rs @@ -100,7 +100,7 @@ impl ITerminalCursor for AnsiCursor { screen.write_ansi_str(csi!("?12h")); } else { - screen.write_ansi_str(csi!("?12")); + screen.write_ansi_str(csi!("?12l")); } } } diff --git a/src/cursor/cursor.rs b/src/cursor/cursor.rs index 8ee03ad..c61b398 100644 --- a/src/cursor/cursor.rs +++ b/src/cursor/cursor.rs @@ -338,7 +338,7 @@ impl TerminalCursor /// Enable or disable blinking of the terminal. /// - /// Note that this only works on windows 10 and unix systems. If you are working on windows 10 or lower this won't work. + /// Not all terminals are supporting this functionality. Windows versions lower than windows 10 also are not supporting this version. /// /// #Example /// diff --git a/src/kernel/unix_kernel/terminal.rs b/src/kernel/unix_kernel/terminal.rs index 7f10506..0d97c0c 100644 --- a/src/kernel/unix_kernel/terminal.rs +++ b/src/kernel/unix_kernel/terminal.rs @@ -135,6 +135,7 @@ pub fn get_terminal_mode() -> io::Result pub fn exit() { ::std::process::exit(0); +} /// Is the return value true? fn is_true(value: i32) -> Result<(), Error> diff --git a/src/kernel/windows_kernel/kernel.rs b/src/kernel/windows_kernel/kernel.rs index 855643f..bdd4694 100644 --- a/src/kernel/windows_kernel/kernel.rs +++ b/src/kernel/windows_kernel/kernel.rs @@ -4,6 +4,7 @@ use winapi::um::winbase::{STD_OUTPUT_HANDLE, STD_INPUT_HANDLE }; use winapi::um::handleapi::INVALID_HANDLE_VALUE; use winapi::um::processenv::{GetStdHandle}; use winapi::um::consoleapi::{SetConsoleMode,GetConsoleMode, }; +use winapi::shared::ntdef::{NULL}; use winapi::shared::minwindef::{TRUE, FALSE}; use winapi::um::wincon; use winapi::um::wincon:: @@ -311,7 +312,7 @@ pub fn write_char_buffer(handle: HANDLE, buf: &[u8]) let utf16_bytes: Vec = utf8.encode_utf16().collect(); - let utf16 = match String::from_utf16(&utf16_bytes) + let mut utf16 = match String::from_utf16(&utf16_bytes) { Ok(string) => string, Err(_) => String::new() @@ -338,6 +339,7 @@ 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(handle, ptr, str_length, current_pos, &mut cells_written); } diff --git a/src/manager/win_manager.rs b/src/manager/win_manager.rs index 0f61962..de0a750 100644 --- a/src/manager/win_manager.rs +++ b/src/manager/win_manager.rs @@ -20,16 +20,10 @@ impl IScreenManager for WinApiScreenManager } fn write_ansi(&mut self, string: String) - { -// write!(self.output, "{}", string); -// self.flush(); - } + { } fn write_ansi_str(&mut self, string: &str) - { -// write!(self.output, "{}", string); -// self.flush(); - } + { } fn write(&mut self, buf: &[u8]) -> io::Result { if self.is_alternate_screen diff --git a/src/terminal/ansi_terminal.rs b/src/terminal/ansi_terminal.rs index 264d121..1b61f5e 100644 --- a/src/terminal/ansi_terminal.rs +++ b/src/terminal/ansi_terminal.rs @@ -67,14 +67,6 @@ impl ITerminal for AnsiTerminal { } } - fn set_title(&self, title: String) - { - let mut screen = self.context.screen_manager.lock().unwrap(); - { - screen.write_ansi_str("\x1b]2;New terminal titleBEL"); - } - } - fn exit(&self) { functions::exit_terminal(); diff --git a/src/terminal/mod.rs b/src/terminal/mod.rs index 2003aaa..42035e4 100644 --- a/src/terminal/mod.rs +++ b/src/terminal/mod.rs @@ -48,8 +48,6 @@ pub trait ITerminal { fn scroll_down(&self, count: i16); /// Resize terminal to the given width and height. fn set_size(&self,width: i16, height: i16); - /// Set the terminal title. - fn set_title(&self, title: String); /// Close the current terminal fn exit(&self); } diff --git a/src/terminal/terminal.rs b/src/terminal/terminal.rs index 00d9069..8f646e4 100644 --- a/src/terminal/terminal.rs +++ b/src/terminal/terminal.rs @@ -187,13 +187,6 @@ impl Terminal { style::ObjectStyle::new().apply_to(val, self.context.clone()) } - pub fn set_title(&self, title: String) - { - if let Some (ref terminal) = self.terminal { - terminal.set_title(title ); - } - } - pub fn exit(&self) { if let Some (ref terminal) = self.terminal { diff --git a/src/terminal/winapi_terminal.rs b/src/terminal/winapi_terminal.rs index e40fd44..7dcb9da 100644 --- a/src/terminal/winapi_terminal.rs +++ b/src/terminal/winapi_terminal.rs @@ -139,11 +139,6 @@ impl ITerminal for WinApiTerminal { } } - fn set_title(&self, title: String) - { - - } - fn exit(&self) { functions::exit_terminal();