/** * Change what file is currently being edited. * * <OL> * <LI>store the String for the text of the current file. * <LI>retrieve the String for the text of the new file. * <LI>change the text that's visible in the text area * </OL> */ public void setCurrent(int which) { // if current is null, then this is the first setCurrent(0) if ((currentIndex == which) && (current != null)) { return; } // get the text currently being edited if (current != null) { current.program = editor.getText(); current.selectionStart = editor.textarea.getSelectionStart(); current.selectionStop = editor.textarea.getSelectionEnd(); current.scrollPosition = editor.textarea.getScrollPosition(); } current = code[which]; currentIndex = which; editor.setCode(current); // editor.setDocument(current.document, // current.selectionStart, current.selectionStop, // current.scrollPosition, current.undo); // set to the text for this file // 'true' means to wipe out the undo buffer // (so they don't undo back to the other file.. whups!) /* * editor.setText(current.program, current.selectionStart, * current.selectionStop, current.undo); */ // set stored caret and scroll positions // editor.textarea.setScrollPosition(current.scrollPosition); // editor.textarea.select(current.selectionStart, // current.selectionStop); // editor.textarea.setSelectionStart(current.selectionStart); // editor.textarea.setSelectionEnd(current.selectionStop); editor.header.rebuild(); }