<commit_before>#define _POSIX_C_SOURCE 199310L

#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <ncurses.h>

#include "display.h"
#include "../process/process.h"
#include "../system/sys_stats.h"


void init_screen(void)
{
    initscr();
    noecho();
    halfdelay(DELAY);
    keypad(stdscr, TRUE);
    curs_set(0);

    start_color();
    init_pair(1, COLOR_GREEN, COLOR_BLACK);
    attron(COLOR_PAIR(1));
}

int update_screen(proc_t *processes, bool sys_fields_refresh, char *fstype, 
                  char *fieldbar, int process_line_num, int max_x, int max_y)
{
    int cur_y = LINE_Y;

    attron(A_BOLD);
    mvwprintw(stdscr, 1, (max_x / 2) - 4, DASHBOARD);
    attroff(A_BOLD);

    if (sys_fields_refresh)
        build_sys_info(fstype);

    attron(A_REVERSE);
    mvwprintw(stdscr, cur_y++, 1, fieldbar);
    attroff(A_REVERSE);

    while (processes && cur_y < max_y - 1) {
        if (process_line_num == 0) {
            mvwprintw(stdscr, cur_y, LINE_X, "%s  ", processes->name);
            mvwprintw(stdscr, cur_y, LINE_X + LPID, "%d   ", processes->pid);
            mvwprintw(stdscr, cur_y, LINE_X + LUSER, "%s   ", processes->user);
            mvwprintw(stdscr, cur_y, LINE_X + LCPU, "%d ", processes->cpuset);
            mvwprintw(stdscr, cur_y, LINE_X + LMEM, "%.2f%", 
                      processes->mempcent);
            if (processes->nice >= 0 && processes->nice < 10) 
                mvwprintw(stdscr, cur_y, LINE_X + LNNICE, "%d", 
                          processes->nice);
            else if (processes->nice >= 10) 
                mvwprintw(stdscr, cur_y, LINE_X + LMNICE, "%d", 
                          processes->nice);
            else 
                mvwprintw(stdscr, cur_y, LINE_X + LLNICE, "%d", 
                          processes->nice);
            mvwprintw(stdscr, cur_y, LINE_X + LPRIO, "%s", processes->ioprio);
            mvwprintw(stdscr, cur_y, LINE_X + LSTATE, "%s", processes->state);
            mvwprintw(stdscr, cur_y, LINE_X + LVMEM, "%d", processes->vmem);
            mvwprintw(stdscr, cur_y, LINE_X + LPTE, "%d", processes->pte);
            mvwprintw(stdscr, cur_y, LINE_X + LRSS, "%d", processes->rss); 
            mvwprintw(stdscr, cur_y, LINE_X + LREAD, "%llu", 
                      processes->io_read);
            mvwprintw(stdscr, cur_y, LINE_X + LWRITE, "%llu", 
                      processes->io_write);
            if (processes->open_fds != -1)
                mvwprintw(stdscr, cur_y, LINE_X + LFDS, "%d", 
                          processes->open_fds);
            else
                mvwprintw(stdscr, cur_y, LINE_X + LFDS, "N/A", 
                          processes->open_fds);
            mvwprintw(stdscr, cur_y, LINE_X + LINVOL, "%d", 
                      processes->invol_sw);
            mvwprintw(stdscr, cur_y++, LINE_X + LTHRDS, "%d", 
                      processes->thrcnt);
        } else 
            process_line_num--;

        processes = processes->next;
    }

    box(stdscr, 0, 0);
    refresh();

    return 0;
}

char *build_fieldbar(void)<commit_msg>Change formatting for threads to char *<commit_after>#define _POSIX_C_SOURCE 199310L

#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <ncurses.h>

#include "display.h"
#include "../process/process.h"
#include "../system/sys_stats.h"


void init_screen(void)
{
    initscr();
    noecho();
    halfdelay(DELAY);
    keypad(stdscr, TRUE);
    curs_set(0);

    start_color();
    init_pair(1, COLOR_GREEN, COLOR_BLACK);
    attron(COLOR_PAIR(1));
}

int update_screen(proc_t *processes, bool sys_fields_refresh, char *fstype, 
                  char *fieldbar, int process_line_num, int max_x, int max_y)
{
    int cur_y = LINE_Y;

    attron(A_BOLD);
    mvwprintw(stdscr, 1, (max_x / 2) - 4, DASHBOARD);
    attroff(A_BOLD);

    if (sys_fields_refresh)
        build_sys_info(fstype);

    attron(A_REVERSE);
    mvwprintw(stdscr, cur_y++, 1, fieldbar);
    attroff(A_REVERSE);

    while (processes && cur_y < max_y - 1) {
        if (process_line_num == 0) {
            mvwprintw(stdscr, cur_y, LINE_X, "%s  ", processes->name);
            mvwprintw(stdscr, cur_y, LINE_X + LPID, "%d   ", processes->pid);
            mvwprintw(stdscr, cur_y, LINE_X + LUSER, "%s   ", processes->user);
            mvwprintw(stdscr, cur_y, LINE_X + LCPU, "%d ", processes->cpuset);
            mvwprintw(stdscr, cur_y, LINE_X + LMEM, "%.2f%", 
                      processes->mempcent);
            if (processes->nice >= 0 && processes->nice < 10) 
                mvwprintw(stdscr, cur_y, LINE_X + LNNICE, "%d", 
                          processes->nice);
            else if (processes->nice >= 10) 
                mvwprintw(stdscr, cur_y, LINE_X + LMNICE, "%d", 
                          processes->nice);
            else 
                mvwprintw(stdscr, cur_y, LINE_X + LLNICE, "%d", 
                          processes->nice);
            mvwprintw(stdscr, cur_y, LINE_X + LPRIO, "%s", processes->ioprio);
            mvwprintw(stdscr, cur_y, LINE_X + LSTATE, "%s", processes->state);
            mvwprintw(stdscr, cur_y, LINE_X + LVMEM, "%d", processes->vmem);
            mvwprintw(stdscr, cur_y, LINE_X + LPTE, "%d", processes->pte);
            mvwprintw(stdscr, cur_y, LINE_X + LRSS, "%d", processes->rss); 
            mvwprintw(stdscr, cur_y, LINE_X + LREAD, "%llu", 
                      processes->io_read);
            mvwprintw(stdscr, cur_y, LINE_X + LWRITE, "%llu", 
                      processes->io_write);
            if (processes->open_fds != -1)
                mvwprintw(stdscr, cur_y, LINE_X + LFDS, "%d", 
                          processes->open_fds);
            else
                mvwprintw(stdscr, cur_y, LINE_X + LFDS, "N/A", 
                          processes->open_fds);
            mvwprintw(stdscr, cur_y, LINE_X + LINVOL, "%d", 
                      processes->invol_sw);
            mvwprintw(stdscr, cur_y++, LINE_X + LTHRDS, "%s", 
                      processes->thrcnt);
        } else 
            process_line_num--;

        processes = processes->next;
    }

    box(stdscr, 0, 0);
    refresh();

    return 0;
}

char *build_fieldbar(void)
{'fraction_non_alphanumeric': 0.14045297263290343, 'fraction_numerical': 0.007864108210128971, 'mean_word_length': 2.0411286465805834, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 71, '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': '315747', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2255, 'n_words': 445}