pub struct Textbox { /* private fields */ }
Implementations§
Source§impl Textbox
impl Textbox
Sourcepub fn bg(self, bg: Color) -> Self
pub fn bg(self, bg: Color) -> Self
Defines background color of textbox
Examples found in repository?
examples/demo.rs (line 40)
14 pub fn ui(&mut self, f: &mut Frame) {
15 let size = f.area();
16
17 let vertical_chunks = Layout::default()
18 .direction(Direction::Vertical)
19 .constraints([Constraint::Length(3), Constraint::Length(3), Constraint::Percentage(100)])
20 .split(size);
21
22 let block1 = Block::default().borders(Borders::ALL).title(format!("Use <TAB> to switch active textbox, <ESC> to exit demo"));
23 f.render_widget(block1, vertical_chunks[0]);
24
25 let textbox = Textbox::default()
26 .render_cursor(self.focused_textbox == 0);
27 let textbox_rect = Rect {
28 x: 1,
29 y: 1,
30 width: 15,
31 height: 1,
32 };
33 f.render_stateful_widget(textbox, textbox_rect, &mut self.textbox_state);
34
35 let block2 = Block::default().borders(Borders::ALL);
36 f.render_widget(block2, vertical_chunks[1]);
37
38 let textbox2 = Textbox::default()
39 .fg(ratatui::style::Color::Yellow)
40 .bg(ratatui::style::Color::Green)
41 .hint_color(ratatui::style::Color::LightGreen)
42 .cursor_color(ratatui::style::Color::DarkGray)
43 .render_cursor(self.focused_textbox == 1);
44 f.render_stateful_widget(textbox2, vertical_chunks[1].inner(ratatui::layout::Margin::new(1, 1)), &mut self.textbox2_state);
45 }
Sourcepub fn fg(self, fg: Color) -> Self
pub fn fg(self, fg: Color) -> Self
Defines foreground color (text color) of textbox
Examples found in repository?
examples/demo.rs (line 39)
14 pub fn ui(&mut self, f: &mut Frame) {
15 let size = f.area();
16
17 let vertical_chunks = Layout::default()
18 .direction(Direction::Vertical)
19 .constraints([Constraint::Length(3), Constraint::Length(3), Constraint::Percentage(100)])
20 .split(size);
21
22 let block1 = Block::default().borders(Borders::ALL).title(format!("Use <TAB> to switch active textbox, <ESC> to exit demo"));
23 f.render_widget(block1, vertical_chunks[0]);
24
25 let textbox = Textbox::default()
26 .render_cursor(self.focused_textbox == 0);
27 let textbox_rect = Rect {
28 x: 1,
29 y: 1,
30 width: 15,
31 height: 1,
32 };
33 f.render_stateful_widget(textbox, textbox_rect, &mut self.textbox_state);
34
35 let block2 = Block::default().borders(Borders::ALL);
36 f.render_widget(block2, vertical_chunks[1]);
37
38 let textbox2 = Textbox::default()
39 .fg(ratatui::style::Color::Yellow)
40 .bg(ratatui::style::Color::Green)
41 .hint_color(ratatui::style::Color::LightGreen)
42 .cursor_color(ratatui::style::Color::DarkGray)
43 .render_cursor(self.focused_textbox == 1);
44 f.render_stateful_widget(textbox2, vertical_chunks[1].inner(ratatui::layout::Margin::new(1, 1)), &mut self.textbox2_state);
45 }
Sourcepub fn hint_color(self, hint: Color) -> Self
pub fn hint_color(self, hint: Color) -> Self
Defines the color of hint_text
Examples found in repository?
examples/demo.rs (line 41)
14 pub fn ui(&mut self, f: &mut Frame) {
15 let size = f.area();
16
17 let vertical_chunks = Layout::default()
18 .direction(Direction::Vertical)
19 .constraints([Constraint::Length(3), Constraint::Length(3), Constraint::Percentage(100)])
20 .split(size);
21
22 let block1 = Block::default().borders(Borders::ALL).title(format!("Use <TAB> to switch active textbox, <ESC> to exit demo"));
23 f.render_widget(block1, vertical_chunks[0]);
24
25 let textbox = Textbox::default()
26 .render_cursor(self.focused_textbox == 0);
27 let textbox_rect = Rect {
28 x: 1,
29 y: 1,
30 width: 15,
31 height: 1,
32 };
33 f.render_stateful_widget(textbox, textbox_rect, &mut self.textbox_state);
34
35 let block2 = Block::default().borders(Borders::ALL);
36 f.render_widget(block2, vertical_chunks[1]);
37
38 let textbox2 = Textbox::default()
39 .fg(ratatui::style::Color::Yellow)
40 .bg(ratatui::style::Color::Green)
41 .hint_color(ratatui::style::Color::LightGreen)
42 .cursor_color(ratatui::style::Color::DarkGray)
43 .render_cursor(self.focused_textbox == 1);
44 f.render_stateful_widget(textbox2, vertical_chunks[1].inner(ratatui::layout::Margin::new(1, 1)), &mut self.textbox2_state);
45 }
Sourcepub fn cursor_color(self, cursor: Color) -> Self
pub fn cursor_color(self, cursor: Color) -> Self
Defines the color of cursor
Examples found in repository?
examples/demo.rs (line 42)
14 pub fn ui(&mut self, f: &mut Frame) {
15 let size = f.area();
16
17 let vertical_chunks = Layout::default()
18 .direction(Direction::Vertical)
19 .constraints([Constraint::Length(3), Constraint::Length(3), Constraint::Percentage(100)])
20 .split(size);
21
22 let block1 = Block::default().borders(Borders::ALL).title(format!("Use <TAB> to switch active textbox, <ESC> to exit demo"));
23 f.render_widget(block1, vertical_chunks[0]);
24
25 let textbox = Textbox::default()
26 .render_cursor(self.focused_textbox == 0);
27 let textbox_rect = Rect {
28 x: 1,
29 y: 1,
30 width: 15,
31 height: 1,
32 };
33 f.render_stateful_widget(textbox, textbox_rect, &mut self.textbox_state);
34
35 let block2 = Block::default().borders(Borders::ALL);
36 f.render_widget(block2, vertical_chunks[1]);
37
38 let textbox2 = Textbox::default()
39 .fg(ratatui::style::Color::Yellow)
40 .bg(ratatui::style::Color::Green)
41 .hint_color(ratatui::style::Color::LightGreen)
42 .cursor_color(ratatui::style::Color::DarkGray)
43 .render_cursor(self.focused_textbox == 1);
44 f.render_stateful_widget(textbox2, vertical_chunks[1].inner(ratatui::layout::Margin::new(1, 1)), &mut self.textbox2_state);
45 }
Sourcepub fn render_cursor(self, render: bool) -> Self
pub fn render_cursor(self, render: bool) -> Self
Defines the visibility of cursor
Examples found in repository?
examples/demo.rs (line 26)
14 pub fn ui(&mut self, f: &mut Frame) {
15 let size = f.area();
16
17 let vertical_chunks = Layout::default()
18 .direction(Direction::Vertical)
19 .constraints([Constraint::Length(3), Constraint::Length(3), Constraint::Percentage(100)])
20 .split(size);
21
22 let block1 = Block::default().borders(Borders::ALL).title(format!("Use <TAB> to switch active textbox, <ESC> to exit demo"));
23 f.render_widget(block1, vertical_chunks[0]);
24
25 let textbox = Textbox::default()
26 .render_cursor(self.focused_textbox == 0);
27 let textbox_rect = Rect {
28 x: 1,
29 y: 1,
30 width: 15,
31 height: 1,
32 };
33 f.render_stateful_widget(textbox, textbox_rect, &mut self.textbox_state);
34
35 let block2 = Block::default().borders(Borders::ALL);
36 f.render_widget(block2, vertical_chunks[1]);
37
38 let textbox2 = Textbox::default()
39 .fg(ratatui::style::Color::Yellow)
40 .bg(ratatui::style::Color::Green)
41 .hint_color(ratatui::style::Color::LightGreen)
42 .cursor_color(ratatui::style::Color::DarkGray)
43 .render_cursor(self.focused_textbox == 1);
44 f.render_stateful_widget(textbox2, vertical_chunks[1].inner(ratatui::layout::Margin::new(1, 1)), &mut self.textbox2_state);
45 }
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Textbox
impl RefUnwindSafe for Textbox
impl Send for Textbox
impl Sync for Textbox
impl Unpin for Textbox
impl UnwindSafe for Textbox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more