Terminal styling and layout widgets for OCaml (tables, trees, panels, colors)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix cursor not restored after Ctrl-C during progress bar

at_exit hooks don't run on SIGINT — the process is killed before they
fire. Install a SIGINT handler that restores the cursor then re-raises
with the default handler so the process exits with the correct signal
status (128+SIGINT).

+13 -1
+13 -1
lib/progress.ml
··· 52 52 let hide_cursor = "\027[?25l" 53 53 let show_cursor = "\027[?25h" 54 54 55 - (* Ensure cursor is restored on exit (handles Ctrl-C, uncaught exceptions) *) 55 + (* Ensure cursor is restored on exit and on SIGINT (Ctrl-C). *) 56 56 let cursor_hidden = ref false 57 57 58 58 let restore_cursor () = ··· 63 63 end 64 64 65 65 let () = at_exit restore_cursor 66 + 67 + let () = 68 + let prev_handler = ref Sys.Signal_default in 69 + prev_handler := 70 + Sys.signal Sys.sigint 71 + (Sys.Signal_handle 72 + (fun signo -> 73 + restore_cursor (); 74 + (* Re-raise with the default handler so the process exits with the 75 + correct signal status (128+signo). *) 76 + Sys.set_signal Sys.sigint !prev_handler; 77 + Unix.kill (Unix.getpid ()) signo)) 66 78 67 79 let render_bar_utf8 ~bar_width ~pct = 68 80 let total_eighths = bar_width * 8 in