i18n_ui 0.2.126

Terminal UI for translation progress with interactive concurrent panels and line-by-line fallback
Documentation
//! Cross-thread interrupt flag shared by the render thread and the caller's signal watcher

use std::sync::{
  Arc,
  atomic::{AtomicBool, Ordering},
};

/// Interrupt handle: the async side sets it, the interactive render stage polls it
///
/// The UI crate stays runtime-agnostic: the caller wires its platform signal (for example
/// `compio_ctrl_c::watch_with`) to [`Interrupt::set`], and the interactive stage then behaves like
/// Ctrl+C was pressed: it restores the terminal, prints the summary, and exits with code 130.
#[derive(Clone)]
pub struct Interrupt(Arc<AtomicBool>);

impl Interrupt {
  pub(crate) fn new() -> Self {
    Self(Arc::new(AtomicBool::new(false)))
  }

  /// Whether an interrupt has been requested
  pub(crate) fn hit(&self) -> bool {
    self.0.load(Ordering::Relaxed)
  }

  /// Request interruption; idempotent
  pub fn set(&self) {
    self.0.store(true, Ordering::Relaxed);
  }
}