mirror of
https://github.com/Xyverle/neutuino.git
synced 2026-08-29 10:10:04 -04:00
Add terminal check in examples
This commit is contained in:
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
use neutuino::prelude::*;
|
use neutuino::prelude::*;
|
||||||
use std::{io, time::Duration};
|
use std::{io, time::Duration};
|
||||||
|
use std::io::IsTerminal;
|
||||||
|
|
||||||
fn print_line_style_reset(string: &str) {
|
fn print_line_style_reset(string: &str) {
|
||||||
println!("{}{}{}", string, STYLE_RESET, move_cursor_to_column(0));
|
println!("{}{}{}", string, STYLE_RESET, move_cursor_to_column(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
|
assert!(io::stdout().is_terminal(), "Not running in a terminal");
|
||||||
|
|
||||||
let all_styles = format!("{STYLE_BOLD}{STYLE_ITALIC}{STYLE_UNDERLINE}");
|
let all_styles = format!("{STYLE_BOLD}{STYLE_ITALIC}{STYLE_UNDERLINE}");
|
||||||
|
|
||||||
enable_ansi()?;
|
enable_ansi()?;
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
use neutuino::prelude::*;
|
use neutuino::prelude::*;
|
||||||
use std::{
|
use std::{
|
||||||
io::{self, Write},
|
io::{self, IsTerminal, Write},
|
||||||
thread, time,
|
thread, time,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
|
assert!(io::stdout().is_terminal(), "Not running in a terminal");
|
||||||
|
|
||||||
enable_ansi()?;
|
enable_ansi()?;
|
||||||
|
|
||||||
// makes the terminal raw until this value is dropped
|
// makes the terminal raw until this value is dropped
|
||||||
|
|||||||
Reference in New Issue
Block a user