• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lpenz / ogle / 21596462741

02 Feb 2026 03:34PM UTC coverage: 59.173% (-0.2%) from 59.326%
21596462741

push

github

lpenz
user_wrapper: ignore errors while sending key thorugh the channel

The error could come in a race when the thread was already being dropped.

Also: no longer drop user in engine, it's not necessary anymore and it
was actually enlarging the window of the race mentioned above.

0 of 4 new or added lines in 1 file covered. (0.0%)

11 existing lines in 2 files now uncovered.

458 of 774 relevant lines covered (59.17%)

1.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/term_wrapper.rs
1
// Copyright (C) 2025 Leandro Lisboa Penz <lpenz@lpenz.org>
2
// This file is subject to the terms and conditions defined in
3
// file 'LICENSE', which is part of this source code package.
4

5
//! Wrapper for low-level terminal manipulation.
6
//!
7
//! This wraps [`console::Term`] at the moment, and provides singleton
8
//! functions that do not require an object. We do that by wrapping
9
//! the Term object in a [`std::sync::Mutex`].
10
//!
11
//! A side-effect of this style of interface is that we can change the
12
//! underlying library with (hopefully) no impact on users.
13

14
use crossterm::{
15
    cursor::MoveUp,
16
    execute,
17
    terminal::{Clear, ClearType, size},
18
};
19
use std::io::Result;
20
use std::io::{Write, stdout};
21

22
/// Returns the width of the terminal
23
///
24
/// Uses [`console::Term::size_checked`]
25
#[allow(dead_code)]
26
pub fn get_width() -> Option<u16> {
×
27
    size().ok().map(|(w, _)| w)
×
28
}
×
29

30
/// Move the cursor up by `n` lines, if possible.
31
///
32
/// Wraps [`console::Term::move_cursor_up`]
UNCOV
33
pub fn move_cursor_up(n: u16) -> Result<()> {
×
UNCOV
34
    execute!(stdout(), MoveUp(n))
×
UNCOV
35
}
×
36

37
/// Clear the current line.
38
///
39
/// Position the cursor at the beginning of the current line.
40
///
41
/// Wraps [`console::Term::clear_line`]
UNCOV
42
pub fn clear_line() -> Result<()> {
×
UNCOV
43
    execute!(stdout(), Clear(ClearType::CurrentLine))
×
UNCOV
44
}
×
45

46
/// Attempts to write an entire buffer to the terminal.
47
///
48
/// Wraps [`console::Term::write_all`]
UNCOV
49
pub fn write_all(buf: &[u8]) -> Result<()> {
×
UNCOV
50
    stdout().write_all(buf)?;
×
UNCOV
51
    stdout().flush()?;
×
52
    Ok(())
×
53
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc