diff options
Diffstat (limited to 'third_party/rust/termion/src/macros.rs')
-rw-r--r-- | third_party/rust/termion/src/macros.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/third_party/rust/termion/src/macros.rs b/third_party/rust/termion/src/macros.rs new file mode 100644 index 0000000000..28370e36b4 --- /dev/null +++ b/third_party/rust/termion/src/macros.rs @@ -0,0 +1,19 @@ +/// Create a CSI-introduced sequence. +macro_rules! csi { + ($( $l:expr ),*) => { concat!("\x1B[", $( $l ),*) }; +} + +/// Derive a CSI sequence struct. +macro_rules! derive_csi_sequence { + ($doc:expr, $name:ident, $value:expr) => { + #[doc = $doc] + #[derive(Copy, Clone)] + pub struct $name; + + impl fmt::Display for $name { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, csi!($value)) + } + } + }; +} |