Skip to content

Commit b3a70fb

Browse files
committed
Add commands for scrolling region manipulation.
One command sets the scrolling region, the other resets it to be the whole screen.
1 parent b056370 commit b3a70fb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/terminal.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,46 @@ impl Command for ScrollDown {
330330
}
331331
}
332332

333+
/// A command that sets the scrolling region.
334+
///
335+
/// # Notes
336+
///
337+
/// Commands must be executed/queued for execution otherwise they do nothing.
338+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
339+
pub struct SetScrollingRegion(pub u16, pub u16);
340+
341+
impl Command for SetScrollingRegion {
342+
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
343+
write!(f, csi!("{};{}r"), self.0, self.1)?;
344+
Ok(())
345+
}
346+
347+
#[cfg(windows)]
348+
fn execute_winapi(&self) -> io::Result<()> {
349+
unimplemented!("not implemented for winapi");
350+
}
351+
}
352+
353+
/// A command that resets the scrolling region.
354+
///
355+
/// # Notes
356+
///
357+
/// Commands must be executed/queued for execution otherwise they do nothing.
358+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
359+
pub struct ResetScrollingRegion;
360+
361+
impl Command for ResetScrollingRegion {
362+
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
363+
write!(f, csi!("r"))?;
364+
Ok(())
365+
}
366+
367+
#[cfg(windows)]
368+
fn execute_winapi(&self) -> io::Result<()> {
369+
unimplemented!("not implemented for winapi");
370+
}
371+
}
372+
333373
/// A command that clears the terminal screen buffer.
334374
///
335375
/// See the [`ClearType`](enum.ClearType.html) enum.

0 commit comments

Comments
 (0)