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

lpenz / ogle / 21598289194

02 Feb 2026 04:25PM UTC coverage: 58.629%. Remained the same
21598289194

push

github

lpenz
Use raw mode in terminal to get keys immediately and avoid echo

Raw mode is enabled when the user stream is constructed, and disabled
when it's dropped.

4 of 9 new or added lines in 2 files covered. (44.44%)

21 existing lines in 3 files now uncovered.

462 of 788 relevant lines covered (58.63%)

1.52 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 [`crossterm`] at the moment.
8

9
use crossterm::{
10
    cursor::{MoveToColumn, MoveUp},
11
    execute,
12
    terminal::{Clear, ClearType, size},
13
};
14
use std::io::Result;
15
use std::io::{Write, stdout};
16

17
/// Returns the width of the terminal
18
///
19
/// Uses [`crossterm::terminal::size`]
20
#[allow(dead_code)]
UNCOV
21
pub fn get_width() -> Option<u16> {
×
UNCOV
22
    size().ok().map(|(w, _)| w)
×
UNCOV
23
}
×
24

25
/// Move the cursor up by `n` lines, if possible.
26
///
27
/// Wraps [`crossterm::cursor::MoveUp`]
28
pub fn move_cursor_up(n: u16) -> Result<()> {
×
UNCOV
29
    execute!(stdout(), MoveUp(n))
×
UNCOV
30
}
×
31

32
/// Clear the current line.
33
///
34
/// Position the cursor at the beginning of the current line.
35
///
36
/// Wraps [`crossterm::terminal::Clear`]
UNCOV
37
pub fn clear_line() -> Result<()> {
×
NEW
38
    execute!(stdout(), Clear(ClearType::CurrentLine))?;
×
NEW
39
    execute!(stdout(), MoveToColumn(0))
×
UNCOV
40
}
×
41

42
/// Attempts to write an entire buffer to the terminal.
43
///
44
/// Wraps regular io functions but also moves the cursor to the first
45
/// column with [`crossterm::cursor::MoveToColumn`]
46
pub fn write_all(buf: &[u8]) -> Result<()> {
×
UNCOV
47
    stdout().write_all(buf)?;
×
UNCOV
48
    stdout().flush()?;
×
NEW
49
    execute!(stdout(), MoveToColumn(0))?;
×
UNCOV
50
    Ok(())
×
UNCOV
51
}
×
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