use smallvec::SmallVec;
use DEC::T as DEC;
use DEC::*;
#[inline]
pub fn normal(id: u8, modifier: Option<u8>, args: &[Option<u32>]) -> Option<DEC> {
match (id, modifier) {
(b'r', None) => DECSTBM(args),
(b'q', Some(b' ')) => DECSCUSR(args),
(b'p', Some(b'!')) => DECSTR(args),
_ => None
}
}
#[inline]
pub fn private(id: u8, modifier: Option<u8>, args: &[Option<u32>]) -> Option<DEC> {
match (id, modifier) {
(b'h', None) => SM(args),
(b'l', None) => RM(args),
(b'~', Some(b'\'')) => DECDC(args),
(b'}', Some(b'\'')) => DECIC(args),
_ => None
}
}
with_args!(SM<args> -> DEC, ?
args.iter().map(|d| d.unwrap_or(0))
.map(Mode::parse)
.collect::<Result<SmallVec<_>, _>>()
.map(Set));
with_args!(RM<args> -> DEC, ?
args.iter().map(|d| d.unwrap_or(0))
.map(Mode::parse)
.collect::<Result<SmallVec<_>, _>>()
.map(Reset));
with_args!(DECDC<1, args> -> DEC,
DeleteColumn(arg!(args[0] => 1)));
with_args!(DECIC<1, args> -> DEC,
InsertColumn(arg!(args[0] => 1)));
with_args!(DECSCUSR<1, args> -> DEC,
CursorStyle(arg!(args[0] => 0) as u8));
with_args!(DECSTBM<2, args> -> DEC,
ScrollRegion {
top: arg!(args[0] => 1).saturating_sub(1),
bottom: arg!(args[1])
.and_then(|v| if v == 0 { None } else { Some(v) })
.map(|b| b.saturating_sub(1)),
});
with_args!(DECSTR -> DEC,
SoftReset);