1
1
use crate :: {
2
2
buffer:: Buffer ,
3
3
layout:: { Position , Rect } ,
4
- widgets:: { StatefulWidget , StatefulWidgetRef , Widget , WidgetRef } ,
4
+ widgets:: { StatefulWidget , Widget } ,
5
5
} ;
6
6
7
7
/// A consistent view into the terminal state for rendering a single frame.
@@ -14,7 +14,7 @@ use crate::{
14
14
/// to the terminal. This avoids drawing redundant cells.
15
15
///
16
16
/// [`Buffer`]: crate::buffer::Buffer
17
- /// [`Terminal::draw`]: crate::Terminal::draw
17
+ /// [`Terminal::draw`]: crate::terminal:: Terminal::draw
18
18
#[ derive( Debug , Hash ) ]
19
19
pub struct Frame < ' a > {
20
20
/// Where should the cursor be after drawing this frame?
@@ -37,7 +37,7 @@ pub struct Frame<'a> {
37
37
/// [`Terminal::draw`] call have been applied. Therefore, it is only valid until the next call to
38
38
/// [`Terminal::draw`].
39
39
///
40
- /// [`Terminal::draw`]: crate::Terminal::draw
40
+ /// [`Terminal::draw`]: crate::terminal:: Terminal::draw
41
41
#[ derive( Debug , Clone , Eq , PartialEq , Hash ) ]
42
42
pub struct CompletedFrame < ' a > {
43
43
/// The buffer that was used to draw the last frame.
@@ -96,32 +96,6 @@ impl Frame<'_> {
96
96
widget. render ( area, self . buffer ) ;
97
97
}
98
98
99
- /// Render a [`WidgetRef`] to the current buffer using [`WidgetRef::render_ref`].
100
- ///
101
- /// Usually the area argument is the size of the current frame or a sub-area of the current
102
- /// frame (which can be obtained using [`Layout`] to split the total area).
103
- ///
104
- /// # Example
105
- ///
106
- /// ```rust
107
- /// # #[cfg(feature = "unstable-widget-ref")] {
108
- /// # use ratatui::{backend::TestBackend, Terminal};
109
- /// # let backend = TestBackend::new(5, 5);
110
- /// # let mut terminal = Terminal::new(backend).unwrap();
111
- /// # let mut frame = terminal.get_frame();
112
- /// use ratatui::{layout::Rect, widgets::Block};
113
- ///
114
- /// let block = Block::new();
115
- /// let area = Rect::new(0, 0, 5, 5);
116
- /// frame.render_widget_ref(&block, area);
117
- /// # }
118
- /// ```
119
- #[ allow( clippy:: needless_pass_by_value) ]
120
- #[ instability:: unstable( feature = "widget-ref" ) ]
121
- pub fn render_widget_ref < W : WidgetRef > ( & mut self , widget : W , area : Rect ) {
122
- widget. render_ref ( area, self . buffer ) ;
123
- }
124
-
125
99
/// Render a [`StatefulWidget`] to the current buffer using [`StatefulWidget::render`].
126
100
///
127
101
/// Usually the area argument is the size of the current frame or a sub-area of the current
@@ -156,53 +130,16 @@ impl Frame<'_> {
156
130
widget. render ( area, self . buffer , state) ;
157
131
}
158
132
159
- /// Render a [`StatefulWidgetRef`] to the current buffer using
160
- /// [`StatefulWidgetRef::render_ref`].
161
- ///
162
- /// Usually the area argument is the size of the current frame or a sub-area of the current
163
- /// frame (which can be obtained using [`Layout`] to split the total area).
164
- ///
165
- /// The last argument should be an instance of the [`StatefulWidgetRef::State`] associated to
166
- /// the given [`StatefulWidgetRef`].
167
- ///
168
- /// # Example
169
- ///
170
- /// ```rust
171
- /// # #[cfg(feature = "unstable-widget-ref")] {
172
- /// # use ratatui::{backend::TestBackend, Terminal};
173
- /// # let backend = TestBackend::new(5, 5);
174
- /// # let mut terminal = Terminal::new(backend).unwrap();
175
- /// # let mut frame = terminal.get_frame();
176
- /// use ratatui::{
177
- /// layout::Rect,
178
- /// widgets::{List, ListItem, ListState},
179
- /// };
180
- ///
181
- /// let mut state = ListState::default().with_selected(Some(1));
182
- /// let list = List::new(vec![ListItem::new("Item 1"), ListItem::new("Item 2")]);
183
- /// let area = Rect::new(0, 0, 5, 5);
184
- /// frame.render_stateful_widget_ref(&list, area, &mut state);
185
- /// # }
186
- /// ```
187
- #[ allow( clippy:: needless_pass_by_value) ]
188
- #[ instability:: unstable( feature = "widget-ref" ) ]
189
- pub fn render_stateful_widget_ref < W > ( & mut self , widget : W , area : Rect , state : & mut W :: State )
190
- where
191
- W : StatefulWidgetRef ,
192
- {
193
- widget. render_ref ( area, self . buffer , state) ;
194
- }
195
-
196
133
/// After drawing this frame, make the cursor visible and put it at the specified (x, y)
197
134
/// coordinates. If this method is not called, the cursor will be hidden.
198
135
///
199
136
/// Note that this will interfere with calls to [`Terminal::hide_cursor`],
200
137
/// [`Terminal::show_cursor`], and [`Terminal::set_cursor_position`]. Pick one of the APIs and
201
138
/// stick with it.
202
139
///
203
- /// [`Terminal::hide_cursor`]: crate::Terminal::hide_cursor
204
- /// [`Terminal::show_cursor`]: crate::Terminal::show_cursor
205
- /// [`Terminal::set_cursor_position`]: crate::Terminal::set_cursor_position
140
+ /// [`Terminal::hide_cursor`]: crate::terminal:: Terminal::hide_cursor
141
+ /// [`Terminal::show_cursor`]: crate::terminal:: Terminal::show_cursor
142
+ /// [`Terminal::set_cursor_position`]: crate::terminal:: Terminal::set_cursor_position
206
143
pub fn set_cursor_position < P : Into < Position > > ( & mut self , position : P ) {
207
144
self . cursor_position = Some ( position. into ( ) ) ;
208
145
}
@@ -214,9 +151,9 @@ impl Frame<'_> {
214
151
/// [`Terminal::show_cursor`], and [`Terminal::set_cursor_position`]. Pick one of the APIs and
215
152
/// stick with it.
216
153
///
217
- /// [`Terminal::hide_cursor`]: crate::Terminal::hide_cursor
218
- /// [`Terminal::show_cursor`]: crate::Terminal::show_cursor
219
- /// [`Terminal::set_cursor_position`]: crate::Terminal::set_cursor_position
154
+ /// [`Terminal::hide_cursor`]: crate::terminal:: Terminal::hide_cursor
155
+ /// [`Terminal::show_cursor`]: crate::terminal:: Terminal::show_cursor
156
+ /// [`Terminal::set_cursor_position`]: crate::terminal:: Terminal::set_cursor_position
220
157
#[ deprecated = "the method set_cursor_position indicates more clearly what about the cursor to set" ]
221
158
pub fn set_cursor ( & mut self , x : u16 , y : u16 ) {
222
159
self . set_cursor_position ( Position { x, y } ) ;
0 commit comments