<commit_before>use ncurses as nc;
use std::char;

pub fn mvrel(rel_y: i32, rel_x: i32) {
    wmvrel(nc::stdscr(), rel_y, rel_x);
}

pub fn wmvrel(window: nc::WINDOW, rel_y: i32, rel_x: i32) {
    let mut y = 0;
    let mut x = 0;
    nc::getyx(window, &mut y, &mut x);
    nc::wmove(window, y + rel_y, x + rel_x);
}

pub fn getstring() -> String {
    wgetstring(nc::stdscr())
}

pub fn wgetstring(window: nc::WINDOW) -> String {
    nc::noecho();

    let mut string = String::with_capacity(32);
    let mut pos_history = Vec::new();

    let mut y = 0;
    let mut x = 0;

    nc::getyx(window, &mut y, &mut x);
    pos_history.push((y, x));

    let mut ch = nc::wgetch(window);
    while ch != '\n' as i32 && ch != '\r' as i32 {
        if ch == 127 {
            if let Some((y, x)) = pos_history.pop() {
                nc::mvwdelch(window, y, x);
                string.pop();
            }
        }
        else if let Some(c) = char::from_u32(ch as u32) {
            nc::getyx(window, &mut y, &mut x);
            pos_history.push((y, x));
            string.push(c);
            nc::wechochar(window, ch as u32);
        }
        ch = nc::wgetch(window);
    }

    string.shrink_to_fit();
    string
}

pub fn getsecretstring() -> String {
    wgetsecretstring(nc::stdscr())
}

pub fn wgetsecretstring(window: nc::WINDOW) -> String {
    nc::noecho();
    let mut string = String::with_capacity(32);

    let mut ch = nc::wgetch(window);
    while ch != '\n' as i32 && ch != '\r' as i32 {
        if ch == 127 {
            string.pop();
        }
        else if let Some(c) = char::from_u32(ch as u32) {
            string.push(c);
        }
        ch = nc::wgetch(window);
    }

    string.shrink_to_fit();
    string
}

pub fn getchoice() -> i32 {
    wgetchoice(nc::stdscr())
}

pub fn wgetchoice(window: nc::WINDOW) -> i32 {
    wgetstring(window).trim().parse::<i32>().unwrap_or(-1)
}
<commit_msg>Fixed typo<commit_after>use ncurses as nc;
use std::char;

pub fn mvrel(rel_y: i32, rel_x: i32) {
    wmvrel(nc::stdscr(), rel_y, rel_x);
}

pub fn wmvrel(window: nc::WINDOW, rel_y: i32, rel_x: i32) {
    let mut y = 0;
    let mut x = 0;
    nc::getyx(window, &mut y, &mut x);
    nc::wmove(window, y + rel_y, x + rel_x);
}

pub fn getstring() -> String {
    wgetstring(nc::stdscr())
}

pub fn wgetstring(window: nc::WINDOW) -> String {
    nc::noecho();

    let mut string = String::with_capacity(32);
    let mut pos_history = Vec::new();

    let mut y = 0;
    let mut x = 0;

    nc::getyx(window, &mut y, &mut x);
    pos_history.push((y, x));

    let mut ch = nc::wgetch(window);
    while ch != '\n' as i32 && ch != '\r' as i32 {
        if ch == 127 {
            if let Some((y, x)) = pos_history.pop() {
                nc::mvwdelch(window, y, x);
                string.pop();
            }
        }
        else if let Some(c) = char::from_u32(ch as u32) {
            nc::getyx(window, &mut y, &mut x);
            pos_history.push((y, x));
            string.push(c);
            nc::wechochar(window, ch as u64);
        }
        ch = nc::wgetch(window);
    }

    string.shrink_to_fit();
    string
}

pub fn getsecretstring() -> String {
    wgetsecretstring(nc::stdscr())
}

pub fn wgetsecretstring(window: nc::WINDOW) -> String {
    nc::noecho();
    let mut string = String::with_capacity(32);

    let mut ch = nc::wgetch(window);
    while ch != '\n' as i32 && ch != '\r' as i32 {
        if ch == 127 {
            string.pop();
        }
        else if let Some(c) = char::from_u32(ch as u32) {
            string.push(c);
        }
        ch = nc::wgetch(window);
    }

    string.shrink_to_fit();
    string
}

pub fn getchoice() -> i32 {
    wgetchoice(nc::stdscr())
}

pub fn wgetchoice(window: nc::WINDOW) -> i32 {
    wgetstring(window).trim().parse::<i32>().unwrap_or(-1)
}

{'fraction_non_alphanumeric': 0.16940317956737033, 'fraction_numerical': 0.024498305968204327, 'mean_word_length': 2.2144053601340032, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '861207', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1454, 'n_words': 357}