@@ -5,7 +5,9 @@ use crate::model::ui_state::LayoutMode;
55use crate :: model:: AppState ;
66use anyhow:: Result ;
77use crossterm:: {
8- event:: { Event , EventStream , KeyCode , KeyEventKind } ,
8+ event:: {
9+ DisableBracketedPaste , EnableBracketedPaste , Event , EventStream , KeyCode , KeyEventKind ,
10+ } ,
911 execute,
1012 terminal:: { disable_raw_mode, enable_raw_mode, EnterAlternateScreen , LeaveAlternateScreen } ,
1113} ;
@@ -33,6 +35,8 @@ impl App {
3335 enable_raw_mode ( ) ?;
3436 let mut stdout = io:: stdout ( ) ;
3537 execute ! ( stdout, EnterAlternateScreen ) ?;
38+ // Enable bracketed paste to detect paste events (does not affect mouse selection copy)
39+ execute ! ( stdout, EnableBracketedPaste ) ?;
3640 // Mouse capture disabled to allow standard copy/paste functionality
3741 let backend = CrosstermBackend :: new ( stdout) ;
3842 let terminal = Terminal :: new ( backend) ?;
@@ -67,6 +71,8 @@ impl App {
6771 enable_raw_mode ( ) ?;
6872 let mut stdout = io:: stdout ( ) ;
6973 execute ! ( stdout, EnterAlternateScreen ) ?;
74+ // Enable bracketed paste to detect paste events (does not affect mouse selection copy)
75+ execute ! ( stdout, EnableBracketedPaste ) ?;
7076 // Mouse capture disabled to allow standard copy/paste functionality
7177 let backend = CrosstermBackend :: new ( stdout) ;
7278 let terminal = Terminal :: new ( backend) ?;
@@ -204,10 +210,6 @@ impl App {
204210
205211 /// Handle terminal events and convert to actions
206212 async fn handle_event ( & mut self , event : Event ) -> Result < bool > {
207- // Only log non-mouse events to reduce noise
208- if !matches ! ( event, Event :: Mouse ( _) ) {
209- tracing:: debug!( "handle_event called with: {:?}" , event) ;
210- }
211213 let mut actions_to_process = Vec :: new ( ) ;
212214
213215 match event {
@@ -395,6 +397,39 @@ impl App {
395397 Event :: Resize ( width, height) => {
396398 actions_to_process. push ( Action :: Resize ( width, height) ) ;
397399 }
400+ Event :: Paste ( pasted) => {
401+ tracing:: debug!( "Event received: paste_len={}" , pasted. len( ) ) ;
402+ // Batch insert pasted text depending on focused panel and mode
403+ match self . state . ui . focus . current_panel {
404+ PanelType :: InteractiveCommand => {
405+ match self . state . command_panel . mode {
406+ crate :: model:: panel_state:: InteractionMode :: Input => {
407+ let actions = self
408+ . state
409+ . command_input_handler
410+ . insert_str ( & mut self . state . command_panel , & pasted) ;
411+ actions_to_process. extend ( actions) ;
412+ self . state . command_renderer . mark_pending_updates ( ) ;
413+ }
414+ crate :: model:: panel_state:: InteractionMode :: ScriptEditor => {
415+ let actions =
416+ crate :: components:: command_panel:: ScriptEditor :: insert_text (
417+ & mut self . state . command_panel ,
418+ & pasted,
419+ ) ;
420+ actions_to_process. extend ( actions) ;
421+ self . state . command_renderer . mark_pending_updates ( ) ;
422+ }
423+ crate :: model:: panel_state:: InteractionMode :: Command => {
424+ // Ignore paste in command mode
425+ }
426+ }
427+ }
428+ _ => {
429+ // Ignore paste in other panels
430+ }
431+ }
432+ }
398433 _ => { }
399434 }
400435
@@ -3357,6 +3392,8 @@ impl App {
33573392 /// Cleanup terminal
33583393 async fn cleanup ( & mut self ) -> Result < ( ) > {
33593394 disable_raw_mode ( ) ?;
3395+ // Disable bracketed paste before leaving alternate screen
3396+ execute ! ( self . terminal. backend_mut( ) , DisableBracketedPaste ) ?;
33603397 execute ! ( self . terminal. backend_mut( ) , LeaveAlternateScreen ) ?;
33613398 // Mouse capture was not enabled, so no need to disable it
33623399 self . terminal . show_cursor ( ) ?;
0 commit comments