Пример #1
0
PairMatch *BaseEditor::searchGlobalPair(int lineNo, int pos)
{
  int lno;
  int end_line = lineCount;
  PairMatch *pm = getPairMatch(lineNo, pos);
  if (pm == null){
    return null;
  }

  lno = pm->sline;

  LineRegion *pair = pm->getStartRef();
  LineRegion *slr = getLineRegions(lno);
  while(true){
    if (pm->pairBalance > 0){
      pair = pair->next;
      while(pair == null){
        lno++;
        if (lno > end_line) break;
        pair = getLineRegions(lno);
      }
      if (lno > end_line) break;
    }else{
      if(pair->prev == slr->prev){ // first region
        lno--;
        if (lno < 0) break;
        slr = getLineRegions(lno);
        pair = slr;
      }
      if (lno < 0) break;
      pair = pair->prev;
    }
    if (pair->region->hasParent(def_PairStart)){
      pm->pairBalance++;
    }
    if (pair->region->hasParent(def_PairEnd)){
      pm->pairBalance--;
    }
    if (pm->pairBalance == 0){
      break;
    }
  }
  if (pm->pairBalance == 0){
    pm->eline = lno;
    pm->setEnd(pair);
  }
  return pm;
}
void LineRegionsSupport::addLineRegion(int lno, LineRegion *lr){
  LineRegion *lstart = getLineRegions(lno);
  lr->next = null;
  lr->prev = lr;
  if (lstart == null)
    lineRegions.setElementAt(lr, lno-firstLineNo);
  else{
    lr->prev = lstart->prev;
    lr->prev->next = lr;
    lstart->prev = lr;
  };
};
void LineRegionsSupport::clearLine(int lno, String *line){
  // ignoring out of cached interval lines
  if (lno < firstLineNo || lno >= firstLineNo+lineCount) return;

  LineRegion *ln = getLineRegions(lno);
  while(ln != null){
    LineRegion *lnn = ln->next;
    delete ln;
    ln = lnn;
  };
  LineRegion *lfirst = new LineRegion(*schemeStack.lastElement());
  lfirst->start = 0;
  lfirst->end = -1;
  lfirst->next = null;
  lfirst->prev = lfirst;
  lineRegions.setElementAt(lfirst, lno-firstLineNo);
  flowBackground = lfirst;
};
Пример #4
0
PairMatch *BaseEditor::getPairMatch(int lineNo, int linePos)
{
  LineRegion *lrStart = getLineRegions(lineNo);
  if (lrStart == null){
    return null;
  }
  LineRegion *pair = null;
  for(LineRegion *l1 = lrStart; l1; l1 = l1->next){
    if ((l1->region->hasParent(def_PairStart) ||
         l1->region->hasParent(def_PairEnd)) &&
         linePos >= l1->start && linePos <= l1->end)
      pair = l1;
  }
  if (pair != null){
    PairMatch *pm = new PairMatch(pair, lineNo, pair->region->hasParent(def_PairStart));
    pm->setStart(pair);
    return pm;
  }
  return null;
}