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

style(paragraph): add documentation for "scroll"'s "offset" #355

Merged
merged 2 commits into from
Aug 19, 2023
Merged
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
11 changes: 10 additions & 1 deletion src/widgets/paragraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ pub struct Wrap {
pub trim: bool,
}

type Horizontal = u16;
type Vertical = u16;

impl<'a> Paragraph<'a> {
pub fn new<T>(text: T) -> Paragraph<'a>
where
Expand Down Expand Up @@ -121,7 +124,13 @@ impl<'a> Paragraph<'a> {
self
}

pub fn scroll(mut self, offset: (u16, u16)) -> Paragraph<'a> {
/// Set the scroll offset for the given paragraph
///
/// Scroll works by starting to render at the given offset, which unlike other scroll function
/// is (y, x)
///
/// There is a RFC for scroll refactoring and unification, see https://github.com/ratatui-org/ratatui/issues/174
pub fn scroll(mut self, offset: (Vertical, Horizontal)) -> Paragraph<'a> {
self.scroll = offset;
self
}
Expand Down