Skip to content

Commit

Permalink
style(paragraph): add documentation for "scroll"'s "offset" (#355)
Browse files Browse the repository at this point in the history
* style(paragraph): add documentation for "scroll"'s "offset"

* style(paragraph): add more text to the scroll doc-comment
  • Loading branch information
hasezoey committed Aug 19, 2023
1 parent b6b2da5 commit ab5e616
Showing 1 changed file with 10 additions and 1 deletion.
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

0 comments on commit ab5e616

Please sign in to comment.