FvContext switchContext(TextEdit ev, int incval) { FvContext newcontext = fvmap.get(vi, ev); if (null == newcontext) { newcontext = new FvContext(vi, ev); fvmap.put(newcontext); } else { if (newcontext != this) newcontext.wrapInc(incval); } return newcontext; }
public static FvContext getcontext(View viloc, TextEdit te) { // trace("fvcontext.getcontext " + e + " and " + viloc); FvContext context = fvmap.get(viloc, te); if (null == defaultFvc) { defaultFvc = new FvContext(viloc, defaultText); fvmap.put(defaultFvc); } if (null == context) { context = new FvContext(viloc, te); fvmap.put(context); } return context; }
public static void dispose(TextEdit ed, TextEdit next) throws InputException, IOException { // trace("disposing " + ed + " currfvc " + currfvc); reconnect(ed, next); fvmap.remove(ed); ed.disposeFvc(); }
public static FvContext dispose(View vi) { // trace("removing " + vi); FvContext retval = null; if (currfvc.vi == vi) retval = nextView(); fvmap.remove(vi); // else // for (FvContext fvc :ehash.values()) // EditContainer.unRegisterListener(fvc); return retval; }
static void reconnect(TextEdit ed, TextEdit next) throws InputException { // trace("reconnecting oldfile " + ed + " next " + next); if (currfvc.edvec == ed) FvContext.connectFv(next, currfvc.vi); // trace("starting iterator"); for (Iterator<FvContext> fit = fvmap.iterator(); fit.hasNext(); ) { FvContext fvc = fit.next(); if (fvc.edvec == ed) getcontext(fvc.vi, next).activate(); } // trace("done iterator"); }
private static void disposeAll(boolean ignoreLock) throws IOException { if (!ignoreLock) EventQueue.biglock2.assertOwned(); Set<TextEdit> allEdits = new HashSet<TextEdit>(100); for (Iterator<FvContext> fit = fvmap.iterator(); fit.hasNext(); ) allEdits.add(fit.next().edvec); for (TextEdit ev : allEdits) try { // trace("disposing in fvc quit" + ev); ev.disposeFvc(); } catch (Throwable t) { trace("disposeall caught " + t); trace("for file " + ev); t.printStackTrace(); } EditContainer.disposeAll(); fvmap.clear(); currfvc = null; }
public View findNextView() { Collection<View> views = fvmap.viewCollection(); for (Iterator<View> eve = views.iterator(); eve.hasNext(); ) { if (vi == eve.next()) { while (eve.hasNext()) { View nview = eve.next(); if (nview.isTraverseable()) return nview; } for (View nv : views) if (nv.isTraverseable()) { return nv; } throw new RuntimeException("findNextView is confused"); } } throw new RuntimeException("findNextView cant find vi " + vi); }
private void activate() { // trace("activate " + this); if (null != currfvc) { if (currfvc.vi == vi) // the usual case currfvc.vis = false; else for (Iterator<FvContext> fit = fvmap.iterator(); fit.hasNext(); ) { FvContext fvc = fit.next(); if (fvc.vi == vi) fvc.vis = false; } } if (!edvec.containsNow(1)) { fileposy = 1; fileposx = 0; } else { fileposy = inrange(fileposy, 1, edvec.readIn() - 1); fileposx = inrange(fileposx, 0, edvec.at(fileposy).toString().length()); } vi.newfile(edvec, fileposx, fileposy); vis = true; }
private static void fixCursor(TextEdit ed) { for (HashMap<TextEdit, FvContext> hmap : fvmap.tmap()) { FvContext fv = hmap.get(ed); if (null != fv) fv.cursorabs(fv.fileposx, fv.fileposy); // fix up cursor position } }
public void idle() { for (View vi : fvmap.viewCollection()) vi.repaint(); }
void invalidateBack(UndoHistory.EhMark ehm) { for (Iterator<FvContext> fit = fvmap.iterator(); fit.hasNext(); ) { FvContext fvc = fit.next(); if (fvc.vis) fvc.vi.checkValid(ehm); } }
static int viewCount() { return fvmap.viewCount(); }
static void dump() { fvmap.dump(); }