eclipse-cli 0.13.4

Command-line interface for eclipse
//! The full-screen interface leaves the pointer, the selection and the clipboard to the terminal.
//!
//! This is a rule about what must *not* be in the code, so it is checked against the source text
//! rather than against behaviour: a mouse handler is invisible to a test until the day one comes
//! back, and the day it comes back is the day the terminal stops owning its own selection, its own
//! right-click menu and its own copy — which is the bug this file exists to keep away. The names
//! below are the identifiers the layer was made of, not prose, so a comment may still explain the
//! choice.
//!
//! It lives here rather than in `tui`'s own tests because a guard written in the file it scans
//! would find itself: the words it forbids are the words it carries.

/// The interface's own files, in the directory that holds them.
const TUI: [&str; 3] = ["mod.rs", "app.rs", "view.rs"];

/// Mouse reporting and the clipboard layer, by the names only code would use for them. Prose is
/// deliberately not matched: the files below explain the choice, and an explanation of the thing
/// forbidden is not the thing.
const FORBIDDEN: [&str; 13] = [
    "EnableMouseCapture",
    "DisableMouseCapture",
    "PushMouseReport",
    "PopMouseReport",
    "MouseEvent",
    "MouseButton",
    "MouseEventKind",
    "clipboard::",
    "clipboard_path",
    "osc52",
    "wl-copy",
    "xclip",
    "xsel",
];

#[test]
fn the_interface_never_asks_for_the_pointer_or_touches_a_clipboard() {
    let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/tui");
    let mut read = 0;
    for name in TUI {
        let path = dir.join(name);
        let text = std::fs::read_to_string(&path)
            .unwrap_or_else(|why| panic!("could not read {}: {why}", path.display()));
        read += 1;
        for forbidden in FORBIDDEN {
            assert!(
                !text.contains(forbidden),
                "{} still mentions {forbidden:?}: the terminal owns the selection, its own menu \
                 and its own clipboard, and asking for any of them takes them back",
                path.display()
            );
        }
    }
    assert_eq!(read, TUI.len(), "every file was read");
}