<commit_before>/*
 * @file
 * @brief prints file to standart output screen by screen
 *
 * @date 22.09.2013
 * @author <NAME>
 */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <curses.h>


#define TAB_SIZE 4
#define MAX_SCREEN_WIDTH 256

static char buff[MAX_SCREEN_WIDTH], info[MAX_SCREEN_WIDTH];

static void screen(FILE *fp) {
    int cmd = 0, columns, lines, x, y;
	WINDOW *std;
	bool endOfFile = false;

	std = initscr();
	columns = std->endx - std->begx;
	if (columns >= MAX_SCREEN_WIDTH - 1) {
		columns = MAX_SCREEN_WIDTH - 1;
	}
	lines	= std->endy - std->begy;
	refresh();
	cbreak();
	noecho();

	while (1){
		if (!endOfFile) {
			for (x = 0; x < lines - 1; x++) {
				for (y = 0; y < columns; y++) {
					buff[y] = !endOfFile ? getc(fp) : ' ';

					switch ((int)buff[y]) {
						case EOF:
							buff[y] = ' ';
							endOfFile = true;
							break;
						case '\n':
							/*	End of the line, filling the rest of buffer */
							memset(buff + y, ' ', columns - y);
							y = columns;
							break;
						case '\t':
							/*	Perform tab instert	*/
							memset(buff + y, ' ', TAB_SIZE);
							y += TAB_SIZE - 1;
							break;
					}
				}
				/*	In case if we got out of the actual line size	*/
				buff[columns]= '\n';
				addstr(buff);
			}
			memset(info, '\0', columns);
			memcpy(info, "---More---", 10);
			memset(buff, ' ', columns);
			if (endOfFile) {
				strcat(info, " End of the file! Press 'q' to quit.");
			}
			memcpy(buff, info, strlen(info));
			attron(A_REVERSE);
			addstr(buff);
			attron(A_NORMAL);
			refresh();
		}

		cmd = getch();
		if (cmd == 'q') {
			endwin();
			return;
		}
	}
	endwin();
	return;
}

int main(int argc, char **argv) {
	FILE *fp;

	if (argc < 2) {<commit_msg>cmds : fix command more(now it works without bugs)<commit_after>/*
 * @file
 * @brief prints file to standart output screen by screen
 *
 * @date 22.09.2013
 * @author <NAME>
 */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <curses.h>


#define TAB_SIZE 4
#define MAX_SCREEN_WIDTH 256

static void screen(FILE *fp) {
	char buff[MAX_SCREEN_WIDTH];
	int cmd = 0, columns, lines, x, y, i;

	WINDOW *std;
	std = initscr();
	columns = std->endx - std->begx;
	if (columns >= MAX_SCREEN_WIDTH - 1) {
		columns = MAX_SCREEN_WIDTH - 1;
	}
	lines = std->endy - std->begy;
	endwin();

	while (1) {
		for (x = 0; x < lines - 1; x++) {

			for (y = 0; y < columns; y++) {
				buff[y] = getc(fp);
				switch ((int) buff[y]) {
				case EOF:
					for (i = 0; i < y; i++) {
						printf("%c", buff[i]);
					}
					return;
				case '\n':
					/*	End of the line, filling the rest of buffer */
					memset(buff + y, ' ', columns - y);
					y = columns;
					break;
				case '\t':
					/*	Perform tab instert	*/
					memset(buff + y, ' ', TAB_SIZE);
					y += TAB_SIZE - 1;
					break;
				}
			}
			/*	In case if we got out of the actual line size	*/
			buff[columns - 1] = '\n';
			for (i = 0; i < columns; i++) {
				printf("%c", buff[i]);
			}
		}

		printf("---More---\n");
		cmd = getch();

		if (cmd == 'q') {
			return;
		}
	}
}

int main(int argc, char **argv) {
	FILE *fp;

	if (argc < 2) {
{'fraction_non_alphanumeric': 0.17942361326309267, 'fraction_numerical': 0.014874496436318562, 'mean_word_length': 2.3836477987421385, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '1259682', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1273, 'n_words': 360}