protected boolean getRegionText(BaleRegion br, int off, int len, Segment text) throws BadLocationException { int soff = br.getStart(); int eoff = br.getEnd(); if (region_map != null) { validateRegions(); RegionData rd = region_map.get(br); Segment rtext = new Segment(); base_document.getText(soff, eoff - soff, rtext); return rd.getText(rtext, off, len, text); } int doff = off + soff; int dlen = len; boolean lastbad = false; if (br.includesEol()) { if (doff + dlen > eoff) dlen = eoff - off; base_document.getText(doff, len, text); } else { if (doff + dlen > eoff) dlen = eoff - off + 1; base_document.getText(doff, len, text); lastbad = (doff + len > eoff); // if last character might be bad } return lastbad; }
/** ***************************************************************************** */ protected int getRegionLength(BaleRegion br) { int len = br.getEnd() - br.getStart(); if (!br.includesEol()) len += 1; if (region_map != null) { validateRegions(); RegionData rd = region_map.get(br); len += rd.getDeltaLength(); } return len; }