mirror of
https://github.com/Xyverle/neutuino.git
synced 2026-06-26 22:23:14 -04:00
remove is_terminal function, same functionality exists in rust standard library
This commit is contained in:
@@ -2,7 +2,6 @@ use std::ffi::{c_int, c_uint, c_ulong, c_ushort};
|
|||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
fn isatty(fd: c_int) -> c_int;
|
|
||||||
fn ioctl(fd: c_int, request: c_ulong, argp: *mut u8) -> c_int;
|
fn ioctl(fd: c_int, request: c_ulong, argp: *mut u8) -> c_int;
|
||||||
fn tcgetattr(fd: c_int, termios_p: *mut Termios) -> c_int;
|
fn tcgetattr(fd: c_int, termios_p: *mut Termios) -> c_int;
|
||||||
fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *mut Termios) -> c_int;
|
fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *mut Termios) -> c_int;
|
||||||
@@ -46,12 +45,6 @@ struct Termios {
|
|||||||
cc: [u8; NCCS],
|
cc: [u8; NCCS],
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if stdout is a terminal
|
|
||||||
#[must_use]
|
|
||||||
pub fn is_terminal() -> bool {
|
|
||||||
unsafe { isatty(1) != 0 }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Enables ANSI support on Windows terminals
|
/// Enables ANSI support on Windows terminals
|
||||||
///
|
///
|
||||||
/// ANSI is on by default on *nix machines but still exists on them for simpler usage
|
/// ANSI is on by default on *nix machines but still exists on them for simpler usage
|
||||||
|
|||||||
@@ -36,19 +36,6 @@ struct ConsoleScreenBufferInfo {
|
|||||||
dwMaximumWindowSizeY: u16,
|
dwMaximumWindowSizeY: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if stdout is a terminal
|
|
||||||
#[must_use]
|
|
||||||
pub fn is_terminal() -> bool {
|
|
||||||
let handle = get_std_handle(STD_OUTPUT_HANDLE);
|
|
||||||
match handle {
|
|
||||||
Ok(handle) => {
|
|
||||||
let mut dwMode = 0;
|
|
||||||
unsafe { GetConsoleMode(handle, &mut dwMode) != 0 }
|
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Enables ANSI support on Windows terminals
|
/// Enables ANSI support on Windows terminals
|
||||||
///
|
///
|
||||||
/// ANSI is on by default on *nix machines but still exists on them for simpler usage
|
/// ANSI is on by default on *nix machines but still exists on them for simpler usage
|
||||||
|
|||||||
Reference in New Issue
Block a user