<commit_before>#include <stddef.h>
#include <stdint.h>
#include <drivers/terminal.h>

uint8_t make_color(enum vga_color fg, enum vga_color bg)
{
    return fg | bg << 4;
}

uint16_t make_vgaentry(char c, uint8_t color)
{
    uint16_t c16 = c;
    uint16_t color16 = color;
    return c16 | color16 << 8;
}

void term_putentryat(char c, uint8_t color, size_t x, size_t y)
{
    const size_t index = y * VGA_WIDTH + x;
    term_buffer[index] = make_vgaentry(c, color);
}

void term_initialize()
{
    term_row = 0;
    term_column = 0;
    term_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
    term_buffer = (uint16_t*)0xB8000;
    for (size_t y = 0; y < VGA_HEIGHT; y++) {
        for (size_t x = 0; x < VGA_WIDTH; x++) {
            const size_t index = y * VGA_WIDTH + x;
            term_buffer[index] = make_vgaentry(' ', term_color);
        }
    }
}

int term_putchar(char c)
{
    if (c == '\n') {
        term_column = 0;

        if(++term_row == VGA_HEIGHT) {
            term_copy_up_lines();
        }

        return c;
    }

    if(term_column >= VGA_WIDTH) {
        term_color = 0;
        term_row++;
    }

    term_putentryat(c, term_color, term_column, term_row);
    if (++term_column == VGA_WIDTH) {
        term_column = 0;<commit_msg>Fixed typo in terminal wrapping<commit_after>#include <stddef.h>
#include <stdint.h>
#include <drivers/terminal.h>

uint8_t make_color(enum vga_color fg, enum vga_color bg)
{
    return fg | bg << 4;
}

uint16_t make_vgaentry(char c, uint8_t color)
{
    uint16_t c16 = c;
    uint16_t color16 = color;
    return c16 | color16 << 8;
}

void term_putentryat(char c, uint8_t color, size_t x, size_t y)
{
    const size_t index = y * VGA_WIDTH + x;
    term_buffer[index] = make_vgaentry(c, color);
}

void term_initialize()
{
    term_row = 0;
    term_column = 0;
    term_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
    term_buffer = (uint16_t*)0xB8000;
    for (size_t y = 0; y < VGA_HEIGHT; y++) {
        for (size_t x = 0; x < VGA_WIDTH; x++) {
            const size_t index = y * VGA_WIDTH + x;
            term_buffer[index] = make_vgaentry(' ', term_color);
        }
    }
}

int term_putchar(char c)
{
    if (c == '\n') {
        term_column = 0;

        if(++term_row == VGA_HEIGHT) {
            term_copy_up_lines();
        }

        return c;
    }

    if(term_column >= VGA_WIDTH) {
        term_column = 0;
        term_row++;
    }

    term_putentryat(c, term_color, term_column, term_row);
    if (++term_column == VGA_WIDTH) {
        term_column = 0;
{'fraction_non_alphanumeric': 0.12475480580619851, 'fraction_numerical': 0.025892506865437426, 'mean_word_length': 2.576437587657784, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 11, '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': '3068810', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1000, 'n_words': 225}