Move 'win' crate back into local module
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This is necessary to publish on crates.io
authored by sharkdp · committed by sharkdp · parent bba5c4f · Browse files · 7 files·+47 added−89 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+47 added−89 removed
- other:+47 added−89 removed
Provenance
- Commit
b3f1e18- Tree
a785576- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
bba5c4f
7 files changed+47 added−89 removed
modified:src/main.rs+4 added-2 removed
17 unmodified lines18 extern crate num_cpus;19 extern crate regex;20 extern crate regex_syntax;21 extern crate shell_escape;22-#[cfg(windows)]23-extern crate windows;22 23 pub mod fshelper;24 pub mod lscolors;25 mod app;1 unmodified line27 mod internal;28 mod output;29 mod walk;30 31+#[cfg(windows)]32+mod windows;33+34 use std::env;35 use std::error::Error;36 use std::path::{Path, PathBuf};37 use std::sync::Arc;57 unmodified lines95 Some("always") => true,96 Some("never") => false,97 _ => atty::is(Stream::Stdout),98 };99+100 #[cfg(windows)]101 let colored_output = colored_output && windows::enable_colored_output();102 103 let ls_colors = if colored_output {62 unmodified linesadded:src/windows.rs+39 added
1+// Copyright (c) 2017 fd developers2+// Licensed under the Apache License, Version 2.03+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>4+// or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,5+// at your option. All files in the project carrying such6+// notice may not be copied, modified, or distributed except7+// according to those terms.8+9+extern crate kernel32;10+extern crate winapi;11+12+use kernel32::{GetStdHandle, GetConsoleMode, SetConsoleMode};13+use winapi::{STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE};14+15+const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004;16+17+// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example18+pub fn enable_colored_output() -> bool {19+ unsafe {20+ let handle = GetStdHandle(STD_OUTPUT_HANDLE);21+ if handle == INVALID_HANDLE_VALUE {22+ return false;23+ }24+25+ // https://docs.microsoft.com/en-us/windows/console/getconsolemode26+ let mut mode = 0;27+ if GetConsoleMode(handle, &mut mode) == 0 {28+ return false;29+ }30+ mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;31+32+ // https://docs.microsoft.com/en-us/windows/console/setconsolemode33+ //34+ // A console consists of an input buffer and one or more screen buffers. ... Setting the35+ // output modes of one screen buffer does not affect the output modes of other screen36+ // buffers.37+ SetConsoleMode(handle, mode) != 038+ }39+}deleted:win/src/lib.rs-39 removed
1-// Copyright (c) 2017 fd developers2-// Licensed under the Apache License, Version 2.03-// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>4-// or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,5-// at your option. All files in the project carrying such6-// notice may not be copied, modified, or distributed except7-// according to those terms.8-9-extern crate kernel32;10-extern crate winapi;11-12-use kernel32::{GetStdHandle, GetConsoleMode, SetConsoleMode};13-use winapi::{STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE};14-15-const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004;16-17-// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example18-pub fn enable_colored_output() -> bool {19- unsafe {20- let handle = GetStdHandle(STD_OUTPUT_HANDLE);21- if handle == INVALID_HANDLE_VALUE {22- return false;23- }24-25- // https://docs.microsoft.com/en-us/windows/console/getconsolemode26- let mut mode = 0;27- if GetConsoleMode(handle, &mut mode) == 0 {28- return false;29- }30- mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;31-32- // https://docs.microsoft.com/en-us/windows/console/setconsolemode33- //34- // A console consists of an input buffer and one or more screen buffers. ... Setting the35- // output modes of one screen buffer does not affect the output modes of other screen36- // buffers.37- SetConsoleMode(handle, mode) != 038- }39-}deleted:win/Cargo.lock-31 removed
1-[root]2-name = "windows"3-version = "0.0.0"4-dependencies = [5- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",6- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",7-]8-9-[[package]]10-name = "kernel32-sys"11-version = "0.2.2"12-source = "registry+https://github.com/rust-lang/crates.io-index"13-dependencies = [14- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",15- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",16-]17-18-[[package]]19-name = "winapi"20-version = "0.2.8"21-source = "registry+https://github.com/rust-lang/crates.io-index"22-23-[[package]]24-name = "winapi-build"25-version = "0.1.1"26-source = "registry+https://github.com/rust-lang/crates.io-index"27-28-[metadata]29-"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"30-"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"31-"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"deleted:win/Cargo.toml-7 removed
1234567[package]name = "windows"version = "0.0.0"
[dependencies]kernel32-sys = "0.2"winapi = "0.2"modified:Cargo.lock+2 added-9 removed
5 unmodified lines6 "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",7 "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)",8 "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",9 "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",10+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",11 "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",12 "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",13 "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",14 "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",15 "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",16 "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",17 "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",17- "windows 0.0.0",18+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",19 ]20 21 [[package]]22 name = "aho-corasick"307 unmodified lines330 name = "winapi-build"331 version = "0.1.1"332 source = "registry+https://github.com/rust-lang/crates.io-index"333 333-[[package]]334-name = "windows"335-version = "0.0.0"336-dependencies = [337- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",338- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",339-]340-334 [metadata]335 "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"336 "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"337 "checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860"39 unmodified linesmodified:Cargo.toml+2 added-1 removed
43 unmodified lines444546474848495051525343 unmodified lines[target.'cfg(all(unix, not(target_os = "redox")))'.dependencies]libc = "0.2"
[target.'cfg(windows)'.dependencies]windows = { path = "win" }kernel32-sys = "0.2"winapi = "0.2"
[dev-dependencies]diff = "0.1"tempdir = "0.3"