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; }
private void fixupOffset(BaleRegion br, int off, boolean edit) { if (edit && region_map != null) { validateRegions(); RegionData rd = region_map.get(br); rd.fixupOffset(br, off); } validateRegions(); }
protected int mapRegionOffsetToView(BaleRegion br, int offset) { if (region_map != null) { validateRegions(); RegionData rd = region_map.get(br); return rd.getViewOffset(offset); } return offset; }
protected int mapViewOffsetToRegion(BaleRegion br, int offset, boolean edit) { if (region_map != null) { fixupOffset(br, offset, edit); RegionData rd = region_map.get(br); return rd.getRegionOffset(br, offset); } return offset; }
/** ***************************************************************************** */ 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; }