Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands for scrolling region manipulation. #916

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,46 @@ impl Command for ScrollDown {
}
}

/// A command that sets the scrolling region.
///
/// # Notes
///
/// Commands must be executed/queued for execution otherwise they do nothing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SetScrollingRegion(pub u16, pub u16);

impl Command for SetScrollingRegion {
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
write!(f, csi!("{};{}r"), self.0, self.1)?;
Ok(())
}

#[cfg(windows)]
fn execute_winapi(&self) -> io::Result<()> {
unimplemented!("not implemented for winapi");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other methods that are unsupported instead return and io::Error with the unsupported error kind and a nice error message. I'd recommend doing the same here and below.

}
}

/// A command that resets the scrolling region.
///
/// # Notes
///
/// Commands must be executed/queued for execution otherwise they do nothing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ResetScrollingRegion;

impl Command for ResetScrollingRegion {
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
write!(f, csi!("r"))?;
Ok(())
}

#[cfg(windows)]
fn execute_winapi(&self) -> io::Result<()> {
unimplemented!("not implemented for winapi");
}
}

/// A command that clears the terminal screen buffer.
///
/// See the [`ClearType`](enum.ClearType.html) enum.
Expand Down
Loading