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

lpenz / ogle / 15798306825

21 Jun 2025 06:06PM UTC coverage: 60.538% (-0.3%) from 60.811%
15798306825

push

github

lpenz
Document term_wrapper; size_checked -> get_width

3 of 14 new or added lines in 2 files covered. (21.43%)

2 existing lines in 2 files now uncovered.

405 of 669 relevant lines covered (60.54%)

1.56 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 is wrapping `console::Term` at the moment, and providing
8
//! singleton functions that do not require an object. We do that by
9
//! wrapping the Term object in a `std::sync::Mutex`.
10
//!
11
//! A side-effect of prividing this interface is that we can change
12
//! the underlying library with (hopefully) no impact on users.
13

14
use console::Term;
15
use std::io::Result;
16
use std::io::Write;
17
use std::sync::LazyLock;
18
use std::sync::Mutex;
19

20
static TERM: LazyLock<Mutex<Term>> = LazyLock::new(|| Mutex::new(Term::stdout()));
×
21

NEW
22
pub fn get_width() -> Option<u16> {
×
NEW
23
    TERM.lock()
×
NEW
24
        .expect("unable to lock TERM")
×
NEW
25
        .size_checked()
×
NEW
26
        .map(|(_, width)| width)
×
UNCOV
27
}
×
28

29
pub fn move_cursor_up(n: usize) -> Result<()> {
×
NEW
30
    TERM.lock().expect("unable to lock TERM").move_cursor_up(n)
×
31
}
×
32

33
pub fn clear_line() -> Result<()> {
×
NEW
34
    TERM.lock().expect("unable to lock TERM").clear_line()
×
35
}
×
36

37
pub fn write_all(buf: &[u8]) -> Result<()> {
×
NEW
38
    TERM.lock().expect("unable to lock TERM").write_all(buf)
×
39
}
×
40

41
pub fn flush() -> Result<()> {
×
NEW
42
    TERM.lock().expect("unable to lock TERM").flush()
×
43
}
×
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