Search in sources :

Example 6 with Pos

use of net.codemirror.lib.Pos in project gerrit by GerritCodeReview.

the class UnifiedChunkManager method markEdit.

private void markEdit(DisplaySide side, int startLine, JsArrayString lines, JsArray<Span> edits) {
    if (lines == null || edits == null) {
        return;
    }
    EditIterator iter = new EditIterator(lines, startLine);
    Configuration bg = Configuration.create().set("className", getIntralineBgFromSide(side)).set("readOnly", true);
    Configuration diff = Configuration.create().set("className", getDiffColorFromSide(side)).set("readOnly", true);
    Pos last = Pos.create(0, 0);
    for (Span span : Natives.asList(edits)) {
        Pos from = iter.advance(span.skip());
        Pos to = iter.advance(span.mark());
        if (from.line() == last.line()) {
            getMarkers().add(cm.markText(last, from, bg));
        } else {
            getMarkers().add(cm.markText(Pos.create(from.line(), 0), from, bg));
        }
        getMarkers().add(cm.markText(from, to, diff));
        last = to;
        colorLines(cm, LineClassWhere.BACKGROUND, getDiffColorFromSide(side), from.line(), to.line());
    }
}
Also used : Configuration(net.codemirror.lib.Configuration) Pos(net.codemirror.lib.Pos) Span(com.google.gerrit.client.diff.DiffInfo.Span)

Example 7 with Pos

use of net.codemirror.lib.Pos in project gerrit by GerritCodeReview.

the class CommentManager method adjustSelection.

static FromTo adjustSelection(CodeMirror cm) {
    FromTo fromTo = cm.getSelectedRange();
    Pos to = fromTo.to();
    if (to.ch() == 0) {
        to.line(to.line() - 1);
        to.ch(cm.getLine(to.line()).length());
    }
    return fromTo;
}
Also used : Pos(net.codemirror.lib.Pos) FromTo(net.codemirror.lib.TextMarker.FromTo)

Aggregations

Pos (net.codemirror.lib.Pos)7 Span (com.google.gerrit.client.diff.DiffInfo.Span)2 Configuration (net.codemirror.lib.Configuration)2 FromTo (net.codemirror.lib.TextMarker.FromTo)2 LineOnOtherInfo (com.google.gerrit.client.diff.LineMapper.LineOnOtherInfo)1 LineRegionInfo (com.google.gerrit.client.diff.UnifiedChunkManager.LineRegionInfo)1