File tree 2 files changed +18
-9
lines changed
2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 1
1
use super :: Scrollable ;
2
+ use crate :: Result ;
2
3
use ratatui:: layout:: Rect ;
3
4
use std:: { fmt, ops:: Deref } ;
4
5
use term_rustdoc:: tree:: Text as StyledText ;
@@ -44,3 +45,14 @@ impl StyledLines {
44
45
parse:: md ( doc)
45
46
}
46
47
}
48
+
49
+ impl ScrollText {
50
+ pub fn new_text ( doc : & str , area : Rect ) -> Result < Self > {
51
+ // TODO:max_windth and text wrap for markdown
52
+ Ok ( Scrollable {
53
+ lines : StyledLines :: new ( doc) ,
54
+ area,
55
+ ..Default :: default ( )
56
+ } )
57
+ }
58
+ }
Original file line number Diff line number Diff line change @@ -60,25 +60,22 @@ impl<Lines: Default> Default for Scrollable<Lines> {
60
60
}
61
61
}
62
62
63
- impl < Lines : Deref < Target = [ TreeLine ] > > Scrollable < Lines > {
64
- pub fn new ( lines : Lines , full : Rect ) -> Result < Self > {
63
+ impl < Lines : Default + Deref < Target = [ TreeLine ] > > Scrollable < Lines > {
64
+ pub fn new ( lines : Lines , area : Rect ) -> Result < Self > {
65
65
let w = lines. as_ref ( ) . iter ( ) . map ( TreeLine :: width) . max ( ) ;
66
66
let max_windth = w. ok_or_else ( || err ! ( "The documentation is empty with no items." ) ) ?;
67
- if full . width < max_windth {
67
+ if area . width < max_windth {
68
68
warn ! (
69
- full . width,
69
+ area . width,
70
70
max_windth, "Outline width exceeds the area width, so lines may be truncated."
71
71
) ;
72
72
}
73
73
74
- let ( start, cursor, select) = Default :: default ( ) ;
75
74
Ok ( Self {
76
75
lines,
77
76
max_windth,
78
- area : full,
79
- start,
80
- cursor,
81
- select,
77
+ area,
78
+ ..Default :: default ( )
82
79
} )
83
80
}
84
81
}
You can’t perform that action at this time.
0 commit comments