<commit_before>/**
 * @file
 * @brief
 *
 * @date 08.02.13
 * @author <NAME>
 * @author <NAME>
 */

#include <assert.h>
#include <string.h>
#include <stdint.h>
#include <stddef.h>
#include <termios.h>
#include <util/array.h>
#include <util/member.h>
#include <drivers/video_term.h>
#include <drivers/keyboard.h>
#include <drivers/input/input_dev.h>
#include <drivers/input/keymap.h>
#include <drivers/tty.h>

#define VTERM_TAB_WIDTH 8

static void vterm_scroll_up(struct vterm *vt, unsigned short delta) {
	assert(
			vt && vt->video && vt->video->ops && vt->video->ops->copy_rows
					&& vt->video->ops->clear_rows);

	vt->video->ops->copy_rows(vt->video, 0, delta, vt->video->height - delta);
	vt->video->ops->clear_rows(vt->video, vt->video->height - delta, delta);

	vt->cur_y -= delta;
}

static void vterm_clear(struct vterm *vt) {
	assert(vt && vt->video && vt->video->ops && vt->video->ops->clear_rows);

	vt->video->ops->clear_rows(vt->video, 0, vt->video->height);
}

static void vterm_cursor(struct vterm *vt) {
	assert(vt && vt->video && vt->video->ops && vt->video->ops->cursor);

	vt->video->ops->cursor(vt->video, vt->cur_x, vt->cur_y);
}

static int setup_cursor(struct vterm *vt, int x, int y) {
	vt->cur_x = x;
	if (vt->cur_x) {
		--vt->cur_x;
	}
	vt->cur_y = y;
	if (vt->cur_y) {
		--vt->cur_y;
	}
	if (vt->cur_x >= vt->video->width) {
		vt->cur_x = vt->video->width - 1;
	}
	if (vt->cur_y >= vt->video->height) {
		vt->cur_y = vt->video->height - 1;
	}
	return 0;
}

static inline void inc_line(struct vterm *vt) {
	++vt->cur_y;
	if (vt->cur_y >= vt->video->height)
		vterm_scroll_up(vt, vt->cur_y - vt->video->height + 1);
}

static void execute_printable(struct vterm *vt, char ch) {
	switch (ch) {
	case '\n':
	case '\f': /* Form feed/clear screen*/
		vt->cur_x = 0;
		inc_line(vt);<commit_msg>video_term not printing bell (does nothing)<commit_after>/**
 * @file
 * @brief
 *
 * @date 08.02.13
 * @author <NAME>
 * @author <NAME>
 */

#include <assert.h>
#include <string.h>
#include <stdint.h>
#include <stddef.h>
#include <termios.h>
#include <util/array.h>
#include <util/member.h>
#include <drivers/video_term.h>
#include <drivers/keyboard.h>
#include <drivers/input/input_dev.h>
#include <drivers/input/keymap.h>
#include <drivers/tty.h>

#define VTERM_TAB_WIDTH 8

static void vterm_scroll_up(struct vterm *vt, unsigned short delta) {
	assert(
			vt && vt->video && vt->video->ops && vt->video->ops->copy_rows
					&& vt->video->ops->clear_rows);

	vt->video->ops->copy_rows(vt->video, 0, delta, vt->video->height - delta);
	vt->video->ops->clear_rows(vt->video, vt->video->height - delta, delta);

	vt->cur_y -= delta;
}

static void vterm_clear(struct vterm *vt) {
	assert(vt && vt->video && vt->video->ops && vt->video->ops->clear_rows);

	vt->video->ops->clear_rows(vt->video, 0, vt->video->height);
}

static void vterm_cursor(struct vterm *vt) {
	assert(vt && vt->video && vt->video->ops && vt->video->ops->cursor);

	vt->video->ops->cursor(vt->video, vt->cur_x, vt->cur_y);
}

static int setup_cursor(struct vterm *vt, int x, int y) {
	vt->cur_x = x;
	if (vt->cur_x) {
		--vt->cur_x;
	}
	vt->cur_y = y;
	if (vt->cur_y) {
		--vt->cur_y;
	}
	if (vt->cur_x >= vt->video->width) {
		vt->cur_x = vt->video->width - 1;
	}
	if (vt->cur_y >= vt->video->height) {
		vt->cur_y = vt->video->height - 1;
	}
	return 0;
}

static inline void inc_line(struct vterm *vt) {
	++vt->cur_y;
	if (vt->cur_y >= vt->video->height)
		vterm_scroll_up(vt, vt->cur_y - vt->video->height + 1);
}

static void execute_printable(struct vterm *vt, char ch) {
	switch (ch) {
	case '\a': /* bell */
		break;
	case '\n':
	case '\f': /* Form feed/clear screen*/
		vt->cur_x = 0;
		inc_line(vt);
{'fraction_non_alphanumeric': 0.21185064935064934, 'fraction_numerical': 0.007575757575757576, 'mean_word_length': 3.7519280205655527, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 181, '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': '3605483', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1559, 'n_words': 310}