diff -Nru rust-console-0.7.7/Cargo.lock rust-console-0.8.0/Cargo.lock --- rust-console-0.7.7/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 +++ rust-console-0.8.0/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 @@ -0,0 +1,136 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clicolors-control" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "console" +version = "0.8.0" +dependencies = [ + "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "memchr" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "regex" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "termios" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" +"checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" +"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" +"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" +"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff -Nru rust-console-0.7.7/Cargo.toml rust-console-0.8.0/Cargo.toml --- rust-console-0.7.7/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ rust-console-0.8.0/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "console" -version = "0.7.7" +version = "0.8.0" authors = ["Armin Ronacher "] description = "A terminal and console abstraction for Rust" homepage = "https://github.com/mitsuhiko/console" @@ -20,9 +20,6 @@ readme = "README.md" keywords = ["cli", "terminal", "colors", "console", "ansi"] license = "MIT" -[dependencies.atty] -version = "0.2.11" - [dependencies.clicolors-control] version = "1.0.0" @@ -30,10 +27,7 @@ version = "1" [dependencies.libc] -version = "0" - -[dependencies.parking_lot] -version = "0" +version = "0.2" [dependencies.regex] version = "1" diff -Nru rust-console-0.7.7/Cargo.toml.orig rust-console-0.8.0/Cargo.toml.orig --- rust-console-0.7.7/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 +++ rust-console-0.8.0/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "console" -version = "0.7.7" +version = "0.8.0" authors = ["Armin Ronacher "] description = "A terminal and console abstraction for Rust" homepage = "https://github.com/mitsuhiko/console" @@ -20,9 +20,6 @@ readme = "README.md" keywords = ["cli", "terminal", "colors", "console", "ansi"] license = "MIT" -[dependencies.atty] -version = "0.2.11" - [dependencies.clicolors-control] version = "1.0.0" @@ -30,10 +27,7 @@ version = "1" [dependencies.libc] -version = "0" - -[dependencies.parking_lot] -version = "0" +version = "0.2" [dependencies.regex] version = "1" diff -Nru rust-console-0.7.7/.cargo_vcs_info.json rust-console-0.8.0/.cargo_vcs_info.json --- rust-console-0.7.7/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rust-console-0.8.0/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +1,5 @@ { "git": { - "sha1": "9f62b487585476f7a5ba85cd6a2b109d6d15a92f" + "sha1": "f7660dbe32842a1a7b5e766b7e8588a5000c0aeb" } } diff -Nru rust-console-0.7.7/debian/cargo-checksum.json rust-console-0.8.0/debian/cargo-checksum.json --- rust-console-0.7.7/debian/cargo-checksum.json 2019-07-20 18:03:35.000000000 +0000 +++ rust-console-0.8.0/debian/cargo-checksum.json 2019-08-29 07:44:10.000000000 +0000 @@ -1 +1 @@ -{"package":"8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628","files":{}} +{"package":"b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242","files":{}} diff -Nru rust-console-0.7.7/debian/changelog rust-console-0.8.0/debian/changelog --- rust-console-0.7.7/debian/changelog 2019-07-20 18:03:35.000000000 +0000 +++ rust-console-0.8.0/debian/changelog 2019-08-29 07:44:10.000000000 +0000 @@ -1,3 +1,9 @@ +rust-console (0.8.0-1) unstable; urgency=medium + + * Package console 0.8.0 from crates.io using debcargo 2.2.10 + + -- Paride Legovini Thu, 29 Aug 2019 07:44:10 +0000 + rust-console (0.7.7-1) unstable; urgency=medium * Package console 0.7.7 from crates.io using debcargo 2.2.10 diff -Nru rust-console-0.7.7/debian/control rust-console-0.8.0/debian/control --- rust-console-0.7.7/debian/control 2019-07-20 18:03:35.000000000 +0000 +++ rust-console-0.8.0/debian/control 2019-08-29 07:44:10.000000000 +0000 @@ -6,12 +6,10 @@ cargo:native , rustc:native , libstd-rust-dev , - librust-atty-0.2+default-dev (>= 0.2.11-~~) , librust-clicolors-control-1+default-dev , librust-encode-unicode-0.3+default-dev , librust-lazy-static-1+default-dev , - librust-libc-0+default-dev , - librust-parking-lot-0+default-dev , + librust-libc-0.2+default-dev , librust-regex-1+default-dev , librust-termios-0.3+default-dev , librust-unicode-width-0.1+default-dev , @@ -34,12 +32,10 @@ Multi-Arch: same Depends: ${misc:Depends}, - librust-atty-0.2+default-dev (>= 0.2.11-~~), librust-clicolors-control-1+default-dev, librust-encode-unicode-0.3+default-dev, librust-lazy-static-1+default-dev, - librust-libc-0+default-dev, - librust-parking-lot-0+default-dev, + librust-libc-0.2+default-dev, librust-regex-1+default-dev, librust-termios-0.3+default-dev, librust-unicode-width-0.1+default-dev, @@ -53,10 +49,10 @@ librust-console+default-dev (= ${binary:Version}), librust-console-0-dev (= ${binary:Version}), librust-console-0+default-dev (= ${binary:Version}), - librust-console-0.7-dev (= ${binary:Version}), - librust-console-0.7+default-dev (= ${binary:Version}), - librust-console-0.7.7-dev (= ${binary:Version}), - librust-console-0.7.7+default-dev (= ${binary:Version}) + librust-console-0.8-dev (= ${binary:Version}), + librust-console-0.8+default-dev (= ${binary:Version}), + librust-console-0.8.0-dev (= ${binary:Version}), + librust-console-0.8.0+default-dev (= ${binary:Version}) Description: Terminal and console abstraction for Rust - Rust source code This package contains the source for the Rust console crate, packaged by debcargo for use with cargo and dh-cargo. diff -Nru rust-console-0.7.7/src/common_term.rs rust-console-0.8.0/src/common_term.rs --- rust-console-0.7.7/src/common_term.rs 2019-01-17 22:01:28.000000000 +0000 +++ rust-console-0.8.0/src/common_term.rs 2019-08-23 22:43:48.000000000 +0000 @@ -25,3 +25,13 @@ pub fn clear_screen(out: &Term) -> io::Result<()> { out.write_str("\r\x1b[2J\r\x1b[H") } + +pub fn show_cursor(out: &Term) -> io::Result<()> { + let esc = "\u{001B}"; + out.write_str(&format!("{}[0H{}[0J{}[?25h", esc, esc, esc)) +} + +pub fn hide_cursor(out: &Term) -> io::Result<()> { + let esc = "\u{001B}"; + out.write_str(&format!("{}[?251", esc)) +} diff -Nru rust-console-0.7.7/src/kb.rs rust-console-0.8.0/src/kb.rs --- rust-console-0.7.7/src/kb.rs 2018-09-11 18:40:07.000000000 +0000 +++ rust-console-0.8.0/src/kb.rs 2019-08-23 22:43:48.000000000 +0000 @@ -11,6 +11,7 @@ ArrowDown, Enter, Escape, + Backspace, Char(char), #[doc(hidden)] __More, diff -Nru rust-console-0.7.7/src/lib.rs rust-console-0.8.0/src/lib.rs --- rust-console-0.7.7/src/lib.rs 2018-12-24 00:03:01.000000000 +0000 +++ rust-console-0.8.0/src/lib.rs 2019-08-23 22:45:18.000000000 +0000 @@ -69,9 +69,7 @@ extern crate winapi; #[macro_use] extern crate lazy_static; -extern crate atty; extern crate clicolors_control; -extern crate parking_lot; extern crate regex; extern crate unicode_width; diff -Nru rust-console-0.7.7/src/term.rs rust-console-0.8.0/src/term.rs --- rust-console-0.7.7/src/term.rs 2019-06-20 08:23:01.000000000 +0000 +++ rust-console-0.8.0/src/term.rs 2019-08-23 22:43:48.000000000 +0000 @@ -1,6 +1,7 @@ +use std::fmt::Display; use std::io; use std::io::Write; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; #[cfg(unix)] use std::os::unix::io::{AsRawFd, RawFd}; @@ -10,7 +11,6 @@ use kb::Key; use clicolors_control; -use parking_lot::Mutex; /// Where the term is writing. #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -152,7 +152,7 @@ #[doc(hidden)] pub fn write_str(&self, s: &str) -> io::Result<()> { match self.inner.buffer { - Some(ref buffer) => buffer.lock().write_all(s.as_bytes()), + Some(ref buffer) => buffer.lock().unwrap().write_all(s.as_bytes()), None => self.write_through(s.as_bytes()), } } @@ -161,7 +161,7 @@ pub fn write_line(&self, s: &str) -> io::Result<()> { match self.inner.buffer { Some(ref mutex) => { - let mut buffer = mutex.lock(); + let mut buffer = mutex.lock().unwrap(); buffer.extend_from_slice(s.as_bytes()); buffer.push(b'\n'); Ok(()) @@ -240,7 +240,7 @@ /// will automatically flush. pub fn flush(&self) -> io::Result<()> { if let Some(ref buffer) = self.inner.buffer { - let mut buffer = buffer.lock(); + let mut buffer = buffer.lock().unwrap(); if !buffer.is_empty() { self.write_through(&buffer[..])?; buffer.clear(); @@ -318,6 +318,24 @@ clear_screen(self) } + /// Set the terminal title + pub fn set_title(&self, title: T) { + if !self.is_term() { + return; + } + set_title(title); + } + + /// Makes cursor visible again + pub fn show_cursor(&self) -> io::Result<()> { + show_cursor(self) + } + + /// Hides cursor + pub fn hide_cursor(&self) -> io::Result<()> { + hide_cursor(self) + } + // helpers fn write_through(&self, bytes: &[u8]) -> io::Result<()> { diff -Nru rust-console-0.7.7/src/unix_term.rs rust-console-0.8.0/src/unix_term.rs --- rust-console-0.7.7/src/unix_term.rs 2019-06-17 15:18:45.000000000 +0000 +++ rust-console-0.8.0/src/unix_term.rs 2019-08-23 22:45:18.000000000 +0000 @@ -1,3 +1,4 @@ +use std::fmt::Display; use std::fs; use std::io; use std::io::{BufRead, BufReader}; @@ -5,7 +6,6 @@ use std::os::unix::io::AsRawFd; use std::str; -use atty; use libc; use termios; @@ -18,12 +18,7 @@ #[inline] pub fn is_a_terminal(out: &Term) -> bool { - let stream = match out.as_raw_fd() { - libc::STDOUT_FILENO => atty::Stream::Stdout, - libc::STDERR_FILENO => atty::Stream::Stderr, - _ => return false, - }; - atty::is(stream) + unsafe { libc::isatty(out.as_raw_fd()) != 0 } } pub fn terminal_size() -> Option<(u16, u16)> { @@ -130,6 +125,7 @@ b"\x1b[B" => Key::ArrowDown, b"\n" | b"\r" => Key::Enter, b"\x1b" => Key::Escape, + b"\x7f" => Key::Backspace, buf => { if let Ok(s) = str::from_utf8(buf) { if let Some(c) = s.chars().next() { @@ -144,3 +140,7 @@ pub fn wants_emoji() -> bool { cfg!(target_os = "macos") } + +pub fn set_title(title: T) { + print!("\x1b]0;{}\x07", title); +} diff -Nru rust-console-0.7.7/src/utils.rs rust-console-0.8.0/src/utils.rs --- rust-console-0.7.7/src/utils.rs 2018-12-23 22:11:30.000000000 +0000 +++ rust-console-0.8.0/src/utils.rs 2019-08-23 22:45:30.000000000 +0000 @@ -4,7 +4,7 @@ use clicolors_control; use regex::{Matches, Regex}; -use unicode_width::UnicodeWidthStr; +use unicode_width::{UnicodeWidthChar, UnicodeWidthStr}; use term::wants_emoji; @@ -614,14 +614,29 @@ match item { (s, false) => { if rv.is_none() { - if s.len() + length > width - tail.len() { + if s.width() + length > width - tail.width() { let ts = iter.current_slice(); - let idx = ts.len() - s.len() + (width - length - tail.len()); + + let mut s_byte = 0; + let mut s_width = 0; + let rest_width = width - tail.width() - length; + for c in s.chars() { + s_byte += c.len_utf8(); + s_width += c.width().unwrap_or(0); + if s_width == rest_width { + break; + } else if s_width > rest_width { + s_byte -= c.len_utf8(); + break; + } + } + + let idx = ts.len() - s.len() + s_byte; let mut buf = ts[..idx].to_string(); buf.push_str(tail); rv = Some(buf); } - length += s.len(); + length += s.width(); } } (s, true) => { @@ -722,6 +737,16 @@ &truncate_str(&s, 10, "..."), &format!("foo {}...", style("bar").red().force_styling(true)) ); + let s = format!("foo {}", style("バー").red().force_styling(true)); + assert_eq!( + &truncate_str(&s, 5, ""), + &format!("foo {}", style("").red().force_styling(true)) + ); + let s = format!("foo {}", style("バー").red().force_styling(true)); + assert_eq!( + &truncate_str(&s, 6, ""), + &format!("foo {}", style("バ").red().force_styling(true)) + ); } #[test] diff -Nru rust-console-0.7.7/src/windows_term.rs rust-console-0.8.0/src/windows_term.rs --- rust-console-0.7.7/src/windows_term.rs 2019-06-17 15:16:51.000000000 +0000 +++ rust-console-0.8.0/src/windows_term.rs 2019-08-23 22:45:18.000000000 +0000 @@ -1,6 +1,10 @@ use std::char; +use std::ffi::OsStr; +use std::fmt::Display; use std::io; +use std::iter::once; use std::mem; +use std::os::windows::ffi::OsStrExt; use std::os::windows::io::AsRawHandle; use std::slice; @@ -10,20 +14,20 @@ use winapi::ctypes::c_void; use winapi::shared::minwindef::DWORD; use winapi::shared::minwindef::MAX_PATH; +use winapi::um::consoleapi::GetConsoleMode; use winapi::um::consoleapi::{GetNumberOfConsoleInputEvents, ReadConsoleInputW}; use winapi::um::fileapi::FILE_NAME_INFO; use winapi::um::handleapi::INVALID_HANDLE_VALUE; use winapi::um::minwinbase::FileNameInfo; use winapi::um::processenv::GetStdHandle; use winapi::um::winbase::GetFileInformationByHandleEx; -use winapi::um::winbase::{STD_INPUT_HANDLE, STD_OUTPUT_HANDLE}; +use winapi::um::winbase::{STD_ERROR_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE}; use winapi::um::wincon::{ FillConsoleOutputCharacterA, GetConsoleScreenBufferInfo, SetConsoleCursorPosition, - CONSOLE_SCREEN_BUFFER_INFO, COORD, INPUT_RECORD, KEY_EVENT, KEY_EVENT_RECORD, + SetConsoleTitleW, CONSOLE_SCREEN_BUFFER_INFO, COORD, INPUT_RECORD, KEY_EVENT, KEY_EVENT_RECORD, }; use winapi::um::winnt::{CHAR, HANDLE, INT, WCHAR}; -use atty; use common_term; use kb::Key; use term::{Term, TermTarget}; @@ -37,11 +41,37 @@ } pub fn is_a_terminal(out: &Term) -> bool { - let stream = match out.target() { - TermTarget::Stdout => atty::Stream::Stdout, - TermTarget::Stderr => atty::Stream::Stderr, + let (fd, others) = match out.target() { + TermTarget::Stdout => (STD_OUTPUT_HANDLE, [STD_INPUT_HANDLE, STD_ERROR_HANDLE]), + TermTarget::Stderr => (STD_ERROR_HANDLE, [STD_INPUT_HANDLE, STD_OUTPUT_HANDLE]), }; - atty::is(stream) + + if unsafe { console_on_any(&[fd]) } { + // False positives aren't possible. If we got a console then + // we definitely have a tty on stdin. + return true; + } + + // At this point, we *could* have a false negative. We can determine that + // this is true negative if we can detect the presence of a console on + // any of the other streams. If another stream has a console, then we know + // we're in a Windows console and can therefore trust the negative. + if unsafe { console_on_any(&others) } { + return false; + } + + msys_tty_on(out) +} + +unsafe fn console_on_any(fds: &[DWORD]) -> bool { + for &fd in fds { + let mut out = 0; + let handle = GetStdHandle(fd); + if GetConsoleMode(handle, &mut out) != 0 { + return true; + } + } + false } pub fn terminal_size() -> Option<(u16, u16)> { @@ -327,3 +357,15 @@ is_msys && is_pty } } + +pub fn set_title(title: T) { + let buffer: Vec = OsStr::new(&format!("{}", title)) + .encode_wide() + .chain(once(0)) + .collect(); + unsafe { + SetConsoleTitleW(buffer.as_ptr()); + } +} + +pub use common_term::{hide_cursor, show_cursor};