ratatui_toolkit/widgets/markdown_widget/widget/methods/git_stats.rs
1//! Git stats setter for MarkdownWidget.
2
3use crate::widgets::markdown_widget::foundation::types::GitStats;
4use crate::widgets::markdown_widget::widget::MarkdownWidget;
5
6impl<'a> MarkdownWidget<'a> {
7 /// Set the git statistics to display in the statusline.
8 ///
9 /// # Arguments
10 ///
11 /// * `stats` - The git statistics (additions, modified, deletions)
12 ///
13 /// # Returns
14 ///
15 /// Self for method chaining.
16 pub fn git_stats(mut self, stats: GitStats) -> Self {
17 self.git_stats = Some(stats);
18 self
19 }
20
21 /// Set the git statistics from an optional value.
22 ///
23 /// This is useful when the git stats may or may not be available,
24 /// such as when fetching from a scroll manager.
25 ///
26 /// # Arguments
27 ///
28 /// * `stats` - Optional git statistics
29 ///
30 /// # Returns
31 ///
32 /// Self for method chaining.
33 pub fn maybe_git_stats(mut self, stats: Option<GitStats>) -> Self {
34 self.git_stats = stats;
35 self
36 }
37
38 /// Set the git statistics from a tuple (additions, modified, deletions).
39 ///
40 /// # Arguments
41 ///
42 /// * `additions` - Lines added
43 /// * `modified` - Files/lines modified
44 /// * `deletions` - Lines deleted
45 ///
46 /// # Returns
47 ///
48 /// Self for method chaining.
49 pub fn git_stats_tuple(mut self, additions: usize, modified: usize, deletions: usize) -> Self {
50 self.git_stats = Some(GitStats {
51 additions,
52 modified,
53 deletions,
54 });
55 self
56 }
57}