rem: break; 
add: status_line(); 
context: function edit(quote_first){	var key;	redraw_screen();	if(quote_first) {		if(quote_mode())			return;	}	while(1) {		set_cursor();		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 (Colour) */				key='';				draw_colour_box();				while(key=='') {					key=console.getkey(K_UPPER);					switch(key) {						case 'K':							curattr&=0xf8;							break;						case 'R':							curattr=(curattr&0xf8)|RED;							break;						case 'G':							curattr=(curattr&0xf8)|GREEN;							break;						case 'Y':							curattr=(curattr&0xf8)|BROWN;							break;						case 'B':							curattr=(curattr&0xf8)|BLUE;							break;						case 'M':							curattr=(curattr&0xf8)|MAGENTA;							break;						case 'C':							curattr=(curattr&0xf8)|CYAN;							break;						case 'W':							curattr=(curattr&0xf8)|LIGHTGRAY;							break;						case '0':							curattr=(curattr&0x8f);							break;						case '1':							curattr=(curattr&0x8f)|(RED<<4);							break;						case '2':							curattr=(curattr&0x8f)|(GREEN<<4);							break;						case '3':							curattr=(curattr&0x8f)|(BROWN<<4);							break;						case '4':							curattr=(curattr&0x8f)|(BLUE<<4);							break;						case '5':							curattr=(curattr&0x8f)|(MAGENTA<<4);							break;						case '6':							curattr=(curattr&0x8f)|(CYAN<<4);							break;						case '7':							curattr=(curattr&0x8f)|(LIGHTGRAY<<4);							break;						case 'H':							curattr|=0x08;							break;						case 'I':							curattr|=0x80;							break;						case 'N':							curattr=7;							break;						case ctrl('R'):							redraw_screen();							key='';							break;						case "\x1b":	/* ESC */							break;						default:							console.beep();							key='';							break;					}				}				status_line();				erase_colour_box();				break;			case '\x02':	/* CTRL-B KEY_HOME */				last_xpos=-1;				xpos=0;				break;			case '\x03':	/* CTRL-C (Center Line) */				last_xpos=-1;				line[ypos].hardcr=true;				/* Trim leading/trailing whitespace */				line[ypos].text=line[ypos].text.replace(/^(\s*)(.*?)\s*$/,function (str, leading, t, offset, s) {					line[ypos].attr=line[ypos].attr.substr(leading.length, t.length);					xpos -= leading.length;					if(xpos<0)						xpos=0;					return(t);				});				var add=parseInt((80-line[ypos].text.length)/2);				for(add=parseInt((80-line[ypos].text.length)/2); add>0; add--) {					line[ypos].text=' '+line[ypos].text;					line[ypos].attr=ascii(curattr)+line[ypos].attr;					xpos++;				}				if(xpos>line[ypos].length)					xpos=line[ypos].length;				draw_line(ypos);				break;			case '\x04':	/* CTRL-D (Quick Find in SyncEdit)*/				break;			case '\x05':	/* CTRL-E KEY_END */				last_xpos=-1;				xpos=line[ypos].text.length;				break;			case '\x06':	/* CTRL-F KEY_RIGHT */				last_xpos=-1;				xpos++;				if(xpos>line[ypos].text.length) {					xpos--;					console.beep();				}				if(xpos>line[ypos].text.length) {					if(line[ypos].hardcr)						console.beep();					else {						if(try_next_line())							x=0;					}				}				break;			case '\x07':	/* CTRL-G (Beep) */				/* Enter Graphic Character */				key=get_graphic();				if(key=='')					break;				add_char(key);				break;			case '\x08':	/* CTRL-H Backspace */				last_xpos=-1;				if(xpos>0) {					line[ypos].text=line[ypos].text.substr(0,xpos-1)							+line[ypos].text.substr(xpos);					line[ypos].attr=line[ypos].attr.substr(0,xpos-1)							+line[ypos].attr.substr(xpos);					xpos--;				}				else {					if(try_prev_line()) {						xpos=line[ypos].text.length;						line[ypos].hardcr=false;					}				}				if(!rewrap())					draw_line(ypos,xpos);				break;			case '\x09':	/* CTRL-I TAB... ToDo expand to spaces */				add_char(' ');				while(xpos%8)					add_char(' ');				break;			case '\x0a':	/* CTRL-J KEY_DOWN (Insert Line in SyncEdit) */				if(last_xpos==-1)					last_xpos=xpos;				try_next_line();				break;			case '\x0b':	/* CTRL-K */				console.attributes=7;				console.gotoxy(1,edit_top);				console.write("Editing keys:");				console.cleartoeol();				console.write("\r\n CTRL-A - Change Colour                  CTRL-Q - Quick Abort (no save)");				console.cleartoeol();				console.write("\r\n CTRL-B - Move to beginning of line      CTRL-R - Redraw screen");				console.cleartoeol();				console.write("\r\n CTRL-C - Center line on screen          CTRL-T - Edit title");				console.cleartoeol();				console.write("\r\n CTRL-E - Move to end of line            CTRL-U - Enter quote mode");				console.cleartoeol();				console.write("\r\n CTRL-F - Move right one character       CTRL-V - Toggle insert mode");				console.cleartoeol();				console.write("\r\n CTRL-G - Enter graphic character        CTRL-W - Delete word backwards");				console.cleartoeol();				console.write("\r\n CTRL-H - Backspace (BACKSPACE)          CTRL-Y - Delete Line");				console.cleartoeol();				console.write("\r\n CTRL-I - Move to next tabstop (TAB)     CTRL-Z - Save message and exit");				console.cleartoeol();				console.write("\r\n CTRL-J - Move down one line             CTRL-] - Move left one character");				console.cleartoeol();				console.write("\r\n CTRL-L - Insert Line                    CTRL-^ - Move up one line");				console.cleartoeol();				console.write("\r\n CTRL-O - Page Up                        CTRL-_ - Quick Abort (no save)");				console.cleartoeol();				console.write("\r\n CTRL-P - Page Down                      CTRL-_ - Quick Abort (no save)");				console.cleartoeol();				console.write('\r\n');				console.cleartoeol();				console.write('\r\n');				console.write("Press any key to return to editing..");				console.cleartoeol();				console.write('\r\n');				console.cleartoeol();				console.up();				console.right(37);				console.getkey();				redraw_screen();				break;			case '\x0c':	/* CTRL-L (Insert Line) */				/* ToDo: Should this kill last_xpos? */				add_new_line_below(ypos-1);				xpos=0;				break;			case '\x0d':	/* CTRL-M CR */				last_xpos=-1;				if(insert) {					add_new_line_below(ypos);					/* Move all this to the next line... */					line[ypos+1].text=line[ypos].text.substr(xpos);					line[ypos+1].attr=line[ypos].attr.substr(xpos);					line[ypos+1].hardcr=line[ypos].hardcr;					line[ypos].text=line[ypos].text.substr(0,xpos);					line[ypos].attr=line[ypos].attr.substr(0,xpos);					line[ypos].hardcr=true;					draw_line(ypos,xpos);					if(line[ypos].kludged) {						line[ypos+1].kludged=true;						line[ypos].kludged=false;					}					draw_line(ypos+1);				}				try_next_line();				xpos=0;				rewrap();				break;			case '\x0e':	/* CTRL-N */				break;			case '\x0f':	/* CTRL-O (Quick Save/exit in SyncEdit) */				if(last_xpos==-1)					last_xpos=xpos;				if(ypos==0) {					console.beep();					break;				}				ypos-=lines_on_screen-1;				if(ypos<0)					ypos=0;				if(topline>ypos)					topline=ypos;				var i;				for(i=edit_top; i<=edit_bottom; i++)					draw_line(i-edit_top+topline);				xpos=last_xpos;				if(xpos>line[ypos].text.length)					xpos=line[ypos].text.length;				break;			case '\x10':	/* CTRL-P */				if(last_xpos==-1)					last_xpos=xpos;				if(ypos>=line.length-1) {					console.beep();					break;				}				ypos+=lines_on_screen-1;				if(ypos>line.length-1)					ypos=line.length-1;				if(ypos>=topline+lines_on_screen)					topline=ypos-lines_on_screen+1;				var i;				for(i=edit_top; i<=edit_bottom; i++)					draw_line(i-edit_top+topline);				xpos=last_xpos;				if(xpos>line[ypos].text.length)					xpos=line[ypos].text.length;				break;			case '\x11':	/* CTRL-Q (XOff) (Quick Abort in SyncEdit) */				return;			case '\x12':	/* CTRL-R (Quick Redraw in SyncEdit) */				redraw_screen();				break;			case '\x13':	/* CTRL-S (Xon)  */				break;			case '\x14':	/* CTRL-T (Justify Line in SyncEdit) */				if(edit_top==5) {					console.gotoxy(7,1);					var newsubj=console.getstr(subj, 70, K_LINE|K_EDIT|K_AUTODEL);					if(newsubj!='')						subj=newsubj;					redraw_screen();				}				break;			case '\x15':	/* CTRL-U (Quick Quote in SyncEdit) */				if(quote_line.length>0) {					if(quote_mode())						return;				}				else					console.beep();				break;			case '\x16':	/* CTRL-V (Toggle insert mode) */				insert=!insert;				status_line();				break;			case '\x17':	/* CTRL-W (Delete Word) */				last_xpos=-1;				/* Remove trailing part of word */				while(line[ypos].text.length>xpos						&& line[ypos].text.substr(xpos,1).search(/\s/)==-1) {					line[ypos].text=line[ypos].text.substr(0,xpos)							+line[ypos].text.substr(xpos+1);					line[ypos].attr=line[ypos].attr.substr(0,xpos)							+line[ypos].attr.substr(xpos+1);				}				/* Remove leading part */				while(xpos>0						&& line[ypos].text.substr(xpos-1,1).search(/\s/)==-1) {					line[ypos].text=line[ypos].text.substr(0,xpos-1)							+line[ypos].text.substr(xpos);					line[ypos].attr=line[ypos].attr.substr(0,xpos-1)							+line[ypos].attr.substr(xpos);					xpos--;				}				/* 				 * Remove Space...				 * Note that no matter what, we should delete a space.				 * We're either deleting the space from the end of the word if				 * this was the first word on the line, or the one before the				 * word otherwise.  This puts the cursor on the previous word				 * if there is one and the next word if there isn't.  This				 * allows multiple ^W to keep deleteing words in all cases.				 */				if(xpos) {					/* Delete space before the deleted word */					line[ypos].text=line[ypos].text.substr(0,xpos-1)							+line[ypos].text.substr(xpos);					line[ypos].attr=line[ypos].attr.substr(0,xpos-1)							+line[ypos].attr.substr(xpos);					xpos--;				}				else {					/* Delete space after the word */					line[ypos].text=line[ypos].text.substr(1);					line[ypos].attr=line[ypos].attr.substr(1);				}				draw_line(ypos,xpos);				break;			case '\x18':	/* CTRL-X (PgDn in SyncEdit) */				break;			case '\x19':	/* CTRL-Y (Delete Line in SyncEdit) */				/* Delete Line */				/* ToDo: Should this kill last_xpos? */				if(line.length==1)					line[0]=new Line;				else					line.splice(ypos,1);				if(ypos>=line.length)					ypos=line.length-1;				if(last_xpos>=0)					xpos=last_xpos;				if(xpos>line[ypos].text.length)					xpos=line[ypos].text.length;				var i;				console.write("\033[M");	/* Delete Line */				/* Redraw bottom line */				draw_line(topline+lines_on_screen-1);				/* Old used to redraw everything after current				for(i=ypos; i<topline+lines_on_screen; i++)					draw_line(i);				*/				break;				break;			case '\x1a':	/* CTRL-Z (EOF) (PgUp in SyncEdit)  */				var f=new File((argc==0?system.temp_dir+"INPUT.MSG":argv[0]));				f.open("w");				var s=make_strings(true,true);				f.write(s[0]);				f.close();				return;			case '\x1b':	/* ESC (This should parse extra ANSI sequences) */				break;			case '\x1c':	/* CTRL-\ (RegExp) */				break;			case '\x1d':	/* CTRL-] KEY_LEFT */				last_xpos=-1;				xpos--;				if(xpos<0) {					console.beep();					xpos=0;				}				break;			case '\x1e':	/* CTRL-^ KEY_UP */				if(last_xpos==-1)					last_xpos=xpos;				try_prev_line();				break;			case '\x1f':	/* CTRL-_ Safe quick-abort*/				return;			case '\x7f':	/* DELETE */				last_xpos=-1;				if(xpos>=line[ypos].text.length)					/* delete the hardcr, */					line[ypos].hardcr=false;				line[ypos].text=line[ypos].text.substr(0,xpos)						+line[ypos].text.substr(xpos+1);				line[ypos].attr=line[ypos].attr.substr(0,xpos)						+line[ypos].attr.substr(xpos+1);				if(!rewrap())					draw_line(ypos,xpos);				break;			default:		/* Insert the char */				add_char(key);		}	}}
meta: 9592	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9592/437160f00f6704cfe32f33a724364895ae3241b9/fseditor.js/clean/fseditor.js