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