<commit_before>/* This is the user console.
 * At the moment, it is not truly in userland -- nothing is.
 * This is the console for the user to use (think 'bash'/'sh'),
 * as opposed to the console driver (think 'VT' [virtual terminal] on Linux)
 */

#include <string.h>
#include <dux/mm/memory.h>
#include <dux/drivers/fdd.h>

void print_prompt(input)
{
	printk("\r                                                                                \r[");
	screen_setattr(0x09, 0x09);
	printk("Dux");
	screen_setattr(0x0a, 0x0a);
	printk("]# %s", input);
}

void user_console()
{
	char c;
	char input[2000];
	int index = 0;
	char history[4000];
	int history_index = 0;
	int history_selected = -1;
	int tmp = 0;
	int scancode;
	
	printk("\nDux OS terminal\n\n");
	console_tab_start(6);
	
	while (1)
	{
		index = 0;
		input[0] = 0;
		history_selected = history_index;
		
		screen_setattr(0x0a, 0x0a);
		printk("[");
		screen_setattr(0x09, 0x09);
		printk("Dux");
		screen_setattr(0x0a, 0x0a);
		printk("]# ");
		
		while (1)
		{
			scancode = kb_read();
			c = console_resolve_scancode(scancode);
			
			if (scancode & 0x80)
				continue;
			
			if (scancode == 72 && history_selected > 0)
			{
				history_selected--;
				for (; history[history_selected - 1] != 0; history_selected--);
				
				strcpy(input, history + history_selected);
				print_prompt(input);
			}<commit_msg>Now your line is saved when you arrow away, so if you accidently hit up you can hit down again and still have what you were typing<commit_after>/* This is the user console.
 * At the moment, it is not truly in userland -- nothing is.
 * This is the console for the user to use (think 'bash'/'sh'),
 * as opposed to the console driver (think 'VT' [virtual terminal] on Linux)
 */

#include <string.h>
#include <dux/mm/memory.h>
#include <dux/drivers/fdd.h>

void print_prompt(input)
{
	printk("\r                                                                                \r[");
	screen_setattr(0x09, 0x09);
	printk("Dux");
	screen_setattr(0x0a, 0x0a);
	printk("]# %s", input);
}

void user_console()
{
	char c;
	char input[2000];
	int index = 0;
	char history[4000];
	int history_index = 0;
	int history_selected = -1;
	int tmp = 0;
	int scancode;
	
	printk("\nDux OS terminal\n\n");
	console_tab_start(6);
	
	while (1)
	{
		index = 0;
		input[0] = 0;
		history_selected = history_index;
		
		screen_setattr(0x0a, 0x0a);
		printk("[");
		screen_setattr(0x09, 0x09);
		printk("Dux");
		screen_setattr(0x0a, 0x0a);
		printk("]# ");
		
		while (1)
		{
			scancode = kb_read();
			c = console_resolve_scancode(scancode);
			
			if (scancode & 0x80)
				continue;
			
			if (scancode == 72 && history_selected > 0)
			{
				if (history_selected >= history_index)
					strcpy(history + history_index, input);
				
				history_selected--;
				for (; history[history_selected - 1] != 0; history_selected--);
				
				strcpy(input, history + history_selected);
				print_prompt(input);
			}
{'fraction_non_alphanumeric': 0.13716216216216215, 'fraction_numerical': 0.033783783783783786, 'mean_word_length': 2.791293213828425, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '874053', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1053, 'n_words': 284}