
// -------------------------------------------
// xterm, pascal@alseyn.net

/*

CSS base for customization

xterm-line {
	height:14px;
	overflow:hidden;
	font-family:monospace;
	font-size:12px;
	color:rgb(50%,50%,50%);
}

*/

function xterm(target_div_id,display_height,line_css_class){
    this.buffer = [];
    this._display = function(){
    	var xstring = '';
    	for(var i=0;i<this.buffer.length;i++){
    		xstring += '<div class="'+line_css_class+'">'+this.buffer[i]+'</div>';
    	}
    	if(document.getElementById(target_div_id)){
    		document.getElementById(target_div_id).innerHTML = xstring;
    	}
    }
    this.newline = function(xstring){
    	this.buffer.push(xstring.toString());
    	while( this.buffer.length > display_height ){
    		this.buffer.shift();
    	}
    	this._display();
    }
    this.reline = function(xstring){
    	this.buffer[this.buffer.length-1] = xstring.toString();
    	while( this.buffer.length > display_height ){
    		this.buffer.shift();
    	}
    	this._display();
    }
    this.clear = function(){
    	this.buffer = [];	
    	this._display();
    }
}


