0.15.1 (#381)
This commit is contained in:
parent
f58aca9354
commit
e35d4d2c1c
@ -1,3 +1,10 @@
|
||||
# Version 0.16.0
|
||||
- Make terminal size function work on `/dev/tty` instead of `STDOUT_FILENO`.
|
||||
- Change attribute vector in `ContentStyle` to bitmask.
|
||||
- Add `SetAttributes` command.
|
||||
- Add `Attributes` type, which is a bitfield of enabled attributes.
|
||||
- Remove `exit()`, was useless.
|
||||
|
||||
# Version 0.15.0
|
||||
- Fix CTRL + J key combination. This used to return an ENTER event.
|
||||
- Add a generic implementation `Command` for `&T: Command`. This allows commands to be queued by reference, as well as by value.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "crossterm"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
authors = ["T. Post"]
|
||||
description = "An crossplatform terminal library for manipulating terminals."
|
||||
repository = "https://github.com/crossterm-rs/crossterm"
|
||||
|
@ -55,7 +55,7 @@
|
||||
//! - Colors - [`SetForegroundColor`](style/struct.SetForegroundColor.html),
|
||||
//! [`SetBackgroundColor`](style/struct.SetBackgroundColor.html),
|
||||
//! [`ResetColor`](style/struct.ResetColor.html)
|
||||
//! - Attributes - [`SetAttribute`](style/struct.SetAttribute.html),
|
||||
//! - Attributes - [`SetAttribute`](style/struct.SetAttribute.html), [`SetAttributes`](style/struct.SetAttributes.html),
|
||||
//! [`PrintStyledContent`](style/struct.PrintStyledContent.html)
|
||||
//! - Module `terminal`
|
||||
//! - Scrolling - [`ScrollUp`](terminal/struct.ScrollUp.html),
|
||||
|
@ -66,7 +66,6 @@ macro_rules! Attribute {
|
||||
/// println!("{}", "Negative text".negative());
|
||||
/// ```
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[non_exhaustive]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
|
||||
pub enum Attribute {
|
||||
$(
|
||||
@ -74,9 +73,11 @@ macro_rules! Attribute {
|
||||
$name,
|
||||
)*
|
||||
}
|
||||
|
||||
pub static SGR: &'static[i16] = &[
|
||||
$($sgr,)*
|
||||
];
|
||||
|
||||
impl Attribute {
|
||||
/// Iterates over all the variants of the Attribute enum.
|
||||
pub fn iterator() -> impl Iterator<Item = Attribute> {
|
||||
@ -138,6 +139,8 @@ Attribute! {
|
||||
NotFramedOrEncircled = 54,
|
||||
/// Turns off the `OverLined` attribute.
|
||||
NotOverLined = 55,
|
||||
#[doc(hidden)]
|
||||
__Nonexhaustive = 255,
|
||||
}
|
||||
|
||||
impl Display for Attribute {
|
||||
|
@ -107,11 +107,6 @@ pub fn disable_raw_mode() -> Result<()> {
|
||||
sys::disable_raw_mode()
|
||||
}
|
||||
|
||||
/// Exits the current application.
|
||||
pub fn exit() {
|
||||
sys::exit();
|
||||
}
|
||||
|
||||
/// Returns the terminal size `(columns, rows)`.
|
||||
///
|
||||
/// The top left cell is represented `(1, 1)`.
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! This module provides platform related functions.
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) use self::unix::{disable_raw_mode, enable_raw_mode, exit, is_raw_mode_enabled, size};
|
||||
pub(crate) use self::unix::{disable_raw_mode, enable_raw_mode, is_raw_mode_enabled, size};
|
||||
#[cfg(windows)]
|
||||
pub(crate) use self::windows::{
|
||||
clear, disable_raw_mode, enable_raw_mode, exit, scroll_down, scroll_up, set_size, size,
|
||||
clear, disable_raw_mode, enable_raw_mode, scroll_down, scroll_up, set_size, size,
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
|
@ -2,13 +2,15 @@
|
||||
use std::{io, mem, process, sync::Mutex};
|
||||
|
||||
use libc::{
|
||||
cfmakeraw, ioctl, tcgetattr, tcsetattr, termios as Termios, winsize, STDIN_FILENO,
|
||||
STDOUT_FILENO, TCSANOW, TIOCGWINSZ,
|
||||
cfmakeraw, ioctl, tcgetattr, tcsetattr, termios as Termios, winsize, STDIN_FILENO, TCSANOW,
|
||||
TIOCGWINSZ,
|
||||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::error::{ErrorKind, Result};
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::IntoRawFd;
|
||||
|
||||
lazy_static! {
|
||||
// Some(Termios) -> we're in the raw mode and this is the previous mode
|
||||
@ -20,10 +22,6 @@ pub(crate) fn is_raw_mode_enabled() -> bool {
|
||||
TERMINAL_MODE_PRIOR_RAW_MODE.lock().unwrap().is_some()
|
||||
}
|
||||
|
||||
pub(crate) fn exit() {
|
||||
::std::process::exit(0);
|
||||
}
|
||||
|
||||
#[allow(clippy::identity_conversion)]
|
||||
pub(crate) fn size() -> Result<(u16, u16)> {
|
||||
// http://rosettacode.org/wiki/Terminal_control/Dimensions#Library:_BSD_libc
|
||||
@ -34,8 +32,10 @@ pub(crate) fn size() -> Result<(u16, u16)> {
|
||||
ws_ypixel: 0,
|
||||
};
|
||||
|
||||
let file = File::open("/dev/tty").unwrap();
|
||||
|
||||
if let Ok(true) =
|
||||
wrap_with_result(unsafe { ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size) })
|
||||
wrap_with_result(unsafe { ioctl(file.into_raw_fd(), TIOCGWINSZ.into(), &mut size) })
|
||||
{
|
||||
Ok((size.ws_col, size.ws_row))
|
||||
} else {
|
||||
|
@ -33,10 +33,6 @@ pub(crate) fn disable_raw_mode() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn exit() {
|
||||
::std::process::exit(256);
|
||||
}
|
||||
|
||||
pub(crate) fn size() -> Result<(u16, u16)> {
|
||||
let terminal_size = ScreenBuffer::current()?.info()?.terminal_size();
|
||||
// windows starts counting at 0, unix at 1, add one to replicated unix behaviour.
|
||||
|
Loading…
Reference in New Issue
Block a user