Search for nearest CSS rule/section that contains
given position
@param  {String} content CSS content or matched CSS rules (array of ranges)
@param  {Number} pos     Search position
@return {Range}
506603
function(content, pos) {
			if (typeof content === 'string') {
				content = this.findAllRules(content);
			}

			var rules = content.filter(function(r) {
				return r.inside(pos);
			});

			return utils.last(rules);
		}
651308
function(content, pos) {
			var lineRange = this.findNewlineBounds(content, pos);
			return this.getLinePadding(lineRange.substring(content));
		}
715766
function compile(pos) {
  var values = []

  if (!pos) {
    return null
  }

  values = [[pos.line || 1, pos.column || 1].join(':')]

  if ('offset' in pos) {
    values.push(String(pos.offset || 0))
  }

  return values
}
143747
function posBar(_pos) {
            if (this.bar) {
                var was = css(this.bar, this.origin.pos),
                    will = +_pos + 'px'

                if (will && will != was) {
                    css(this.bar, this.origin.pos, will)
                }
            }
        }
356636
public static function getRangeFromPosition(int $pos, int $length, string $text): Range {
        $start = self::getLineCharacterPositionFromPosition($pos, $text);
        $end = self::getLineCharacterPositionFromPosition($pos + $length, $text);

        return new Range($start, $end);
    }
360168
function(destId, pos, options) {
                corbel.validate.value('destId', destId);
                var positionStartId = destId.indexOf('/');
                if (positionStartId !== -1) {
                    destId = destId.substring(positionStartId + 1);
                }

                options = this.getDefaultOptions(options);

                var args = corbel.utils.extend(options, {
                    url: this.buildUri(this.type, this.srcId, this.destType, destId),
                    contentType: 'application/json',
                    data: {
                        '_order': '$pos(' + pos + ')'
                    },
                    method: corbel.request.method.PUT
                });

                return this.request(args);
            }
608714
function(text, pos) {
			var result = this.find(text, pos);
			if (result && result.type == 'tag') {
				return result;
			}
		}
422490
function(pos) {
			if (!this.range.inside(pos)) {
				return null;
			}

			for (var i = 0, il = this.children.length, m; i < il; i++) {
				m = this.children[i].matchDeep(pos);
				if (m) {
					return m;
				}
			};

			return this.parent ? this : null;
		}
1182520
function (content, block, target, type, attbs, alternateSearchPaths, handler) {
    var linefeed = /\r\n/g.test(content) ? '\r\n' : '\n',
        lines = block.split(linefeed),
        ref = '',
        indent = (lines[0].match(/^\s*/) || [])[0],
        ccmatches = block.match(regcc),
        blockContent = lines.slice(1, -1).join('');

    target = target || 'replace';

    if (type === 'css') {

        // Check to see if there are any css references at all.
        if( blockContent.search(regcss) !== -1 )
        {
            if(attbs) {
              ref = '<link rel="stylesheet" href="' + target + '" ' + attbs + '>';
            } else {
              ref = '<link rel="stylesheet" href="' + target + '">';
            }
        }

    } else if (type === 'js') {

        // Check to see if there are any js references at all.
        if( blockContent.search(regscript) !== -1 )
        {
            if(attbs) {
              ref = '<script src="' + target + '" ' + attbs + '></script>';
            } else {
              ref = '<script src="' + target + '"></script>';
            }
        }

    } else if (type === 'remove') {
        ref = '';
    } else if (handler) {
      ref = handler(blockContent, target, attbs, alternateSearchPaths);
    }
    else {
      ref = null;
    }

    if(ref != null) {
      ref = indent + ref;

      // Reserve IE conditional comment if exist
      if (ccmatches) {
        ref = indent + ccmatches[1] + linefeed + ref + linefeed + indent + ccmatches[2];
      }

      return content.replace(block, ref);
    }
    else { return content; }
  }
484814
function(pos, width){
		if( arguments.length === 0 ){
			pos = this.gradient[0].getPosition();
			var last = this.gradient[this.gradient.length-1].getPosition();
			width = Math.floor(last - pos);
		}

		var result = new ColorList();
		if( this.gradient.length === 0 ){
			return result;
		}

		var frac = 0,
			currPoint, nextPoint,
			endPos = pos + width,
			i = 0,
			l = this.gradient.length;

		for( i=0; i<l; i++ ){
			if( this.gradient[i].pos < pos ){
				currPoint = this.gradient[i];
			}
		}

		var isPremature = (currPoint===undefined),
			activeGradient;
		if( !isPremature ){
			activeGradient = filter(this.gradient, function( g ){ return g.pos >= currPoint.pos; });
		} else {
			//start position is before 1st gradient color, so use whole
			activeGradient = this.gradient;
			currPoint = this.gradient[0];
		}

		var currWidth = 0;
		//start over with i, and use it to iterate
		i = 0;
		l = activeGradient.length;
		if( currPoint !== activeGradient[l-1] ){
			nextPoint = activeGradient[i];
			if( isPremature ){
				var d = currPoint.pos - pos;
				currWidth = mathUtils.abs( d ) > 0 ? 1 / d : 1;
			} else {
				if( nextPoint.pos - currPoint.pos > 0 ) {
					currWidth = 1 / (nextPoint.pos - currPoint.pos);
				}
			}
		}
		while( pos < endPos ){
			if( isPremature ){
				frac = 1 - (currPoint.pos - pos) * currWidth;
			} else {
				frac = (pos - currPoint.pos) * currWidth;
			}
			//switch to next color?
			if( frac > 1.0 ){
				currPoint = nextPoint;
				isPremature = false;
				i++;
				if( i < activeGradient.length ){
					nextPoint = activeGradient[i];
					if( currPoint !== activeGradient[l-1] ){
						currWidth = 1 / (nextPoint.pos - currPoint.pos);
					} else {
						currWidth = 0;
					}
					frac = (pos - currPoint.pos) * currWidth;
				}
			}
			if( currPoint  !== activeGradient[l-1] ){
				var ditheredFrac = mathUtils.clip( frac+mathUtils.normalizedRandom() * this.maxDither, 0, 1 );
				ditheredFrac = this.interpolator.interpolate( 0, 1, ditheredFrac );
				result.add( currPoint.color.getBlended(nextPoint.color, ditheredFrac) );
			} else {
				result.add( currPoint.color.copy() );
			}
			pos++;
		}
		return result;

	}
901679
function(content, pos, isBackward) {
			var bounds = this.extractTag(content, pos, isBackward);
			if (!bounds || !bounds.inside(pos))
				// no matching HTML tag or caret outside tag bounds
				return null;
			
			return this.parse(bounds.substring(content), {
				offset: bounds.start
			});
		}
528323
function findNextHTMLItem(editor) {
		var isFirst = true;
		return findItem(editor, false, function(content, searchPos){
			if (isFirst) {
				isFirst = false;
				return findOpeningTagFromPosition(content, searchPos);
			} else {
				return getOpeningTagFromPosition(content, searchPos);
			}
		}, function(tag, offset, selRange) {
			return getRangeForHTMLItem(tag, offset, selRange, false);
		});
	}
305846
function(editor, pos) {
			var allowedSyntaxes = {'html': 1, 'xml': 1, 'xsl': 1, 'jsx': 1};
			var syntax = editor.getSyntax();
			if (syntax in allowedSyntaxes) {
				var content = editor.getContent();
				if (typeof pos === 'undefined') {
					pos = editor.getCaretPos();
				}

				var tag = htmlMatcher.find(content, pos);
				if (tag && tag.type == 'tag') {
					var startTag = tag.open;
					var contextNode = {
						name: startTag.name,
						attributes: [],
						match: tag
					};
					
					// parse attributes
					var tagTree = xmlEditTree.parse(startTag.range.substring(content));
					if (tagTree) {
						contextNode.attributes = tagTree.getAll().map(function(item) {
							return {
								name: item.name(),
								value: item.value()
							};
						});
					}
					
					return contextNode;
				}
			}
			
			return null;
		}
298358
private void seekNonWs(final String pattern, final ParsePosition pos) {
        int len = 0;
        final char[] buffer = pattern.toCharArray();
        do {
            len = StrMatcher.splitMatcher().isMatch(buffer, pos.getIndex());
            pos.setIndex(pos.getIndex() + len);
        } while (len > 0 && pos.getIndex() < pattern.length());
    }
377392
function findNextNonSpacePoint(editor, pos) {
	const stream = new BufferStreamReader(editor.getBuffer(), pos);
	stream.eatWhile(isSpace);
	return stream.pos;
}
1306111
function(pos) {
        var p = pos || Dom.getXY(this.getEl());

        this.deltaSetXY = null;

        this.startPageX = p[0];
        this.startPageY = p[1];
    }
718007
function(elem, pos) {
            if (elem.setSelectionRange) {
                elem.setSelectionRange(pos, pos);
            } else if (elem.createTextRange) {
                var range = elem.createTextRange();
                range.collapse(true);
                range.moveEnd('character', pos);
                range.moveStart('character', pos);
                range.select();
            }
        }