Get a Selection's Range
@see http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376
@param {Selection} sel
@return {Range|null}
430464
function getRange(sel) {
	sel = sel || getSelection();
	return sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
}
548892
function selectedText(editor) {
    restoreRange(editor);
    if (ie) return getRange(editor).text;
    return getSelection(editor).toString();
  }
437649
def selection_range
      from = [@text_input.selection_start, caret_position].min
      to = [@text_input.selection_start, caret_position].max

      (from...to)
    end
801941
function getItemsAtRange(
    opts: Options,
    value: Value,
    range?: Range
): List<Block> {
    range = range || value.selection;

    if (!range.startKey) {
        return List();
    }

    const { document } = value;

    const startBlock = document.getClosestBlock(range.startKey);
    const endBlock = document.getClosestBlock(range.endKey);

    if (startBlock === endBlock) {
        const item = getCurrentItem(opts, value, startBlock);
        return item ? List([item]) : List();
    }

    const ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);

    if (isList(opts, ancestor)) {
        const startPath = ancestor.getPath(startBlock.key);
        const endPath = ancestor.getPath(endBlock.key);

        return ancestor.nodes.slice(startPath[0], endPath[0] + 1);
    } else if (ancestor.type === opts.typeItem) {
        // The ancestor is the highest list item that covers the range
        return List([ancestor]);
    }
    // No list of items can cover the range
    return List();
}
649519
public INDArray getRange() {
        if (range == null) {
            try (MemoryWorkspace ws = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
                range = upper.sub(lower);
            }
        }
        return range;
    }
103421
function getrange(key, start, end, req) {
  var val = this.getKey(key, req);
  if(!val) return '';
  start = parseInt(start);
  end = parseInt(end);
  if(start < 0) start = val.length + start;
  if(end < 0) end = val.length + end;
  // TODO: buffer compat
  return (val + '').substr(start, end + 1);
}
618193
function getRangeBeforeCursor( cursor ) {
				var range = editor.createRange();
				range.setStartAt( editor.editable(), CKEDITOR.POSITION_AFTER_START );
				range.setEnd( cursor.textNode, cursor.offset );
				return range;
			}
462310
TokenRange range(JavaToken begin, JavaToken end) {
        if (storeTokens) {
            return new TokenRange(begin, end);
        }
        return null;
    }
998428
function getRangeInformation(range, selectionMgr) {
  const $selectedCells = selectionMgr.getSelectedCells();
  let rangeInformation, startCell;

  if ($selectedCells.length) {
    rangeInformation = selectionMgr.getSelectionRangeFromTable($selectedCells.first().get(0),
      $selectedCells.last().get(0));
  } else {
    const {startContainer} = range;
    startCell = domUtil.isTextNode(startContainer) ? $(startContainer).parent('td,th')[0] : startContainer;
    rangeInformation = selectionMgr.getSelectionRangeFromTable(startCell, startCell);
  }

  return rangeInformation;
}
773852
function selectionGet()
			{
				// for webkit, mozilla, opera
				if (window.getSelection)
					return window.getSelection();
				// for ie
				else if (document.selection && document.selection.createRange && document.selection.type != "None")
					return document.selection.createRange();
			}
821198
function getRangesFromCSSNode(node) {
	let ranges;

	if (node.type === 'rule') {
		ranges = [ getRange(node.selectorToken) ].concat(node.parsedSelector.map(getRange));
	} else if (node.type === 'at-rule') {
		const nameEndToken = node.expressionToken || node.nameToken;
		ranges = [
			new Range(node.nameToken.start, nameEndToken.end),
			getRange(node.nameToken),
			getRange(node.expressionToken)
		];
		node.parsedExpression.forEach(token => {
			ranges.push(getRange(token));
			iterateCSSToken(token, t => {
				if (t.type === 'argument') {
					ranges.push(getRange(t));
				}
			});
		});
	} else if (node.type === 'property') {
		ranges = [
			getRange(node),
			getRange(node.nameToken),
			getRange(node.valueToken)
		];
		node.parsedValue.forEach(value => {
			// parsed value contains a comma-separated list of sub-values,
			// each of them, it turn, may contain space-separated parts
			ranges.push(getRange(value));

			for (let i = 0, il = value.size, token; i < il; i++) {
				token = value.item(i);
				if (token.type === 'url') {
					ranges.push(getRange(token), getRange(token.item(0)));
				} else if (token.type !== 'whitespace' && token !== 'comment') {
					ranges.push(getRange(token));

					iterateCSSToken(token, t => {
						if (t.type === 'argument') {
							ranges.push(getRange(t));
						}
					});
				}
			}
		});
	}

	return ranges ? uniqueRanges(ranges.filter(Boolean)) : [];
}
410474
function getRange() {
  const selection = window.getSelection();
  let range;

  if (selection && selection.rangeCount) {
    range = selection.getRangeAt(0).cloneRange();
  } else {
    range = document.createRange();
    range.selectNodeContents(this.preview.$el[0]);
    range.collapse(true);
  }

  return range;
}
213399
function getNextItemRange(model, anchor, getItemRanges) {
	// Find HTML node for next selection
	let node = nodeForPoint(model, anchor.start, 'next');
	let range;

	// We might need to narrow down node context to find best token match
	while (node && !range) {
		range = getNextRange(getItemRanges(node), anchor);
		node = node.firstChild || nextSibling(node);
	}

	return range;
}
217183
def selection_range(self):  # XXX: shouldn't this return `None` if there is no selection???
        
        if self.selection:
            from_, to = sorted([self.cursor_position, self.selection.original_cursor_position])
        else:
            from_, to = self.cursor_position, self.cursor_position

        return from_, to
507088
function(_document,_force){
                var _r = _getSelectionRange(_document);
                if (_force || !_sameRange(_r, _ranges.get(_document))) {
                    _ranges.set(_document, _r);
                    setTimeout(function(){
                        console.log('selectionchange')
                        _v._$dispatchEvent(_document,'selectionchange');
                    }, 0);
                }
            }
1089305
function find(n, sel){
    if(typeof n === 'string'){
      sel = n;
      n = false;
    }
    if(typeof document.querySelectorAll !== 'undefined'){
      return (n||document).querySelectorAll( sel );
    }else{
      error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine');
    }
  }
1066347
def selection_range(self):
        
        selected = self.selectionModel().selection()
        """:type: QItemSelection """

        if selected.isEmpty():
            return -1, -1, -1, -1

        min_row = numpy.min([rng.top() for rng in selected])
        max_row = numpy.max([rng.bottom() for rng in selected])
        start = numpy.min([rng.left() for rng in selected])
        end = numpy.max([rng.right() for rng in selected]) + 1

        return min_row, max_row, start, end