pub fn init_terminal() -> Result<SystemTerminal,()> {
    unsafe {
        if kernel32_sys::GetConsoleWindow().is_null() {
            if kernel32_sys::AllocConsole() == winapi::FALSE
            || kernel32_sys::GetConsoleWindow().is_null() {
                return Err(())
            }
        }

        let old_handle = kernel32_sys::GetStdHandle(winapi::STD_OUTPUT_HANDLE);
        let handle = kernel32_sys::CreateConsoleScreenBuffer(
            winapi::GENERIC_READ | winapi::GENERIC_WRITE,
            0, null_mut(), winapi::CONSOLE_TEXTMODE_BUFFER, null_mut());
        let mut info = uninitialized();
        kernel32_sys::GetConsoleScreenBufferInfo(handle, &mut info);
        let (x, y) = (info.srWindow.Right - info.srWindow.Left + 1,
                      info.srWindow.Bottom - info.srWindow.Top + 1);
        let mut term = SystemTerminal {
            buffer: Vec::new(),
            term_width: 0,
            cur_pos: 0,
            default_color: ColorPair {
                fg: Some(DarkWhite),
                bg: Some(DarkBlack),
            },
            out_handle: handle,
            old_out_handle: old_handle,
        };
        term.set_dimensions(x as u16, y as u16);
        kernel32_sys::SetConsoleActiveScreenBuffer(handle);
        Ok(term)
    }
}
/// Initializes system terminal. **WARNING: Must NOT be called more than once in runtime.**
Initializes system terminal. **WARNING: Must NOT be called more than once in runtime.
Initializes system terminal . ** WARNING : Must NOT be called more than once in runtime .
pub fn init_terminal() -> Result<SystemTerminal,()> {
    unsafe {
        if kernel32_sys::GetConsoleWindow().is_null() {
            if kernel32_sys::AllocConsole() == winapi::FALSE
            || kernel32_sys::GetConsoleWindow().is_null() {
                return Err(())
            }
        }
        let old_handle = kernel32_sys::GetStdHandle(winapi::STD_OUTPUT_HANDLE);
        let handle = kernel32_sys::CreateConsoleScreenBuffer(
            winapi::GENERIC_READ | winapi::GENERIC_WRITE,
            0, null_mut(), winapi::CONSOLE_TEXTMODE_BUFFER, null_mut());
        let mut info = uninitialized();
        kernel32_sys::GetConsoleScreenBufferInfo(handle, &mut info);
        let (x, y) = (info.srWindow.Right - info.srWindow.Left + 1,
                      info.srWindow.Bottom - info.srWindow.Top + 1);
        let mut term = SystemTerminal {
            buffer: Vec::new(),
            term_width: 0,
            cur_pos: 0,
            default_color: ColorPair {
                fg: Some(DarkWhite),
                bg: Some(DarkBlack),
            },
            out_handle: handle,
            old_out_handle: old_handle,
        };
        term.set_dimensions(x as u16, y as u16);
        kernel32_sys::SetConsoleActiveScreenBuffer(handle);
        Ok(term)
    }
}
pub fn init_terminal ( ) -> Result < SystemTerminal , ( ) > { unsafe { if kernel32_sys :: GetConsoleWindow ( ) . is_null ( ) { if kernel32_sys :: AllocConsole ( ) == winapi :: FALSE || kernel32_sys :: GetConsoleWindow ( ) . is_null ( ) { return Err ( ( ) ) } } let old_handle = kernel32_sys :: GetStdHandle ( winapi :: STD_OUTPUT_HANDLE ) ; let handle = kernel32_sys :: CreateConsoleScreenBuffer ( winapi :: GENERIC_READ | winapi :: GENERIC_WRITE , 0 , null_mut ( ) , winapi :: CONSOLE_TEXTMODE_BUFFER , null_mut ( ) ) ; let mut info = uninitialized ( ) ; kernel32_sys :: GetConsoleScreenBufferInfo ( handle , & mut info ) ; let ( x , y ) = ( info . srWindow . Right - info . srWindow . Left + 1 , info . srWindow . Bottom - info . srWindow . Top + 1 ) ; let mut term = SystemTerminal { buffer : Vec :: new ( ) , term_width : 0 , cur_pos : 0 , default_color : ColorPair { fg : Some ( DarkWhite ) , bg : Some ( DarkBlack ) , } , out_handle : handle , old_out_handle : old_handle , } ; term . set_dimensions ( x as u16 , y as u16 ) ; kernel32_sys :: SetConsoleActiveScreenBuffer ( handle ) ; Ok ( term ) } }
Initializes system terminal.
Initializes system terminal .