mirror of
https://github.com/Xyverle/neutuino.git
synced 2026-06-26 22:23:14 -04:00
cargo fmt, delete random c file
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
|
||||
pub mod os;
|
||||
pub mod ansi;
|
||||
pub mod os;
|
||||
|
||||
@@ -46,7 +46,8 @@ struct Termios {
|
||||
cc: [u8; NCCS],
|
||||
}
|
||||
|
||||
#[must_use] pub fn is_terminal() -> bool {
|
||||
#[must_use]
|
||||
pub fn is_terminal() -> bool {
|
||||
unsafe { isatty(1) != 0 }
|
||||
}
|
||||
|
||||
@@ -85,14 +86,14 @@ pub fn disable_raw_mode() -> io::Result<()> {
|
||||
|
||||
fn get_attributes(fd: c_int, termios: &mut Termios) -> io::Result<()> {
|
||||
if unsafe { tcgetattr(fd, &raw mut *termios) } != 0 {
|
||||
return Err(io::Error::last_os_error())
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_attributes(fd: c_int, termios: &mut Termios) -> io::Result<()> {
|
||||
if unsafe { tcsetattr(fd, 0, std::ptr::from_mut(termios)) } != 0 {
|
||||
return Err(io::Error::last_os_error())
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 4;
|
||||
const ENABLE_ECHO_INPUT: u32 = 4;
|
||||
const ENABLE_LINE_INPUT: u32 = 2;
|
||||
const ENABLE_PROCESSED_INPUT: u32 = 1;
|
||||
const INVALID_HANDLE_VALUE: usize = usize::MAX-1;
|
||||
const INVALID_HANDLE_VALUE: usize = usize::MAX - 1;
|
||||
|
||||
unsafe extern "system" {
|
||||
fn GetStdHandle(nStdHandle: u32) -> usize;
|
||||
@@ -43,7 +43,7 @@ pub fn is_terminal() -> bool {
|
||||
Ok(handle) => {
|
||||
let mut dwMode = 0;
|
||||
return unsafe { GetConsoleMode(handle, &mut dwMode) != 0 };
|
||||
},
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
13
test.c
13
test.c
@@ -1,13 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int main() {
|
||||
printf("ECHO: 0x%x\n", ECHO);
|
||||
printf("ICANON: 0x%x\n", ICANON);
|
||||
printf("ISIG: 0x%x\n", ISIG);
|
||||
|
||||
printf("\nNCCS: 0x%x\n", NCCS);
|
||||
printf("TIOCFWINSZ: 0x%x\n", TIOCGWINSZ);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user