<commit_before>/* jslint node: true */
'use strict';

var ansi		= require('./ansi_term.js');

var assert		= require('assert');

exports.connectEntry	= connectEntry;

function ansiQueryTermSizeIfNeeded(client, cb) {
	if(client.term.termHeight > 0 || client.term.termWidth > 0) {
		cb(true);
		return;
	}

	var done = function(res) {
		client.removeListener('cursor position report', cprListener);
		clearTimeout(giveUpTimer);
		cb(res);
	};

	var cprListener = function(pos) {
		//
		//	If we've already found out, disregard
		//
		if(client.term.termHeight > 0 || client.term.termWidth > 0) {
			done(true);
			return;
		}

		assert(2 === pos.length);
		var h = pos[0];
		var w = pos[1];

		//
		//	Netrunner for example gives us 1x1 here. Not really useful. Ignore
		//	values that seem obviously bad.
		//
		if(h < 10 || w < 10) {
			client.log.warn(
				{ height : h, width : w }, 
				'Ignoring ANSI CPR screen size query response due to very small values');
			done(false);
			return;
		}

		client.term.termHeight	= h;
		client.term.termWidth	= w;

		client.log.debug(
			{ 
				termWidth	: client.term.termWidth, 
				termHeight	: client.term.termHeight, 
				source		: 'ANSI CPR' 
			}, 
			'Window size updated'
			);

		done(true);
	};

	client.once('cursor position report', cprListener);

	//	give up after 2s
	var giveUpTimer = setTimeout(function onTimeout() {
		done(false);
	}, 2000);

	//	This causes 
	client.term.rawWrite(ansi.queryScreenSize());
}

function prepareTerminal(term) {
	term.rawWrite(ansi.normal());
	//term.rawWrite(ansi.disableVT100LineWrapping());
	//	:TODO: set xterm stuff -- see x84/others
}

function displayBanner(term) {
	term.pipeWrite(
		'|06Connected to |02EN|10i|02GMA|10½ |06BBS version |12|VN\n'	+
		'|06Copyright (c) 2014-2015 <NAME> |14- |12http://l33t.codes/\n'	+ 
		'|06Updates & source |14- |12https://github.com/NuSkooler/enigma-bbs/\n'			+
		'|00');
}<commit_msg>Update copyright<commit_after>/* jslint node: true */
'use strict';

var ansi		= require('./ansi_term.js');

var assert		= require('assert');

exports.connectEntry	= connectEntry;

function ansiQueryTermSizeIfNeeded(client, cb) {
	if(client.term.termHeight > 0 || client.term.termWidth > 0) {
		cb(true);
		return;
	}

	var done = function(res) {
		client.removeListener('cursor position report', cprListener);
		clearTimeout(giveUpTimer);
		cb(res);
	};

	var cprListener = function(pos) {
		//
		//	If we've already found out, disregard
		//
		if(client.term.termHeight > 0 || client.term.termWidth > 0) {
			done(true);
			return;
		}

		assert(2 === pos.length);
		var h = pos[0];
		var w = pos[1];

		//
		//	Netrunner for example gives us 1x1 here. Not really useful. Ignore
		//	values that seem obviously bad.
		//
		if(h < 10 || w < 10) {
			client.log.warn(
				{ height : h, width : w }, 
				'Ignoring ANSI CPR screen size query response due to very small values');
			done(false);
			return;
		}

		client.term.termHeight	= h;
		client.term.termWidth	= w;

		client.log.debug(
			{ 
				termWidth	: client.term.termWidth, 
				termHeight	: client.term.termHeight, 
				source		: 'ANSI CPR' 
			}, 
			'Window size updated'
			);

		done(true);
	};

	client.once('cursor position report', cprListener);

	//	give up after 2s
	var giveUpTimer = setTimeout(function onTimeout() {
		done(false);
	}, 2000);

	//	This causes 
	client.term.rawWrite(ansi.queryScreenSize());
}

function prepareTerminal(term) {
	term.rawWrite(ansi.normal());
	//term.rawWrite(ansi.disableVT100LineWrapping());
	//	:TODO: set xterm stuff -- see x84/others
}

function displayBanner(term) {
	term.pipeWrite(
		'|06Connected to |02EN|10i|02GMA|10½ |06BBS version |12|VN\n'	+
		'|06Copyright (c) 2014-2016 <NAME> |14- |12http://l33t.codes/\n'	+ 
		'|06Updates & source |14- |12https://github.com/NuSkooler/enigma-bbs/\n'			+
		'|00');
}
{'fraction_non_alphanumeric': 0.15524876269861942, 'fraction_numerical': 0.03177910914300599, 'mean_word_length': 3.2572062084257207, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '1596235', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1426, 'n_words': 315}