Struct crossterm_winapi::Handle
source · pub struct Handle { /* private fields */ }
Expand description
This abstracts away some WinAPI calls to set and get some console handles.
It wraps WinAPI’s HANDLE
type.
Implementations§
source§impl Handle
impl Handle
sourcepub fn new(handle: HandleType) -> Result<Handle>
pub fn new(handle: HandleType) -> Result<Handle>
Create a new handle of a certaint type.
sourcepub unsafe fn from_raw(handle: HANDLE) -> Self
pub unsafe fn from_raw(handle: HANDLE) -> Self
Construct a handle from a raw handle.
Safety
This is unsafe since there is not guarantee that the underlying HANDLE is thread-safe to implement Send
and Sync
.
Most HANDLE’s however, are thread safe.
sourcepub fn current_out_handle() -> Result<Handle>
pub fn current_out_handle() -> Result<Handle>
Get the handle of the active screen buffer. When using multiple screen buffers this will always point to the to the current screen output buffer.
This function uses CONOUT$
to create a file handle to the current output buffer.
This wraps
CreateFileW
.
sourcepub fn current_in_handle() -> Result<Handle>
pub fn current_in_handle() -> Result<Handle>
Get the handle of the console input buffer.
This function uses CONIN$
to create a file handle to the current input buffer.
This wraps
CreateFileW
.
sourcepub fn output_handle() -> Result<Handle>
pub fn output_handle() -> Result<Handle>
Get the handle of the standard output.
On success this function returns the HANDLE
to STD_OUTPUT_HANDLE
.
This wraps GetStdHandle
called with STD_OUTPUT_HANDLE
.
sourcepub fn input_handle() -> Result<Handle>
pub fn input_handle() -> Result<Handle>
Get the handle of the input screen buffer.
On success this function returns the HANDLE
to STD_INPUT_HANDLE
.
This wraps GetStdHandle
called with STD_INPUT_HANDLE
.
sourcepub fn is_valid_handle(handle: &HANDLE) -> bool
pub fn is_valid_handle(handle: &HANDLE) -> bool
Checks if the console handle is an invalid handle value.
This is done by checking if the passed HANDLE
is equal to INVALID_HANDLE_VALUE
.