iced_pancurses/renderer/
text_input.rs1use crate::primitive::Primitive;
2use crate::PancursesRenderer;
3use iced_native::widget::text_input;
4use iced_native::{Font, HorizontalAlignment, Point, Rectangle, VerticalAlignment};
5
6impl text_input::Renderer for PancursesRenderer {
7 fn default_size(&self) -> u16 {
8 3
9 }
10
11 fn draw(
12 &mut self,
13 bounds: Rectangle,
14 src_text_bounds: Rectangle,
15 _cursor_position: Point,
16 _size: u16,
17 placeholder: &str,
18 value: &text_input::Value,
19 _state: &text_input::State,
20 ) -> Primitive {
21 let mut text = value.to_string();
22 if text == "" {
23 text = placeholder.into();
24 }
25 let bounds_text = Rectangle {
26 width: src_text_bounds.width,
27 height: src_text_bounds.height,
28 x: src_text_bounds.x + 1.,
29 y: src_text_bounds.y + 1.,
30 };
31 let prim_text = <Self as iced_native::widget::text::Renderer>::draw(
32 self,
33 bounds_text,
34 &text,
35 1,
36 Font::Default,
37 None,
38 HorizontalAlignment::Left,
39 VerticalAlignment::Top,
40 );
41 Primitive::Group(vec![Primitive::BoxDisplay(bounds), prim_text])
42 }
43}