Skip to content
Myr

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

7 files+47 added−89 removed

modified:src/main.rs+4 added-2 removed
17 unmodified lines
18extern crate num_cpus;19extern crate regex;20extern crate regex_syntax;21extern crate shell_escape;22#[cfg(windows)]23extern crate windows;2223pub mod fshelper;24pub mod lscolors;25mod app;
1 unmodified line
27mod internal;28mod output;29mod walk;3031#[cfg(windows)]32mod windows;3334use std::env;35use std::error::Error;36use std::path::{Path, PathBuf};37use std::sync::Arc;
57 unmodified lines
95 Some("always") => true,96 Some("never") => false,97 _ => atty::is(Stream::Stdout),98 };99100 #[cfg(windows)]101 let colored_output = colored_output && windows::enable_colored_output();102103 let ls_colors = if colored_output {
62 unmodified lines
added: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.89extern crate kernel32;10extern crate winapi;1112use kernel32::{GetStdHandle, GetConsoleMode, SetConsoleMode};13use winapi::{STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE};1415const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004;1617// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example18pub fn enable_colored_output() -> bool {19 unsafe {20 let handle = GetStdHandle(STD_OUTPUT_HANDLE);21 if handle == INVALID_HANDLE_VALUE {22 return false;23 }2425 // 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;3132 // 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.89extern crate kernel32;10extern crate winapi;1112use kernel32::{GetStdHandle, GetConsoleMode, SetConsoleMode};13use winapi::{STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE};1415const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004;1617// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example18pub fn enable_colored_output() -> bool {19 unsafe {20 let handle = GetStdHandle(STD_OUTPUT_HANDLE);21 if handle == INVALID_HANDLE_VALUE {22 return false;23 }2425 // 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;3132 // 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]2name = "windows"3version = "0.0.0"4dependencies = [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]89[[package]]10name = "kernel32-sys"11version = "0.2.2"12source = "registry+https://github.com/rust-lang/crates.io-index"13dependencies = [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]1718[[package]]19name = "winapi"20version = "0.2.8"21source = "registry+https://github.com/rust-lang/crates.io-index"2223[[package]]24name = "winapi-build"25version = "0.1.1"26source = "registry+https://github.com/rust-lang/crates.io-index"2728[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
modified:Cargo.lock+2 added-9 removed
5 unmodified lines
6 "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]2021[[package]]22name = "aho-corasick"
307 unmodified lines
330name = "winapi-build"331version = "0.1.1"332source = "registry+https://github.com/rust-lang/crates.io-index"333333[[package]]334name = "windows"335version = "0.0.0"336dependencies = [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]340334[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 lines
modified:Cargo.toml+2 added-1 removed