From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/output_vt100/.cargo-checksum.json | 1 + vendor/output_vt100/Cargo.lock | 32 ++++++++++++ vendor/output_vt100/Cargo.toml | 25 +++++++++ vendor/output_vt100/LICENSE | 21 ++++++++ vendor/output_vt100/README.md | 43 ++++++++++++++++ vendor/output_vt100/appveyor.yml | 72 ++++++++++++++++++++++++++ vendor/output_vt100/examples/red-hello.rs | 6 +++ vendor/output_vt100/src/lib.rs | 84 +++++++++++++++++++++++++++++++ 8 files changed, 284 insertions(+) create mode 100644 vendor/output_vt100/.cargo-checksum.json create mode 100644 vendor/output_vt100/Cargo.lock create mode 100644 vendor/output_vt100/Cargo.toml create mode 100644 vendor/output_vt100/LICENSE create mode 100644 vendor/output_vt100/README.md create mode 100644 vendor/output_vt100/appveyor.yml create mode 100644 vendor/output_vt100/examples/red-hello.rs create mode 100644 vendor/output_vt100/src/lib.rs (limited to 'vendor/output_vt100') diff --git a/vendor/output_vt100/.cargo-checksum.json b/vendor/output_vt100/.cargo-checksum.json new file mode 100644 index 000000000..dfdd4589f --- /dev/null +++ b/vendor/output_vt100/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.lock":"13468a28e488684fc83a827a1661b5630a28bbf4dc0d3a6a6e3edad81e2d5c95","Cargo.toml":"5efcc64c9c7f677175d9c008ae5b6e22310cd8e865f073eeadaa0c1c3e707ceb","LICENSE":"8c9612877aacfa1b42f5e80b679e6c3c93a7ba2bb99dfaf6e87e200dca4b4e6c","README.md":"8253e236cf431121d4211085f94f6dbf964bd78436b5f23ed178a668a123658a","appveyor.yml":"70ed5d962c451ea9dfc10e8ce4a27bd1ea10091443b86f9702c0d79aa15fda97","examples/red-hello.rs":"7863a30b220a5c2cbc493e3842052ed1b5529781f4a5b858f1d7e13820552cd7","src/lib.rs":"7cce4569f731655d59699cc2620c4947a3139f084dd6faea0cdcab19ef78d234"},"package":"628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"} \ No newline at end of file diff --git a/vendor/output_vt100/Cargo.lock b/vendor/output_vt100/Cargo.lock new file mode 100644 index 000000000..51587ad6f --- /dev/null +++ b/vendor/output_vt100/Cargo.lock @@ -0,0 +1,32 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "output_vt100" +version = "0.1.3" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/vendor/output_vt100/Cargo.toml b/vendor/output_vt100/Cargo.toml new file mode 100644 index 000000000..6b08ff39d --- /dev/null +++ b/vendor/output_vt100/Cargo.toml @@ -0,0 +1,25 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "output_vt100" +version = "0.1.3" +authors = ["Phuntsok Drak-pa "] +description = "Utility to activate escape codes in Windows' CMD and PowerShell" +readme = "README.md" +keywords = ["vt100", "console", "ansi"] +categories = ["development-tools"] +license = "MIT" +repository = "https://github.com/Phundrak/output-vt100-rs" +[dependencies.winapi] +version = "0.3.6" +features = ["winuser", "winbase", "consoleapi", "processenv"] diff --git a/vendor/output_vt100/LICENSE b/vendor/output_vt100/LICENSE new file mode 100644 index 000000000..48b7653f4 --- /dev/null +++ b/vendor/output_vt100/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 rust-derive-builder contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/output_vt100/README.md b/vendor/output_vt100/README.md new file mode 100644 index 000000000..72e45a13e --- /dev/null +++ b/vendor/output_vt100/README.md @@ -0,0 +1,43 @@ +[![crates.io](https://img.shields.io/crates/v/output_vt100.svg?style=flat)](https://crates.io/crates/output_vt100) +[![Released API docs](https://docs.rs/output_vt100/badge.svg)](https://docs.rs/output_vt100) +[![Downloads](https://img.shields.io/crates/d/output_vt100.svg?style=flat)](https://crates.io/crates/output_vt100) +[![MIT Licensed](https://img.shields.io/crates/l/output_vt100.svg?style=flat)](https://crates.io/crates/output_vt100) +[![AppVeyor CI](https://img.shields.io/appveyor/ci/Phundrak/output-vt100-rs.svg?style=flat)](https://ci.appveyor.com/project/Phundrak/output-vt100-rs) +[![Build Status](https://drone.phundrak.com/api/badges/phundrak/output-vt100-rs/status.svg)](https://drone.phundrak.com/phundrak/output-vt100-rs) + +# Output-VT100 + +This simple crates allows developers to enable ANSI escape characters in Windows' console, be it CMD or PowerShell. Its usage is very simple, as shown below: + +```rust +extern crate output_vt100; + +fn main() { + output_vt100::init(); + println!("\x1b[31mThis text is red!\x1b[0m"); +} +``` + +If you wish to ensure the `output_vt100::init()` function is only ran once, you can use the crate [ctor](https://crates.io/crates/ctor). Be aware though it might not be suited for every use case, as explained on the crate’s presentation. + +```rust +extern crate output_vt100; +extern crate ctor; +use ctor::*; + +#[ctor] +fn init_term() { + output_vt100::init(); +} + +fn main() { + println!("\x1b[31mThis text is red!\x1b[0m"); +} +``` + +Not that init panics on error, if you do not wish to panic, use +`output_vt100::try_init` which returns a `Result<(), ()>` + +# Acknowledgements + +A big thank you to [nbouteme](https://github.com/nbouteme) who helped me a lot during the development of this create. diff --git a/vendor/output_vt100/appveyor.yml b/vendor/output_vt100/appveyor.yml new file mode 100644 index 000000000..b8945ed0f --- /dev/null +++ b/vendor/output_vt100/appveyor.yml @@ -0,0 +1,72 @@ +# Appveyor configuration template for Rust using rustup for Rust installation +# https://github.com/starkat99/appveyor-rust + +## Operating System (VM environment) ## + +# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets. +os: Visual Studio 2015 + +## Build Matrix ## +environment: + matrix: + +### MSVC Toolchains ### + # Stable 64-bit MSVC + - channel: stable + target: x86_64-pc-windows-msvc + # Stable 32-bit MSVC + - channel: stable + target: i686-pc-windows-msvc + # Beta 64-bit MSVC + - channel: beta + target: x86_64-pc-windows-msvc + # Beta 32-bit MSVC + - channel: beta + target: i686-pc-windows-msvc + # Nightly 64-bit MSVC + - channel: nightly + target: x86_64-pc-windows-msvc + # Nightly 32-bit MSVC + - channel: nightly + target: i686-pc-windows-msvc + +### GNU Toolchains ### + + # Stable 64-bit GNU + - channel: stable + target: x86_64-pc-windows-gnu + # Stable 32-bit GNU + - channel: stable + target: i686-pc-windows-gnu + # Beta 64-bit GNU + - channel: beta + target: x86_64-pc-windows-gnu + # Beta 32-bit GNU + - channel: beta + target: i686-pc-windows-gnu + # Nightly 64-bit GNU + - channel: nightly + target: x86_64-pc-windows-gnu + # Nightly 32-bit GNU + - channel: nightly + target: i686-pc-windows-gnu + +## Install Script ## +install: + - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init -yv --default-toolchain %channel% --default-host %target% + - set PATH=%PATH%;%USERPROFILE%\.cargo\bin + - rustc -vV + - cargo -vV + +## Build Script ## + +# This prevents the "directory does not contain a project or solution file" +# error. +build: false + +# Uses 'cargo build' to build. AppVeyor cannot run tests on this crate as it +# redirects the console's output, and its state then cannot be retrieved, let +# alone modified. +test_script: + - cargo build --verbose %cargoflags% diff --git a/vendor/output_vt100/examples/red-hello.rs b/vendor/output_vt100/examples/red-hello.rs new file mode 100644 index 000000000..058cc4830 --- /dev/null +++ b/vendor/output_vt100/examples/red-hello.rs @@ -0,0 +1,6 @@ +extern crate output_vt100; + +fn main() { + output_vt100::init(); + println!("\x1b[31mThis text is red!\x1b[0m"); +} diff --git a/vendor/output_vt100/src/lib.rs b/vendor/output_vt100/src/lib.rs new file mode 100644 index 000000000..20338f1e5 --- /dev/null +++ b/vendor/output_vt100/src/lib.rs @@ -0,0 +1,84 @@ +//! # Output-VT100 +//! +//! When you write terminal-based crates, sometimes you might want to use the +//! standard ANSI escaped characters, to display some colors, to display text +//! as bold, italic or whatever. However, you’ve just discovered all your +//! pretty displays that worked like a charm on Linux and Mac look terrible +//! on Windows, because the escaped characters do not work. Rather, they are +//! not activated by default. Then you discover you have to do system calls to +//! Windows directly to activate them in order to get your beautiful text back. +//! What a pain! +//! And this is where this crate comes in action! Simply add it as a dependency +//! for your own crate, and use it like this: +//! ```rust +//! extern crate output_vt100; +//! +//! fn main() { +//! output_vt100::init(); +//! println!("\x1b[31mThis text is red!\x1b[0m"); +//! } +//! ``` +//! And that’s it! By calling it once, you have now activated PowerShell’s and +//! CMD’s support for ANSI’s escaped characters on your Windows builds! And +//! you can leave this line in your Unix builds too, it will simply do nothing. + +use std::fmt; + +#[derive(Debug)] +pub struct InitError; + +impl fmt::Display for InitError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "output-vt100-rs: Could not initialize") + } +} + +impl std::error::Error for InitError {} + +#[cfg(windows)] +pub fn try_init() -> Result<(), InitError> { + use winapi::shared::minwindef::DWORD; + use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode}; + use winapi::um::processenv::GetStdHandle; + use winapi::um::winbase::STD_OUTPUT_HANDLE; + use winapi::um::wincon::{DISABLE_NEWLINE_AUTO_RETURN, ENABLE_VIRTUAL_TERMINAL_PROCESSING}; + + let console_out = unsafe { GetStdHandle(STD_OUTPUT_HANDLE) }; + + let mut state: DWORD = 0; + let mut ret: Result<(), _> = Ok(()); + unsafe { + if GetConsoleMode(console_out, &mut state) == 0 { + ret = Err(InitError); + } + if ret.is_ok() { + state |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + state &= !DISABLE_NEWLINE_AUTO_RETURN; + if SetConsoleMode(console_out, state) == 0 { + ret = Err(InitError); + } + } + } + return ret; +} + +#[cfg(windows)] +pub fn init() { + assert_eq!(try_init().is_ok(), true); +} + +#[cfg(not(windows))] +pub fn try_init() -> Result<(), InitError> { + Ok(()) +} + +#[cfg(not(windows))] +pub fn init() {} + +#[cfg(test)] +mod tests { + #[test] + fn activate_vt100() { + crate::init(); + } +} -- cgit v1.2.3