Example #1
0
  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;
  }
Example #2
0
  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;
  }
Example #3
0
  public static void dispose(TextEdit ed, TextEdit next) throws InputException, IOException {
    // trace("disposing " + ed + " currfvc " + currfvc);

    reconnect(ed, next);
    fvmap.remove(ed);
    ed.disposeFvc();
  }
Example #4
0
 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;
 }
Example #5
0
  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");
  }
Example #6
0
  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;
  }
Example #7
0
 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);
 }
Example #8
0
  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;
  }
Example #9
0
 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
   }
 }
Example #10
0
 public void idle() {
   for (View vi : fvmap.viewCollection()) vi.repaint();
 }
Example #11
0
 void invalidateBack(UndoHistory.EhMark ehm) {
   for (Iterator<FvContext> fit = fvmap.iterator(); fit.hasNext(); ) {
     FvContext fvc = fit.next();
     if (fvc.vis) fvc.vi.checkValid(ehm);
   }
 }
Example #12
0
 static int viewCount() {
   return fvmap.viewCount();
 }
Example #13
0
 static void dump() {
   fvmap.dump();
 }