rem: xpos=1; console.gotoxy(xpos,ypos); 
add: xpos=0; rewrap(); set_cursor(); 
context: function edit(){	var key;	console.gotoxy(xpos,ypos);	while(1) {		status_line();		key=console.inkey(0,10000);		if(key=='')			continue;		switch(key) {			/* We're getting all the CTRL keys here... */			case '\x00':	/* CTRL-@ (NULL) */			case '\x01':	/* CTRL-A */				break;			case '\x02':	/* KEY_HOME */				xpos=1;				console.gotoxy(xpos,ypos);				break;			case '\x03':	/* CTRL-C */			case '\x04':	/* CTRL-D */				break;			case '\x05':	/* KEY_END */				xpos=line[ypos-edit_top+topline].text.length+1;				if(xpos>80)					xpos=80;				console.gotoxy(xpos,ypos);				break;			case '\x06':	/* KEY_RIGHT */				xpos++;				if(xpos>line[ypos-edit_top+topline].text.length+1) {					xpos--;					console.beep();				}				if(xpos>80) {					xpos=1;					try_next_line();				}				console.gotoxy(xpos,ypos);				break;			case '\x07':	/* CTRL-G (Beep) */				break;			case '\x08':	/* Backspace */				if(xpos>1) {					line[ypos-edit_top+topline].text=line[ypos-edit_top+topline].text.substr(0,xpos-2)							+line[ypos-edit_top+topline].text.substr(xpos-1);					line[ypos-edit_top+topline].attr.splice(xpos-2,1);					xpos--;				}				else {					/* ToDo: Backspace onto the previous row and re-wrap... */					if(try_prev_line())						xpos=line[ypos-edit_top+topline].text.length+1;				}				unwrap_line(ypos-edit_top+topline);				redraw_line(ypos-edit_top+topline);				break;			case '\x09':	/* TAB... ToDo expand to spaces */				break;			case '\x0a':	/* KEY_DOWN */				try_next_line();				console.gotoxy(xpos,ypos);				break;			case '\x0b':	/* CTRL-K */			case '\x0c':	/* CTRL-L */			case '\x0d':	/* CR */				if(insert) {					add_new_line_below(ypos-edit_top+topline);					/* Move all this to the next line... */					line[ypos-edit_top+topline+1].text=line[ypos-edit_top+topline].text.substr(xpos-1);					line[ypos-edit_top+topline+1].attr.splice(0,0,line[ypos-edit_top+topline].attr.slice(xpos-1,line[ypos-edit_top+topline+1].text.length));					line[ypos-edit_top+topline+1].hardcr=line[ypos-edit_top+topline].hardcr;					line[ypos-edit_top+topline].text=line[ypos-edit_top+topline].text.substr(0,xpos-1);					line[ypos-edit_top+topline].attr.splice(xpos-1,line[ypos-edit_top+topline+1].text.length);					line[ypos-edit_top+topline].hardcr=true;					redraw_line(ypos-edit_top+topline);					redraw_line(ypos-edit_top+topline+1);				}				try_next_line();				xpos=1;				console.gotoxy(xpos,ypos);				break;			case '\x0e':	/* CTRL-N */			case '\x0f':	/* CTRL-O */			case '\x10':	/* CTRL-P */			case '\x11':	/* CTRL-Q (XOff) */				return;			case '\x12':	/* CTRL-R */			case '\x13':	/* CTRL-S (Xon)  */			case '\x14':	/* CTRL-T */			case '\x15':	/* CTRL-U */			case '\x16':	/* CTRL-V */				if(insert)					insert=false;				else					insert=true;				break;			case '\x17':	/* CTRL-W */			case '\x18':	/* CTRL-X */			case '\x19':	/* CTRL-Y */			case '\x1a':	/* CTRL-Z (EOF) */			case '\x1b':	/* ESC */			case '\x1c':	/* CTRL-\ */				break;			case '\x1d':	/* KEY_LEFT */				xpos--;				if(xpos<=0) {					console.beep();					xpos=1;				}				console.gotoxy(xpos,ypos);				break;			case '\x1e':	/* KEY_UP */				try_prev_line();				console.gotoxy(xpos,ypos);				break;			case '\x1f':	/* CTRL-_ */				break;			case '\x7f':	/* DELETE */				line[ypos-edit_top+topline].text=line[ypos-edit_top+topline].text.substr(0,xpos-1)						+line[ypos-edit_top+topline].text.substr(xpos);				line[ypos-edit_top+topline].attr.splice(xpos-1,1);				unwrap_line(ypos-edit_top+topline);				redraw_line(ypos-edit_top+topline);				break;			default:		/* Insert the char */				if(insert) {					line[ypos-edit_top+topline].text=line[ypos-edit_top+topline].text.substr(0,xpos-1)							+key							+line[ypos-edit_top+topline].text.substr(xpos-1);					line[ypos-edit_top+topline].attr.splice(xpos-1,0,curattr);					if(line[ypos-edit_top+topline].text.length > 80) {						/* ToDo: Wrap */					}				}				else {					line[ypos-edit_top+topline].text=line[ypos-edit_top+topline].text.substr(0,xpos-1)							+key							+line[ypos-edit_top+topline].text.substr(xpos);					line[ypos-edit_top+topline].attr[xpos-1]=curattr;				}				xpos++;				if(xpos>80) {					/* Wrap */					xpos=1;					xpos=wrap_line(ypos-edit_top+topline);					next_line();				}				else {					if(line[ypos-edit_top+topline].text.length > 79)						wrap_line(ypos-edit_top+topline);				}				redraw_line(ypos-edit_top+topline);				console.gotoxy(xpos,ypos);		}	}}
meta: 9592	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9592/d3dfc7c910d9487d1b5e959a6c82f51a1ba0c617/fseditor.js/clean/fseditor.js