msp430-asm: use macro_rules! instead of nightly macro
syntax.
It may be nice, but y'know what's nicer? Building on stable.
This commit is contained in:
parent
0614e17b73
commit
c7402b8dab
@ -1,5 +1,4 @@
|
|||||||
//! Helper library for msp430-asm
|
//! Helper library for msp430-asm
|
||||||
#![feature(decl_macro)]
|
|
||||||
pub mod split_twice {
|
pub mod split_twice {
|
||||||
/// Slices a collection into a beginning, middle, and end, based on two unordered indices
|
/// Slices a collection into a beginning, middle, and end, based on two unordered indices
|
||||||
pub trait SplitTwice<'t> {
|
pub trait SplitTwice<'t> {
|
||||||
@ -63,30 +62,51 @@ pub mod cursor {
|
|||||||
use std::fmt::{Arguments, Display};
|
use std::fmt::{Arguments, Display};
|
||||||
|
|
||||||
/// Moves to the {line}th previous line
|
/// Moves to the {line}th previous line
|
||||||
pub macro previous($line:literal) {
|
#[macro_export]
|
||||||
csi!("{}F", $line)
|
macro_rules! previous {
|
||||||
|
($line:literal) => {
|
||||||
|
csi!("{}F", $line)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Injects a Command Sequence Introducer
|
/// Injects a Command Sequence Introducer
|
||||||
pub macro csi($($t:tt)*) {
|
#[macro_export]
|
||||||
format_args!("\x1b[{}", format_args!($($t)*))
|
macro_rules! csi {
|
||||||
|
($($t:tt)*) => {
|
||||||
|
format_args!("\x1b[{}", format_args!($($t)*))
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the args with a foreground [Color]
|
/// Formats the args with a foreground [Color]
|
||||||
pub macro fg($fg:expr, $($t:tt)*) {
|
#[macro_export]
|
||||||
Colorized::new(Some($fg), None, format_args!($($t)*))
|
macro_rules! fg {
|
||||||
|
($fg:expr, $($t:tt)*) => {
|
||||||
|
Colorized::new(Some($fg), None, format_args!($($t)*))
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the args with a background [Color]
|
/// Formats the args with a background [Color]
|
||||||
pub macro bg($bg:expr, $(t:tt)*) {
|
#[macro_export]
|
||||||
Colorized::new(None, Some($bg), format_args!($($t)*))
|
macro_rules! bg {
|
||||||
|
($bg:expr, $(t:tt)*) => {
|
||||||
|
Colorized::new(None, Some($bg), format_args!($($t)*))
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the args with both a foreground and background [Color]
|
/// Formats the args with both a foreground and background [Color]
|
||||||
pub macro color($fg:expr, $bg:expr, $($t:tt)*) {
|
#[macro_export]
|
||||||
Colorized::new(Some($fg), Some($bg), format_args!($($t)*))
|
macro_rules! color {
|
||||||
|
($fg:expr, $bg:expr, $($t:tt)*) => {
|
||||||
|
Colorized::new(Some($fg), Some($bg), format_args!($($t)*))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub use bg;
|
||||||
|
pub use color;
|
||||||
|
pub use csi;
|
||||||
|
pub use fg;
|
||||||
|
pub use previous;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
#[default]
|
#[default]
|
||||||
|
Loading…
Reference in New Issue
Block a user