diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2632656..f3f365c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,12 +3,9 @@
-
-
-
+
-
@@ -19,11 +16,15 @@
-
-
+
+
-
-
+
+
+
+
+
+
@@ -37,20 +38,11 @@
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
@@ -78,11 +70,20 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -90,8 +91,8 @@
-
-
+
+
@@ -116,8 +117,6 @@
- ScreenManager
- color
cursor(
IStateCommand
execute
@@ -146,6 +145,8 @@
WinApiScreenManager
color(
d
+ srct_read_rect
+ get_output_handle();
crossterm_cursor
@@ -213,13 +214,13 @@
-
-
-
+
+
+
@@ -559,12 +560,12 @@
-
+
-
+
@@ -586,6 +587,7 @@
+
@@ -597,7 +599,6 @@
-
@@ -775,17 +776,14 @@
-
-
-
-
-
-
-
+
+
+
+
@@ -814,6 +812,10 @@
+
+
+
+
@@ -835,6 +837,10 @@
+
+
+
+
@@ -842,6 +848,10 @@
+
+
+
+
@@ -887,13 +897,6 @@
-
-
-
-
-
-
-
@@ -922,23 +925,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -948,8 +937,40 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/kernel/windows_kernel/kernel.rs b/src/kernel/windows_kernel/kernel.rs
index 5971fcb..7e9800e 100644
--- a/src/kernel/windows_kernel/kernel.rs
+++ b/src/kernel/windows_kernel/kernel.rs
@@ -1,4 +1,8 @@
//! This module is the core of all the `WINAPI` actions. All unsafe `WINAPI` function call are done here.
+use Context;
+use std::rc::Rc;
+
+
use winapi::um::winnt::HANDLE;
use winapi::um::winbase::{STD_OUTPUT_HANDLE, STD_INPUT_HANDLE };
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
@@ -20,6 +24,21 @@ use super::{Empty};
static mut CONSOLE_OUTPUT_HANDLE: Option = None;
static mut CONSOLE_INPUT_HANDLE: Option = None;
+
+pub fn get_current_handle(context: Rc) -> Rc
+{
+ let mut screen_manager = context.screen_manager.lock().unwrap();
+ use super::super::super::manager::WinApiScreenManager;
+ let b: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::() {
+ Some(b) => { b },
+ None => panic!("")
+ };
+
+ let handle = b.get_handle();
+
+ return handle.clone()
+}
+
/// Get the std_output_handle of the console
pub fn get_output_handle() -> HANDLE {
unsafe {
diff --git a/src/manager/win_manager.rs b/src/manager/win_manager.rs
index de0a750..8eb3a61 100644
--- a/src/manager/win_manager.rs
+++ b/src/manager/win_manager.rs
@@ -4,6 +4,7 @@ use winapi::um::winnt::HANDLE;
use std::io::{self,Write};
use std::any::Any;
+use std::rc::Rc;
pub struct WinApiScreenManager
{
@@ -59,4 +60,15 @@ impl WinApiScreenManager {
{
self.alternate_handle = alternate_handle;
}
+
+ pub fn get_handle(&mut self) -> Rc
+ {
+ if self.is_alternate_screen
+ {
+ return Rc::from(self.alternate_handle);
+ }
+ else {
+ return Rc::from(self.output);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/state/commands/win_commands.rs b/src/state/commands/win_commands.rs
index 389104d..ebf9670 100644
--- a/src/state/commands/win_commands.rs
+++ b/src/state/commands/win_commands.rs
@@ -195,45 +195,6 @@ impl IStateCommand for ToAlternateScreenBufferCommand
b.set_alternate_handle(new_handle);
- // Set the source rectangle.
- let mut srct_read_rect = SMALL_RECT
- {
- Top: 0,
- Left: 0 ,
- Bottom: 1,
- Right: 79,
- };
-
- // The temporary buffer size is 2 rows x 80 columns.
- let coord_buffer_size = COORD
- {
- X: 2,
- Y: 80
- };
-
- // The top left destination cell of the temporary buffer is
- // row 0, col 0.
- let coord_buffer_coord = COORD
- {
- X: 0,
- Y: 0,
- };
-
- // Copy the block from the screen buffer to the temp. buffer.
- kernel::read_console_output(&handle, &mut chi_buffer, coord_buffer_size, coord_buffer_coord, &mut srct_read_rect);
-
- // Set the destination rectangle.
- let mut srct_write_rect = SMALL_RECT
- {
- Top: 10,
- Left: 0,
- Bottom: 11,
- Right: 19,
- };
-
- // Copy from the temporary buffer to the new screen buffer.
- kernel::write_console_output(&new_handle, &mut chi_buffer, coord_buffer_size, coord_buffer_coord, &mut srct_write_rect);
-
true
}