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