@@ -475,7 +475,9 @@ pub struct App {
475475 total_samples : u64 ,
476476 running : bool ,
477477 paused : bool ,
478+ paused_elapsed : Option < Duration > ,
478479 last_draw : Instant ,
480+ last_click : Option < ( Instant , u16 , u16 ) > ,
479481 include_internal : bool ,
480482
481483 // Selection state
@@ -543,7 +545,9 @@ impl App {
543545 total_samples : 0 ,
544546 running : true ,
545547 paused : false ,
548+ paused_elapsed : None ,
546549 last_draw : Instant :: now ( ) ,
550+ last_click : None ,
547551 include_internal,
548552 selected_row : 0 ,
549553 scroll_offset : 0 ,
@@ -627,7 +631,9 @@ impl App {
627631 total_samples : total_samples as u64 ,
628632 running : true ,
629633 paused : true , // Static mode is always "paused"
634+ paused_elapsed : None ,
630635 last_draw : Instant :: now ( ) ,
636+ last_click : None ,
631637 include_internal : false ,
632638 selected_row : 0 ,
633639 scroll_offset : 0 ,
@@ -756,7 +762,11 @@ impl App {
756762 let ctrl = mouse. modifiers . contains ( KeyModifiers :: CONTROL ) ;
757763 match mouse. kind {
758764 MouseEventKind :: Down ( crossterm:: event:: MouseButton :: Left ) => {
759- self . handle_click ( mouse. column , mouse. row ) ;
765+ if self . is_double_click ( mouse. column , mouse. row ) {
766+ self . chart_visible = !self . chart_visible ;
767+ } else {
768+ self . handle_click ( mouse. column , mouse. row ) ;
769+ }
760770 needs_redraw = true ;
761771 }
762772 MouseEventKind :: ScrollUp => {
@@ -1088,7 +1098,14 @@ impl App {
10881098 // Global controls
10891099 KeyCode :: Char ( 'c' ) if ctrl => self . running = false ,
10901100 KeyCode :: Char ( 'q' ) | KeyCode :: Esc => self . running = false ,
1091- KeyCode :: Char ( 'p' ) if !self . is_static ( ) => self . paused = !self . paused ,
1101+ KeyCode :: Char ( 'p' ) if !self . is_static ( ) => {
1102+ self . paused = !self . paused ;
1103+ if self . paused {
1104+ self . paused_elapsed = Some ( self . start_time . elapsed ( ) ) ;
1105+ } else {
1106+ self . paused_elapsed = None ;
1107+ }
1108+ }
10921109 KeyCode :: Tab => {
10931110 self . focus = match self . focus {
10941111 Focus :: Table => Focus :: Chart ,
@@ -1300,6 +1317,23 @@ impl App {
13001317 }
13011318 }
13021319
1320+ fn is_double_click ( & mut self , x : u16 , y : u16 ) -> bool {
1321+ let now = Instant :: now ( ) ;
1322+ let is_double = self
1323+ . last_click
1324+ . map ( |( last_time, last_x, last_y) | {
1325+ now. duration_since ( last_time) <= Duration :: from_millis ( 400 )
1326+ && last_x == x
1327+ && last_y == y
1328+ } )
1329+ . unwrap_or ( false ) ;
1330+ self . last_click = Some ( ( now, x, y) ) ;
1331+ if is_double {
1332+ self . last_click = None ;
1333+ }
1334+ is_double
1335+ }
1336+
13031337 // Getters for UI
13041338 pub fn total_samples ( & self ) -> u64 {
13051339 self . total_samples
@@ -1788,6 +1822,8 @@ impl App {
17881822 pub fn elapsed ( & self ) -> Duration {
17891823 if self . is_static ( ) {
17901824 Duration :: from_secs_f64 ( self . static_duration_secs )
1825+ } else if let Some ( elapsed) = self . paused_elapsed {
1826+ elapsed
17911827 } else {
17921828 self . start_time . elapsed ( )
17931829 }
@@ -1797,6 +1833,8 @@ impl App {
17971833 pub fn elapsed_secs ( & self ) -> f64 {
17981834 if self . is_static ( ) {
17991835 self . static_duration_secs
1836+ } else if let Some ( elapsed) = self . paused_elapsed {
1837+ elapsed. as_secs_f64 ( )
18001838 } else {
18011839 self . start_time . elapsed ( ) . as_secs_f64 ( )
18021840 }
0 commit comments