devela 0.28.0

A development substrate of coherence.
Documentation
// devela::sys::os::term::ansi::print
//
//! Defines [`ansi_print`].
//!
//! The function depends on either the `linux` or the `std` feature enabled.
//

#![allow(unused, reason = "± std or linux")]

use devela::{IoResult, IoWrite};

crate::CONST! {
    DOC_ANSI_PRINT = "
It abstracts away specific backend implementations.

# Examples
```
# use devela::{Ansi, AnsiColor3, ansi_print};
ansi_print(&Ansi::ERASE_SCREEN_B);
ansi_print(&Ansi::CURSOR_MOVE3_B(120, 80));
ansi_print(&Ansi::COLORS_BRIGHT_BG_B(AnsiColor3::Blue, AnsiColor3::Black));
```
See also the [`ansi!`][crate::ansi] macro.

";
}

/* print methods */
// In sync with /src/sys/os/print/mod.rs

// std version (overrides linux)
#[doc = crate::_tags!(term platform)]
/// A function to print an ANSI escape `sequence` of bytes to `stdout`
#[doc = crate::_doc_meta!{location("sys/os/term")}]
#[doc = DOC_ANSI_PRINT!()]
#[cfg_attr(nightly_doc, doc(cfg(any(feature = "std", feature = "linux"))))]
#[cfg(feature = "std")]
// #[crate::macro_apply(crate::_std_not_linux_syscall)]
pub fn ansi_print(sequence: &[u8]) -> IoResult<()> {
    crate::Io::stdout().write_all(sequence)
}

// linux version (only if not(std)) (because of the extra conversions)
#[doc = crate::_tags!(term platform)]
/// A function to print an ANSI escape `sequence` of bytes to `stdout`
#[doc = crate::_doc_meta!{location("sys/os/term")}]
#[doc = DOC_ANSI_PRINT!()]
#[cfg_attr(nightly_doc, doc(cfg(any(feature = "std", feature = "linux"))))]
#[crate::macro_apply(crate::_linux_syscall_not_std)]
pub fn ansi_print(sequence: &[u8]) -> IoResult<()> {
    crate::Linux::print_bytes(sequence).map_err(crate::LinuxError::to_io)
}

#[doc(hidden)]
#[doc = crate::_tags!(term platform)]
/// The most efficient print method, exclusive for `std`.
#[doc = crate::_doc_meta!{location("sys/os/term")}]
#[cfg(feature = "std")]
#[cfg_attr(nightly_doc, doc(cfg(feature = "std")))]
pub fn ansi_print_std(sequence: &[u8]) -> IoResult<()> {
    crate::Io::stdout().write_all(sequence)
}

#[doc(hidden)]
#[doc = crate::_tags!(term linux)]
/// The most efficient print method, exclusive for `linux`.
#[doc = crate::_doc_meta!{location("sys/os/term")}]
///
/// This method avoids having to perform extra error conversions.
#[cfg_attr(nightly_doc, doc(cfg(feature = "linux")))]
#[crate::macro_apply(crate::_linux_syscall)]
pub fn ansi_print_linux(sequence: &[u8]) -> crate::LinuxResult<()> {
    crate::Linux::print_bytes(sequence)
}