rem: while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined) { 
add: while(this.items[this.current].disabled || this.items[this.current].retval==undefined) { 
context: function Lightbar_getval(current){	var attr=this.bg<<4|this.fg;	var cattr=this.hbg<<4|this.hfg;	var dattr=this.dbg<<4|this.dfg;	var kattr=this.bg<<4|this.kfg;	var kcattr=this.hbg<<4|this.khfg;	var ret=undefined;	var last_cur;	if(current!=undefined)		this.current=current;	if(!(user.settings & USER_ANSI)) {		return(this.failsafe_getval());	}	if(!(user.settings & USER_COLOR)) {		return(this.failsafe_getval());	}	if(this.direction < 0 || this.direction > 1) {		alert("Unknown lightbar direction!");		return(this.failsafe_getval());	}	/* Check that a vertical lightbar fits on the screen */	if(this.direction==0 && (this.ypos+this.items.length-1 > console.screen_rows)) {		alert("Screen too short for lightbar!");		return(this.failsafe_getval());	}	/* Ensure current is valid */	if(this.current<0 || this.current >= this.items.length) {		alert("current parameter is out of range!");		this.current=0;		if(this.items.length<=0)			return(null);	}	var orig_cur=this.current;	while(this.items[this.current].retval==undefined || this.items[this.current].disabled) {		this.current++;		if(this.current==this.items.length)			this.current=0;		if(this.current==orig_cur) {			alert("No items with a return value!");			return(undefined);		}	}	/* Check that a horizontal lightbar fits on the screen */	if(this.direction==1) {		var end=this.xpos;		var i;		for(i=0; i<this.items.length; i++) {			if(this.force_width>0) {				end+=this.force_width+1;				continue;			}			if(this.items[i].width==undefined) {				if(this.items[i]==undefined) {					alert("Sparse items array!");					return(null);				}				if(this.items[i].text==undefined) {					alert("No text for item "+i+"!");					return(this.failsafe_getval());				}				var cleaned=this.items[i].text;				cleaned=cleaned.replace(/\|/g,'');				end+=cleaned.length+1;			}			else {				end+=this.items[i].width			}		}	}	this.draw();	last_cur=this.current;	/* Main loop */	while(1) {		var i;		var j;		var k;		/* Draw items */		var curx=this.xpos;		var cury=this.ypos;		var cursx=this.xpos;		var cursy=this.ypos;		var item_count=0;		for(i=0; i<this.items.length; i++) {			var width;			// Some basic validation.			if(this.items[i]==undefined) {				alert("Sparse items array!");				return(this.failsafe_getval());			}			if(this.items[i].text==undefined) {				alert("No text for item "+i+"!");				return(this.failsafe_getval());			}			var cleaned=this.items[i].text;			cleaned=cleaned.replace(/\|/g,'');			if(this.force_width>0)				width=this.force_width;			else {				width=cleaned.length;				if(this.items[i].width!=undefined)					width=this.items[i].width;			}			var lpadding=this.lpadding;			var rpadding=this.rpadding;			if(this.items[i].lpadding!=undefined)				lpadding=this.items[i].lpadding;			if(this.items[i].rpadding!=undefined)				rpadding=this.items[i].rpadding;			if(lpadding != undefined && lpadding != null)				curx+= lpadding.length;			if(i==this.current || i==last_cur) {				console.gotoxy(curx, cury);				if(i==this.current) {					cursx=curx;					cursy=cury;				}				k=0;				if(cleaned.length < width) {					if(this.align==1) {						if(this.current==i)							console.attributes=cattr;						else {							if(this.items[i].disabled)								console.attributes=dattr;							else								console.attributes=attr;						}						for(;k<width-cleaned.length;k++)							console.write(' ');					}					if(this.align==2) {						if(this.current==i)							console.attributes=cattr;						else {							if(this.items[i].disabled)								console.attributes=dattr;							else								console.attributes=attr;						}						for(;k<(width-cleaned.length)/2;k++)							console.write(' ');					}				}				for(j=0; j<this.items[i].text.length; j++) {					if(width > -1 && k > width)						break;					if(this.items[i].text.substr(j,1)=='|') {						if(!this.items[i].disabled) {							if(this.current==i)								console.attributes=kcattr;							else								console.attributes=kattr;						}						j++;					}					else {						if(this.current==i)							console.attributes=cattr;						else {							if(this.items[i].disabled)								console.attributes=dattr;							else								console.attributes=attr;						}					}					console.write(this.items[i].text.substr(j,1));					k++;				}				if(this.current==i)					console.attributes=cattr;				else {					if(this.items[i].disabled)						console.attributes=dattr;					else						console.attributes=attr;				}				while(k<width) {					console.write(" ");					k++;				}			}			if(rpadding != undefined && rpadding != null)				curx+= rpadding.length;			if(this.direction==0) {				cury++;				curx=this.xpos;			}			else				curx+=width+this.hblanks;			if(this.items[i].retval!=undefined)				item_count++;		}		if(item_count==0) {			alert("No items with a return value!");			return(undefined);		}		console.gotoxy(cursx,cursy);		if(ret!=undefined)			return(ret);		last_cur=this.current;		/* Get input */		var key=console.getkey(K_UPPER);		if(this.hotkeys.indexOf(key)!=-1)			return(key);		switch(key) {			case KEY_UP:				if(this.direction==0) {					do {						if(this.current==0)							this.current=this.items.length;						this.current--;					} while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined);				}				break;			case KEY_DOWN:				if(this.direction==0) {					do {						this.current++;						if(this.current==this.items.length)							this.current=0;					} while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined);				}				break;			case KEY_LEFT:				if(this.direction==1) {					do {						if(this.current==0)							this.current=this.items.length;						this.current--;					} while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined);				}				break;			case KEY_RIGHT:				if(this.direction==1) {					do {						this.current++;						if(this.current==this.items.length)							this.current=0;					} while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined);				}				break;			case KEY_HOME:				this.current=0;				while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined) {					this.current++;					if(this.current==this.items.length)						this.current=0;				}				break;			case KEY_END:				this.current=this.items.length-1;				while(this.items[this.current]!=disabled || this.items[this.current].retval==undefined) {					if(this.current==0)						this.current=this.items.length;					this.current--;				}				break;			case '\r':			case '\n':				if(this.items[this.current].retval==undefined)					return(undefined);				return(this.items[this.current].retval);				break;			default:				for(i=0; i<this.items.length; i++) {					if((!this.items[i].disabled) && (this.items[i].text.indexOf('|'+key)!=-1 || this.items[i].text.indexOf('|'+key.toLowerCase())!=-1)) {						if(this.items[i].retval==undefined)							continue;						this.current=i;						/* Let it go through once more to highlight */						ret=this.items[this.current].retval;						break;					}				}				break;		}	}}
meta: 9592	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9592/4f223d12f8505cb351da184b25e6b6e9ae060fd6/lightbar.js/buggy/load/lightbar.js