Fix up vendor for... linux?
This commit is contained in:
parent
b799fedeec
commit
81de013103
114 changed files with 21002 additions and 21002 deletions
128
vendor/crossterm_winapi/examples/coloring_example.rs
vendored
128
vendor/crossterm_winapi/examples/coloring_example.rs
vendored
|
|
@ -1,64 +1,64 @@
|
|||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::{Console, ScreenBuffer};
|
||||
|
||||
#[cfg(windows)]
|
||||
fn set_background_color() -> Result<()> {
|
||||
// background value
|
||||
const BLUE_BACKGROUND: u16 = 0x0010;
|
||||
|
||||
let screen_buffer = ScreenBuffer::current()?;
|
||||
let csbi = screen_buffer.info()?;
|
||||
|
||||
// Notice that the color values are stored in wAttribute.
|
||||
// So wee need to use bitwise operators to check if the values exists or to get current console colors.
|
||||
let attrs = csbi.attributes();
|
||||
let fg_color = attrs & 0x0007;
|
||||
|
||||
// apply the blue background flag to the current attributes
|
||||
let new_color = fg_color | BLUE_BACKGROUND;
|
||||
|
||||
// set the console text attribute to the new color value.
|
||||
Console::from(screen_buffer.handle().clone()).set_text_attribute(new_color)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn set_foreground_color() -> Result<()> {
|
||||
// background value
|
||||
const BLUE_FOREGROUND: u16 = 0x0001;
|
||||
|
||||
let screen_buffer = ScreenBuffer::current()?;
|
||||
let csbi = screen_buffer.info()?;
|
||||
|
||||
// Notice that the color values are stored in wAttribute.
|
||||
// So we need to use bitwise operators to check if the values exists or to get current console colors.
|
||||
let attrs = csbi.attributes();
|
||||
let bg_color = attrs & 0x0070;
|
||||
let mut color = BLUE_FOREGROUND | bg_color;
|
||||
|
||||
// background intensity is a separate value in attrs,
|
||||
// wee need to check if this was applied to the current bg color.
|
||||
if (attrs & 0x0080 as u16) != 0 {
|
||||
color = color | 0x0080 as u16;
|
||||
}
|
||||
|
||||
// set the console text attribute to the new color value.
|
||||
Console::from(screen_buffer.handle().clone()).set_text_attribute(color)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() -> Result<()> {
|
||||
set_background_color()?;
|
||||
set_foreground_color()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::{Console, ScreenBuffer};
|
||||
|
||||
#[cfg(windows)]
|
||||
fn set_background_color() -> Result<()> {
|
||||
// background value
|
||||
const BLUE_BACKGROUND: u16 = 0x0010;
|
||||
|
||||
let screen_buffer = ScreenBuffer::current()?;
|
||||
let csbi = screen_buffer.info()?;
|
||||
|
||||
// Notice that the color values are stored in wAttribute.
|
||||
// So wee need to use bitwise operators to check if the values exists or to get current console colors.
|
||||
let attrs = csbi.attributes();
|
||||
let fg_color = attrs & 0x0007;
|
||||
|
||||
// apply the blue background flag to the current attributes
|
||||
let new_color = fg_color | BLUE_BACKGROUND;
|
||||
|
||||
// set the console text attribute to the new color value.
|
||||
Console::from(screen_buffer.handle().clone()).set_text_attribute(new_color)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn set_foreground_color() -> Result<()> {
|
||||
// background value
|
||||
const BLUE_FOREGROUND: u16 = 0x0001;
|
||||
|
||||
let screen_buffer = ScreenBuffer::current()?;
|
||||
let csbi = screen_buffer.info()?;
|
||||
|
||||
// Notice that the color values are stored in wAttribute.
|
||||
// So we need to use bitwise operators to check if the values exists or to get current console colors.
|
||||
let attrs = csbi.attributes();
|
||||
let bg_color = attrs & 0x0070;
|
||||
let mut color = BLUE_FOREGROUND | bg_color;
|
||||
|
||||
// background intensity is a separate value in attrs,
|
||||
// wee need to check if this was applied to the current bg color.
|
||||
if (attrs & 0x0080 as u16) != 0 {
|
||||
color = color | 0x0080 as u16;
|
||||
}
|
||||
|
||||
// set the console text attribute to the new color value.
|
||||
Console::from(screen_buffer.handle().clone()).set_text_attribute(color)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() -> Result<()> {
|
||||
set_background_color()?;
|
||||
set_foreground_color()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
|
|
|
|||
52
vendor/crossterm_winapi/examples/console.rs
vendored
52
vendor/crossterm_winapi/examples/console.rs
vendored
|
|
@ -1,26 +1,26 @@
|
|||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::ConsoleMode;
|
||||
|
||||
#[cfg(windows)]
|
||||
fn change_console_mode() -> Result<()> {
|
||||
let console_mode = ConsoleMode::new()?;
|
||||
|
||||
// get the current console mode:
|
||||
let _mode: u32 = console_mode.mode()?;
|
||||
|
||||
// set the console mode (not sure if this is an actual value xp)
|
||||
console_mode.set_mode(10)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() -> Result<()> {
|
||||
change_console_mode()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::ConsoleMode;
|
||||
|
||||
#[cfg(windows)]
|
||||
fn change_console_mode() -> Result<()> {
|
||||
let console_mode = ConsoleMode::new()?;
|
||||
|
||||
// get the current console mode:
|
||||
let _mode: u32 = console_mode.mode()?;
|
||||
|
||||
// set the console mode (not sure if this is an actual value xp)
|
||||
console_mode.set_mode(10)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() -> Result<()> {
|
||||
change_console_mode()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
|
|
|
|||
60
vendor/crossterm_winapi/examples/handle.rs
vendored
60
vendor/crossterm_winapi/examples/handle.rs
vendored
|
|
@ -1,30 +1,30 @@
|
|||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::{Handle, HandleType};
|
||||
|
||||
#[cfg(windows)]
|
||||
#[allow(unused_variables)]
|
||||
fn main() -> Result<()> {
|
||||
// see the description of the types to see what they do.
|
||||
let out_put_handle = Handle::new(HandleType::OutputHandle)?;
|
||||
let out_put_handle = Handle::new(HandleType::InputHandle)?;
|
||||
let curr_out_put_handle = Handle::new(HandleType::CurrentOutputHandle)?;
|
||||
let curr_out_put_handle = Handle::new(HandleType::CurrentInputHandle)?;
|
||||
|
||||
// now you have this handle you might want to get the WinAPI `HANDLE` it is wrapping.
|
||||
// you can do this by defencing.
|
||||
|
||||
let handle /*:HANDLE*/ = *out_put_handle;
|
||||
|
||||
// you can also pass you own `HANDLE` to create an instance of `Handle`
|
||||
let handle = unsafe { Handle::from_raw(handle) }; /* winapi::um::winnt::HANDLE */
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::{Handle, HandleType};
|
||||
|
||||
#[cfg(windows)]
|
||||
#[allow(unused_variables)]
|
||||
fn main() -> Result<()> {
|
||||
// see the description of the types to see what they do.
|
||||
let out_put_handle = Handle::new(HandleType::OutputHandle)?;
|
||||
let out_put_handle = Handle::new(HandleType::InputHandle)?;
|
||||
let curr_out_put_handle = Handle::new(HandleType::CurrentOutputHandle)?;
|
||||
let curr_out_put_handle = Handle::new(HandleType::CurrentInputHandle)?;
|
||||
|
||||
// now you have this handle you might want to get the WinAPI `HANDLE` it is wrapping.
|
||||
// you can do this by defencing.
|
||||
|
||||
let handle /*:HANDLE*/ = *out_put_handle;
|
||||
|
||||
// you can also pass you own `HANDLE` to create an instance of `Handle`
|
||||
let handle = unsafe { Handle::from_raw(handle) }; /* winapi::um::winnt::HANDLE */
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::ScreenBuffer;
|
||||
|
||||
#[cfg(windows)]
|
||||
fn print_screen_buffer_information() -> Result<()> {
|
||||
let screen_buffer = ScreenBuffer::current()?;
|
||||
|
||||
// get console screen buffer information
|
||||
let csbi = screen_buffer.info()?;
|
||||
|
||||
println!("cursor post: {:?}", csbi.cursor_pos());
|
||||
println!("attributes: {:?}", csbi.attributes());
|
||||
println!("terminal window dimentions {:?}", csbi.terminal_window());
|
||||
println!("terminal size {:?}", csbi.terminal_size());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn multiple_screen_buffers() -> Result<()> {
|
||||
// create new screen buffer
|
||||
let screen_buffer = ScreenBuffer::create()?;
|
||||
|
||||
// which to this screen buffer
|
||||
screen_buffer.show()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() -> Result<()> {
|
||||
print_screen_buffer_information()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
#![allow(dead_code)]
|
||||
|
||||
#[cfg(windows)]
|
||||
use std::io::Result;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_winapi::ScreenBuffer;
|
||||
|
||||
#[cfg(windows)]
|
||||
fn print_screen_buffer_information() -> Result<()> {
|
||||
let screen_buffer = ScreenBuffer::current()?;
|
||||
|
||||
// get console screen buffer information
|
||||
let csbi = screen_buffer.info()?;
|
||||
|
||||
println!("cursor post: {:?}", csbi.cursor_pos());
|
||||
println!("attributes: {:?}", csbi.attributes());
|
||||
println!("terminal window dimentions {:?}", csbi.terminal_window());
|
||||
println!("terminal size {:?}", csbi.terminal_size());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn multiple_screen_buffers() -> Result<()> {
|
||||
// create new screen buffer
|
||||
let screen_buffer = ScreenBuffer::create()?;
|
||||
|
||||
// which to this screen buffer
|
||||
screen_buffer.show()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() -> Result<()> {
|
||||
print_screen_buffer_information()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
println!("This example is for the Windows platform only.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue