Move by one page downward (if downward is true), or upward (if false).
Return true if we ended up changing the selection, false if not.
160279
function scrollOnePage(element, downward) {
  
  const scrollTarget = element[symbols.scrollTarget];
  const items = element.items;
  const selectedIndex = element.state.selectedIndex;

  // Determine the item visible just at the edge of direction we're heading.
  // We'll select that item if it's not already selected.
  const edge = scrollTarget.scrollTop + (downward ? scrollTarget.clientHeight : 0);
  const indexOfItemAtEdge = getIndexOfItemAtY(items, scrollTarget, edge, downward);

  let newIndex;
  if (indexOfItemAtEdge && selectedIndex === indexOfItemAtEdge) {
    // The item at the edge was already selected, so scroll in the indicated
    // direction by one page. Leave the new item at that edge selected.
    const delta = (downward ? 1 : -1) * scrollTarget.clientHeight;
    newIndex = getIndexOfItemAtY(items, scrollTarget, edge + delta, downward);
  }
  else {
    // The item at the edge wasn't selected yet. Instead of scrolling, we'll
    // just select that item. That is, the first attempt to page up/down
    // usually just moves the selection to the edge in that direction.
    newIndex = indexOfItemAtEdge;
  }

  if (!newIndex) {
    // We can't find an item in the direction we want to travel. Select the
    // last item (if moving downward) or first item (if moving upward).
    newIndex = (downward ? items.length - 1 : 0);
  }

  // If external code causes an operation that scrolls the page, it's impossible
  // for it to predict where the selectedIndex is going to end up. Accordingly,
  // we raise change events.
  const saveRaiseChangesEvents = element[symbols.raiseChangeEvents];
  element[symbols.raiseChangeEvents] = true;

  element.setState({
    selectedIndex: newIndex
  });

  element[symbols.raiseChangeEvents] = saveRaiseChangesEvents;

  const changed = element.state.selectedIndex !== selectedIndex;
  return changed;
}
1327937
def _onShortcutMoveLine(self, down):
        
        startBlock, endBlock = self._selectedBlocks()

        startBlockNumber = startBlock.blockNumber()
        endBlockNumber = endBlock.blockNumber()

        def _moveBlock(block, newNumber):
            text = block.text()
            with self:
                del self.lines[block.blockNumber()]
                self.lines.insert(newNumber, text)

        if down:  # move next block up
            blockToMove = endBlock.next()
            if not blockToMove.isValid():
                return

            # if operaiton is UnDone, marks are located incorrectly
            markMargin = self.getMargin("mark_area")
            if markMargin:
                markMargin.clearBookmarks(startBlock, endBlock.next())

            _moveBlock(blockToMove, startBlockNumber)

            self._selectLines(startBlockNumber + 1, endBlockNumber + 1)
        else:  # move previous block down
            blockToMove = startBlock.previous()
            if not blockToMove.isValid():
                return

            # if operaiton is UnDone, marks are located incorrectly
            markMargin = self.getMargin("mark_area")
            if markMargin:
                markMargin.clearBookmarks(startBlock, endBlock)

            _moveBlock(blockToMove, endBlockNumber)

            self._selectLines(startBlockNumber - 1, endBlockNumber - 1)

        if markMargin:
            markMargin.update()
200386
private function moveToNextLine(): bool
    {
        if ($this->currentLineNb >= \count($this->lines) - 1) {
            return false;
        }

        $this->currentLine = $this->lines[++$this->currentLineNb];

        return true;
    }
94674
private boolean hasChangedPosition(I_CmsDropTarget target) {

        if ((m_currentTarget != target) || (m_currentIndex != target.getPlaceholderIndex())) {
            m_currentTarget = target;
            m_currentIndex = target.getPlaceholderIndex();
            return true;
        }
        return false;
    }
1297302
function moveSelection(
    opts: Options,
    change: Change,
    x: number,
    y: number
): Change {
    const { value } = change;
    const { startKey } = value;
    const pos = TablePosition.create(opts, value.document, startKey);

    if (!pos.isInCell()) {
        throw new Error('moveSelection can only be applied from within a cell');
    }

    const { table } = pos;
    const row = table.nodes.get(y);
    const cell = row.nodes.get(x);

    return change.collapseToStartOf(cell);
}
1033923
protected void moveLeftToRight() {
        // Loop over the selected items and locate them in the data model, Add
        // these to the selection.
        Object[] sourceSelected = sourceList.getSelectedValues();
        int nSourceSelected = sourceSelected.length;
        int[] currentSelection = helperList.getSelectedIndices();
        int[] newSelection = new int[currentSelection.length + nSourceSelected];
        System.arraycopy(currentSelection, 0, newSelection, 0, currentSelection.length);
        int destPos = currentSelection.length;

        for (int i = 0; i < sourceSelected.length; i++) {
            newSelection[destPos++] = indexOf(sourceSelected[i]);
        }

        helperList.setSelectedIndices(newSelection);
        update();
    }
1344023
protected void moveSelectionBottom() {
		final IStructuredSelection selection = this.list.getStructuredSelection();
		final int index = this.conversions.indexOf(selection.getFirstElement());
		if (index >= 0 && (index + selection.size()) < this.conversions.size()) {
			for (int i = 0; i < selection.size(); ++i) {
				final ConversionMapping previous = this.conversions.remove(index);
				this.conversions.addLast(previous);
			}
			refreshListUI();
			this.list.refresh(true);
			enableButtons();
			preferenceValueChanged();
		}
	}
298168
function moveSelectionBy(
    opts: Options,
    change: Change,
    x: number, //  Move horizontally by x
    y: number // Move vertically by y
): Change {
    const { value } = change;
    const { startKey } = value;
    const pos = TablePosition.create(opts, value.document, startKey);
    if (!pos.isInCell()) {
        throw new Error('moveSelectionBy can only be applied in a cell');
    }

    const rowIndex = pos.getRowIndex();
    const colIndex = pos.getColumnIndex();
    const width = pos.getWidth();
    const height = pos.getHeight();

    const [absX, absY] = normPos(x + colIndex, y + rowIndex, width, height);
    const isGoingUp = y < 0;

    if (absX === -1) {
        // Out of table
        return change;
    }

    const { table } = pos;
    const row = table.nodes.get(absY);
    const cell = row.nodes.get(absX);

    if (isGoingUp) {
        change.collapseToEndOf(cell);
    } else {
        change.collapseToStartOf(cell);
    }

    return change;
}
1105687
function isBackwards(sel) {
	sel = sel || getSelection();
	if (isCollapsed(sel)) { return; }

	// Detect if selection is backwards
	var range = doc.createRange();
	range.setStart(sel.anchorNode, sel.anchorOffset);
	range.setEnd(sel.focusNode, sel.focusOffset);
	range.detach();

	// if `collapsed` then it's backwards
	return range.collapsed;
}
1315194
boolean lookForwardLineFeedAndEof() {
		int forwardBak = forward;
		int forwardRowBak = forwardRow;
		for (char c=peek(); true; c=next()) {
			if (CharTable.isBlank(c)) {
				continue ;
			}
			if (c == '\n' || c == EOF) {
				return true;
			}
			forward = forwardBak;
			forwardRow = forwardRowBak;
			return false;
		}
	}
929587
public boolean nextInOrder() {
        if (mNode == null) {
            return false;
        }
        if (firstChild()) {
            return true;
        }
        if (nextSibling()) {
            return true;
        }
        AccessibilityNodeInfoRef tmp = unOwned(mNode);
        while (tmp.parent()) {
            if (tmp.nextSibling()) {
                reset(tmp);
                return true;
            }
        }
        tmp.clear();
        return false;
    }
288613
function(direction) {
                var currentOrder = this.state.order,
                    newOrder = currentOrder;
                if (direction === PagingCollection.SortDirection.ASCENDING) {
                    newOrder = -1;
                } else if (direction === PagingCollection.SortDirection.DESCENDING) {
                    newOrder = 1;
                }
                if (newOrder !== currentOrder) {
                    this.setSorting(this.state.sortKey, newOrder);
                    this.isStale = true;
                }
            }
181655
public boolean isForwarded() {

        Iterator<A_CmsListDialog> i = m_wps.iterator();
        while (i.hasNext()) {
            A_CmsListDialog wp = i.next();
            if (wp.isForwarded()) {
                return true;
            }
        }
        return false;
    }
495085
private boolean isChangedPosition(I_CmsDropTarget target) {

        // if the new index is not next to the old one, the position has changed
        if ((target != m_initialDropTarget)
            || !((target.getPlaceholderIndex() == (m_originalIndex + 1))
                || (target.getPlaceholderIndex() == m_originalIndex))) {
            return true;
        }
        return false;
    }
199456
def would_move_be_promotion(self):
        
        return (self._end_loc.rank == 0 and not self.color) or \
            (self._end_loc.rank == 7 and self.color)
279617
protected void moveSelectionTop() {
		final IStructuredSelection selection = this.list.getStructuredSelection();
		final int index = this.conversions.indexOf(selection.getFirstElement());
		if (index > 0) {
			final int endIndex = index + selection.size() - 1;
			for (int i = 0; i < selection.size(); ++i) {
				final ConversionMapping next = this.conversions.remove(endIndex);
				this.conversions.addFirst(next);
			}
			refreshListUI();
			this.list.refresh(true);
			enableButtons();
			preferenceValueChanged();
		}
	}
152444
boolean compareAndSetLeaf(Page oldPage, Page page)
  {
    if (oldPage == page) {
      return true;
    }
    
    int pid = (int) page.getId();
    
    updateTailPid(pid);
    
    if (oldPage instanceof PageLeafImpl && page instanceof PageLeafImpl) {
      PageLeafImpl oldLeaf = (PageLeafImpl) oldPage;
      PageLeafImpl newLeaf = (PageLeafImpl) page;
      
      if (BlockTree.compareKey(oldLeaf.getMaxKey(), newLeaf.getMaxKey(), 0) < 0) {
        System.err.println(" DERP: " + oldPage + " " + page);
        Thread.dumpStack();
        /*
        throw new IllegalStateException("DERP: old=" + oldPage + " " + page
                                        + " old-dirt:" + oldPage.isDirty());
                                        */
      }
    }
    
    boolean result = _pages.compareAndSet(pid, oldPage, page);
    
    return result;
  }