src/extensions/default/InlineTimingFunctionEditor/main.js
function prepareEditorForProvider(hostEditor, pos) {
        var cursorLine, sel, startPos, endPos, startBookmark, endBookmark, currentMatch,
            cm = hostEditor._codeMirror;

        sel = hostEditor.getSelection();
        if (sel.start.line !== sel.end.line) {
            return {timingFunction: null, reason: null};
        }

        cursorLine = hostEditor.document.getLine(pos.line);

        // code runs several matches complicated patterns, multiple times, so
        // first do a quick, simple check to see make sure we may have a match
        if (!cursorLine.match(/cubic-bezier|linear|ease|step/)) {
            return {timingFunction: null, reason: null};
        }

        currentMatch = TimingFunctionUtils.timingFunctionMatch(cursorLine, false);
        if (!currentMatch) {
            return {timingFunction: null, reason: Strings.ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX};
        }

        // check for subsequent matches, and use first match after pos
        var lineOffset = 0,
            matchLength = ((currentMatch.originalString && currentMatch.originalString.length) || currentMatch[0].length);
        while (pos.ch > (currentMatch.index + matchLength + lineOffset)) {
            var restOfLine = cursorLine.substring(currentMatch.index + matchLength + lineOffset),
                newMatch = TimingFunctionUtils.timingFunctionMatch(restOfLine, false);

            if (newMatch) {
                lineOffset += (currentMatch.index + matchLength);
                currentMatch = $.extend(true, [], newMatch);
            } else {
                break;
            }
        }

        currentMatch.lineOffset = lineOffset;

        startPos = {line: pos.line, ch: lineOffset + currentMatch.index};
        endPos   = {line: pos.line, ch: lineOffset + currentMatch.index + matchLength};

        startBookmark = cm.setBookmark(startPos);
        endBookmark   = cm.setBookmark(endPos);

        // Adjust selection to the match so that the inline editor won't
        // get dismissed while we're updating the timing function.
        hostEditor.setSelection(startPos, endPos);

        return {
            timingFunction: currentMatch,
            start: startBookmark,
            end: endBookmark
        };
    }
function prepareEditorForProvider(hostEditor, pos) {
        var cursorLine, sel, startPos, endPos, startBookmark, endBookmark, currentMatch,
            cm = hostEditor._codeMirror;

        sel = hostEditor.getSelection();
        if (sel.start.line !== sel.end.line) {
            return {timingFunction: null, reason: null};
        }

        cursorLine = hostEditor.document.getLine(pos.line);

        // code runs several matches complicated patterns, multiple times, so
        // first do a quick, simple check to see make sure we may have a match
        if (!cursorLine.match(/cubic-bezier|linear|ease|step/)) {
            return {timingFunction: null, reason: null};
        }

        currentMatch = TimingFunctionUtils.timingFunctionMatch(cursorLine, false);
        if (!currentMatch) {
            return {timingFunction: null, reason: Strings.ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX};
        }

        // check for subsequent matches, and use first match after pos
        var lineOffset = 0,
            matchLength = ((currentMatch.originalString && currentMatch.originalString.length) || currentMatch[0].length);
        while (pos.ch > (currentMatch.index + matchLength + lineOffset)) {
            var restOfLine = cursorLine.substring(currentMatch.index + matchLength + lineOffset),
                newMatch = TimingFunctionUtils.timingFunctionMatch(restOfLine, false);

            if (newMatch) {
                lineOffset += (currentMatch.index + matchLength);
                currentMatch = $.extend(true, [], newMatch);
            } else {
                break;
            }
        }

        currentMatch.lineOffset = lineOffset;

        startPos = {line: pos.line, ch: lineOffset + currentMatch.index};
        endPos   = {line: pos.line, ch: lineOffset + currentMatch.index + matchLength};

        startBookmark = cm.setBookmark(startPos);
        endBookmark   = cm.setBookmark(endPos);

        // Adjust selection to the match so that the inline editor won't
        // get dismissed while we're updating the timing function.
        hostEditor.setSelection(startPos, endPos);

        return {
            timingFunction: currentMatch,
            start: startBookmark,
            end: endBookmark
        };
    }
function prepareEditorForProvider ( hostEditor , pos ) { var cursorLine , sel , startPos , endPos , startBookmark , endBookmark , currentMatch , cm = hostEditor . _codeMirror ; sel = hostEditor . getSelection ( ) ; if ( sel . start . line !== sel . end . line ) { return { timingFunction : null , reason : null } ; } cursorLine = hostEditor . document . getLine ( pos . line ) ; // code runs several matches complicated patterns, multiple times, so // first do a quick, simple check to see make sure we may have a match if ( ! cursorLine . match ( / cubic-bezier|linear|ease|step / ) ) { return { timingFunction : null , reason : null } ; } currentMatch = TimingFunctionUtils . timingFunctionMatch ( cursorLine , false ) ; if ( ! currentMatch ) { return { timingFunction : null , reason : Strings . ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX } ; } // check for subsequent matches, and use first match after pos var lineOffset = 0 , matchLength = ( ( currentMatch . originalString && currentMatch . originalString . length ) || currentMatch [ 0 ] . length ) ; while ( pos . ch > ( currentMatch . index + matchLength + lineOffset ) ) { var restOfLine = cursorLine . substring ( currentMatch . index + matchLength + lineOffset ) , newMatch = TimingFunctionUtils . timingFunctionMatch ( restOfLine , false ) ; if ( newMatch ) { lineOffset += ( currentMatch . index + matchLength ) ; currentMatch = $ . extend ( true , [ ] , newMatch ) ; } else { break ; } } currentMatch . lineOffset = lineOffset ; startPos = { line : pos . line , ch : lineOffset + currentMatch . index } ; endPos = { line : pos . line , ch : lineOffset + currentMatch . index + matchLength } ; startBookmark = cm . setBookmark ( startPos ) ; endBookmark = cm . setBookmark ( endPos ) ; // Adjust selection to the match so that the inline editor won't // get dismissed while we're updating the timing function. hostEditor . setSelection ( startPos , endPos ) ; return { timingFunction : currentMatch , start : startBookmark , end : endBookmark } ; }
Functions 
Prepare hostEditor for an InlineTimingFunctionEditor at pos if possible.
Return editor context if so; otherwise null.

@param {Editor} hostEditor
@param {{line:Number, ch:Number}} pos
@return {timingFunction:{?string}, reason:{?string}, start:{?TextMarker}, end:{?TextMarker}}
Functions Prepare hostEditor for an InlineTimingFunctionEditor at pos if possible . Return editor context if so ; otherwise null .