@@ -40,7 +40,11 @@ struct LayoutRects {
4040 shortcuts_area : Rect ,
4141}
4242
43- fn build_layout ( area : Rect , errors : & Option < String > ) -> LayoutRects {
43+ fn build_layout (
44+ area : Rect ,
45+ errors : & Option < String > ,
46+ textarea : & tui_textarea:: TextArea ,
47+ ) -> LayoutRects {
4448 let main_layout = Layout :: default ( )
4549 . direction ( Direction :: Vertical )
4650 . constraints ( [
@@ -69,27 +73,32 @@ fn build_layout(area: Rect, errors: &Option<String>) -> LayoutRects {
6973 . map ( |s| textwrap:: wrap ( s, left_area. width as usize - 5 ) . len ( ) )
7074 . unwrap_or ( 0 ) ;
7175
76+ let input_text_lines_count = textarea
77+ . lines ( )
78+ . iter ( )
79+ . map ( |s| textwrap:: wrap ( s, left_area. width as usize - 5 ) . len ( ) )
80+ . sum :: < usize > ( ) as u16 ;
7281 // Left panel (chat history + input)
7382 let ( task_area, chat_area, error_area, status_area, input_area) = if error_lines_count > 0 {
7483 let rects = Layout :: default ( )
7584 . direction ( Direction :: Vertical )
7685 . constraints ( [
77- Constraint :: Length ( 4 ) , // Task panel
78- Constraint :: Fill ( 3 ) , // Chat history
79- Constraint :: Max ( u16 :: min ( 10 , error_lines_count as u16 ) ) , // Error message
80- Constraint :: Length ( 1 ) , // Task progress status
81- Constraint :: Length ( 3 ) , // Input field
86+ Constraint :: Length ( 4 ) , // Task panel
87+ Constraint :: Fill ( 3 ) , // Chat history
88+ Constraint :: Max ( 10 . min ( error_lines_count as u16 ) ) , // Error message
89+ Constraint :: Length ( 1 ) , // Task progress status
90+ Constraint :: Length ( 6 . min ( input_text_lines_count ) + 1 ) , // Input field
8291 ] )
8392 . split ( left_area) ;
8493 ( rects[ 0 ] , rects[ 1 ] , rects[ 2 ] , rects[ 3 ] , rects[ 4 ] )
8594 } else {
8695 let rects = Layout :: default ( )
8796 . direction ( Direction :: Vertical )
8897 . constraints ( [
89- Constraint :: Length ( 4 ) , // Task panel
90- Constraint :: Min ( 3 ) , // Chat history
91- Constraint :: Length ( 1 ) , // Task progress status
92- Constraint :: Length ( 3 ) , // Input field
98+ Constraint :: Length ( 4 ) , // Task panel
99+ Constraint :: Min ( 3 ) , // Chat history
100+ Constraint :: Length ( 1 ) , // Task progress status
101+ Constraint :: Length ( 6 . min ( input_text_lines_count ) + 1 ) , // Input field
93102 ] )
94103 . split ( left_area) ;
95104 ( rects[ 0 ] , rects[ 1 ] , Rect :: default ( ) , rects[ 2 ] , rects[ 3 ] )
@@ -126,7 +135,7 @@ impl Widget for &mut App<'_> {
126135
127136 buf. set_style ( area, Style :: default ( ) . bg ( theme. background ) . fg ( theme. text ) ) ;
128137
129- let layout = build_layout ( area, & self . model . last_error ) ;
138+ let layout = build_layout ( area, & self . model . last_error , & self . ui . textarea ) ;
130139
131140 ToolbarWidget . render ( layout. toolbar_area , buf, & theme, & self . config ) ;
132141
@@ -265,6 +274,8 @@ impl Widget for &mut App<'_> {
265274 // Create a TextArea with the App's input text
266275 self . ui . textarea . set_block ( input_block) ;
267276 self . ui . textarea . set_style ( theme. text_style ( ) ) ;
277+ self . ui . textarea . set_wrap ( true ) ;
278+ self . ui . textarea . set_cursor_line_style ( theme. text_style ( ) ) ;
268279 self . ui
269280 . textarea
270281 . set_placeholder_style ( theme. inactive_style ( ) ) ;
0 commit comments