Skip to content

Commit

Permalink
Rename navigator to clarify usage; remove middle-man method
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMartinez committed Oct 27, 2017
1 parent 343499b commit 1e550d9
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public Optional<Tuple2<Codec<PS>, Codec<StyledSegment<SEG, S>>>> getStyleCodecs(

// used for two-level navigation, where on the higher level are
// paragraphs and on the lower level are lines within a paragraph
private final TwoLevelNavigator navigator;
private final TwoLevelNavigator paragraphLineNavigator;

private boolean followCaretRequested = false;

Expand Down Expand Up @@ -724,7 +724,7 @@ public GenericStyledArea(
// initialize navigator
IntSupplier cellCount = () -> getParagraphs().size();
IntUnaryOperator cellLength = i -> virtualFlow.getCell(i).getNode().getLineCount();
navigator = new TwoLevelNavigator(cellCount, cellLength);
paragraphLineNavigator = new TwoLevelNavigator(cellCount, cellLength);

viewportDirty = merge(
// no need to check for width & height invalidations as scroll values update when these do
Expand Down Expand Up @@ -891,7 +891,7 @@ TwoDimensional.Position currentLine() {
int parIdx = getCurrentParagraph();
Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell = virtualFlow.getCell(parIdx);
int lineIdx = cell.getNode().getCurrentLineIndex();
return _position(parIdx, lineIdx);
return paragraphLineNavigator.position(parIdx, lineIdx);
}

@Override
Expand All @@ -900,10 +900,6 @@ public final int lineIndex(int paragraphIndex, int columnPosition) {
return cell.getNode().getCurrentLineIndex(columnPosition);
}

TwoDimensional.Position _position(int par, int line) {
return navigator.position(par, line);
}

@Override
public int getParagraphLinesCount(int paragraphIndex) {
return virtualFlow.getCell(paragraphIndex).getNode().getLineCount();
Expand Down

0 comments on commit 1e550d9

Please sign in to comment.