<commit_before>use alloc::collections::VecDeque;
use alloc::vec::Vec;
use alloc::string::String;
use alloc::borrow::ToOwned;
use core::ptr::Unique;

use super::{keyboard::EventAction, vga};
use d7keymap::{KeyAction, KeySymbol};

/// Screen and scrollback history
#[derive(Debug, Clone)]
pub struct Output {
    lines: VecDeque<Vec<u8>>,
    height: usize,
    width: usize,
}
impl Output {
    pub fn new() -> Self {
        Self {
            lines: VecDeque::new(),
            height: 25,
            width: 80,
        }
    }

    pub fn write_str(&mut self, text: &[u8]) {
        for byte in text {
            self.write_byte(*byte);
        }
    }

    pub fn write_byte(&mut self, byte: u8) {
        assert!(byte != 0);
        assert!(byte != b'\r');

        if byte == b'\n' {
            self.new_line();
            return;
        }

        // Ensure that there is a last line and it has space for one character
        if let Some(last_line) = self.lines.back_mut() {
            if last_line.len() == self.width {
                self.new_line();
            }
        } else {
            self.lines.push_back(Vec::new());
        };

        self.lines.back_mut().unwrap().push(byte);
    }

    pub fn new_line(&mut self) {<commit_msg>Ignore \r characters in virtual console output<commit_after>use alloc::collections::VecDeque;
use alloc::vec::Vec;
use alloc::string::String;
use alloc::borrow::ToOwned;
use core::ptr::Unique;

use super::{keyboard::EventAction, vga};
use d7keymap::{KeyAction, KeySymbol};

/// Screen and scrollback history
#[derive(Debug, Clone)]
pub struct Output {
    lines: VecDeque<Vec<u8>>,
    height: usize,
    width: usize,
}
impl Output {
    pub fn new() -> Self {
        Self {
            lines: VecDeque::new(),
            height: 25,
            width: 80,
        }
    }

    pub fn write_str(&mut self, text: &[u8]) {
        for byte in text {
            self.write_byte(*byte);
        }
    }

    pub fn write_byte(&mut self, byte: u8) {
        assert!(byte != 0);

        if byte == b'\r' {
            return;
        }

        if byte == b'\n' {
            self.new_line();
            return;
        }

        // Ensure that there is a last line and it has space for one character
        if let Some(last_line) = self.lines.back_mut() {
            if last_line.len() == self.width {
                self.new_line();
            }
        } else {
            self.lines.push_back(Vec::new());
        };

        self.lines.back_mut().unwrap().push(byte);
    }

    pub fn new_line(&mut self) {
{'fraction_non_alphanumeric': 0.1420256111757858, 'fraction_numerical': 0.006984866123399301, 'mean_word_length': 1.9195922989807475, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2485191', 'n_tokens_mistral': 832, 'n_tokens_neox': 816, 'n_words': 206}