Search for abbreviation in editor from current caret position
@param {IEmmetEditor} editor Editor instance
@return {String}
184827
function findAbbreviation(editor) {
		var r = range(editor.getSelectionRange());
		var content = String(editor.getContent());
		if (r.length()) {
			// abbreviation is selected by user
			return r.substring(content);
		}
		
		// search for new abbreviation from current caret position
		var curLine = editor.getCurrentLineRange();
		return actionUtils.extractAbbreviation(content.substring(curLine.start, r.start));
	}
104737
function Editor(options) {
    this.options = options;
    window.indentUnit = options.indentUnit;
    this.parent = parent;
    this.doc = document;
    var container = this.container = this.doc.body;
    this.win = window;
    this.history = new History(container, options.undoDepth, options.undoDelay, this);
    var self = this;

    if (!Editor.Parser)
      throw "No parser loaded.";
    if (options.parserConfig && Editor.Parser.configure)
      Editor.Parser.configure(options.parserConfig);

    if (!options.readOnly)
      select.setCursorPos(container, {node: null, offset: 0});

    this.dirty = [];
    this.importCode(options.content || "");
    this.history.onChange = options.onChange;

    if (!options.readOnly) {
      if (options.continuousScanning !== false) {
        this.scanner = this.documentScanner(options.passTime);
        this.delayScanning();
      }

      function setEditable() {
        // In IE, designMode frames can not run any scripts, so we use
        // contentEditable instead.
        if (document.body.contentEditable != undefined && internetExplorer)
          document.body.contentEditable = "true";
        else
          document.designMode = "on";

        document.documentElement.style.borderWidth = "0";
        if (!options.textWrapping)
          container.style.whiteSpace = "nowrap";
      }

      // If setting the frame editable fails, try again when the user
      // focus it (happens when the frame is not visible on
      // initialisation, in Firefox).
      try {
        setEditable();
      }
      catch(e) {
        var focusEvent = addEventHandler(document, "focus", function() {
          focusEvent();
          setEditable();
        }, true);
      }

      addEventHandler(document, "keydown", method(this, "keyDown"));
      addEventHandler(document, "keypress", method(this, "keyPress"));
      addEventHandler(document, "keyup", method(this, "keyUp"));

      function cursorActivity() {self.cursorActivity(false);}
      addEventHandler(document.body, "mouseup", cursorActivity);
      addEventHandler(document.body, "cut", cursorActivity);

      // workaround for a gecko bug [?] where going forward and then
      // back again breaks designmode (no more cursor)
      if (gecko)
        addEventHandler(this.win, "pagehide", function(){self.unloaded = true;});

      addEventHandler(document.body, "paste", function(event) {
        cursorActivity();
        var text = null;
        try {
          var clipboardData = event.clipboardData || window.clipboardData;
          if (clipboardData) text = clipboardData.getData('Text');
        }
        catch(e) {}
        if (text !== null) {
          event.stop();
          self.replaceSelection(text);
          select.scrollToCursor(self.container);
        }
      });

      if (this.options.autoMatchParens)
        addEventHandler(document.body, "click", method(this, "scheduleParenHighlight"));
    }
    else if (!options.textWrapping) {
      container.style.whiteSpace = "nowrap";
    }
  }
672203
function(editor, filepath) {
			var data = String(editor.getSelection());
			var caretPos = editor.getCaretPos();
			var info = editorUtils.outputInfo(editor);

			if (!data) {
				// no selection, try to find image bounds from current caret position
				var text = info.content, m;
				while (caretPos-- >= 0) {
					if (startsWith('src=', text, caretPos)) { // found <img src="">
						if ((m = text.substr(caretPos).match(/^(src=(["'])?)([^'"<>\s]+)\1?/))) {
							data = m[3];
							caretPos += m[1].length;
						}
						break;
					} else if (startsWith('url(', text, caretPos)) { // found CSS url() pattern
						if ((m = text.substr(caretPos).match(/^(url\((['"])?)([^'"\)\s]+)\1?/))) {
							data = m[3];
							caretPos += m[1].length;
						}
						break;
					}
				}
			}

			if (data) {
				if (startsWith('data:', data)) {
					return decodeFromBase64(editor, filepath, data, caretPos);
				} else {
					return encodeToBase64(editor, data, caretPos);
				}
			}

			return false;
		}
1238616
function(editorContext, options) {
			var that = this;
			var deferred = new Deferred();
			editorContext.getFileMetadata().then(function(metadata) {
				if(Array.isArray(metadata.parents) && metadata.parents.length > 1) {
					that.scriptResolver.setSearchLocation(metadata.parents[metadata.parents.length - 1].Location);
				} else {
					that.scriptResolver.setSearchLocation(null);	
				}
	    		return that._doRename(editorContext, options, deferred);
			}, /* @callback */ function(err) {
				deferred.reject({Severity: 'Error', Message: Messages['noFileMeta']}); //$NON-NLS-1$
			});
			return deferred;
		}
25109
function getInlineEditors(hostEditor) {
        var inlineEditors = [];

        if (hostEditor) {
            hostEditor.getInlineWidgets().forEach(function (widget) {
                if (widget instanceof InlineTextEditor && widget.editor) {
                    inlineEditors.push(widget.editor);
                }
            });
        }

        return inlineEditors;
    }
533125
function markExtension(editor) {
  const ml = new MarkerList();
  const mm = new MarkerManager(ml);
  let wmh, mmh, vmh;

  editor.eventManager.addEventType('markerUpdated');

  if (editor.isViewer()) {
    vmh = new ViewerMarkerHelper(editor.preview);
  } else {
    wmh = new WysiwygMarkerHelper(editor.getSquire());
    mmh = new MarkdownMarkerHelper(editor.getCodeMirror());
  }

  /**
   * getHelper
   * Get helper for current situation
   * @returns {object} helper
   */
  function getHelper() {
    let helper;

    if (editor.isViewer()) {
      helper = vmh;
    } else if (editor.isWysiwygMode()) {
      helper = wmh;
    } else {
      helper = mmh;
    }

    return helper;
  }

  /**
   * Update mark when resizing
   */
  function updateMarkWhenResizing() {
    const helper = getHelper();

    ml.getAll().forEach(marker => {
      helper.updateMarkerWithExtraInfo(marker);
    });

    editor.eventManager.emit('markerUpdated', ml.getAll());
  }

  // We need to update marker after window have been resized
  $(window).on('resize', updateMarkWhenResizing);

  editor.on('removeEditor', () => {
    $(window).off('resize', updateMarkWhenResizing);
  });

  // Reset marker content after set value
  editor.on('setMarkdownAfter', () => {
    const helper = getHelper();
    mm.resetContent(helper.getTextContent());
  });

  /**
   * setValueWithMarkers
   * Set value with markers
   * @param {string} value markdown content
   * @param {object} markerDataCollection marker data that obtain with exportMarkers method
   * @returns {Array.<object>} markers
   */
  editor.setValueWithMarkers = (value, markerDataCollection) => {
    let helper;

    ml.resetMarkers();

    markerDataCollection.forEach(markerData => {
      ml.addMarker(markerData.start, markerData.end, markerData.id);
    });

    editor.setValue(value);

    mm.resetContent(value.replace(FIND_CRLF_RX, ''));

    if (editor.isViewer() || editor.isWysiwygMode()) {
      helper = getHelper();
      mm.updateMarkersByContent(helper.getTextContent());
    } else {
      helper = mmh;
    }

    ml.getAll().forEach(marker => {
      helper.updateMarkerWithExtraInfo(marker);
    });

    editor.eventManager.emit('markerUpdated', ml.getAll());

    return ml.getAll();
  };

  /**
   * getMarker
   * Get markers that have given id
   * @param {string} id id of marker
   * @returns {object}
   */
  editor.getMarker = id => ml.getMarker(id);

  /**
   * getMarkersAll
   * Get all markers
   * @returns {Array.<object>}
   */
  editor.getMarkersAll = () => ml.getAll();

  /**
   * removeMarker
   * Remove marker with given id
   * @param {string} id of marker that should be removed
   * @returns {marker} removed marker
   */
  editor.removeMarker = id => ml.removeMarker(id);

  /**
   * getMarkersData
   * Get marker data to export so you can restore markers next time
   * @returns {object} markers data
   */
  editor.exportMarkers = () => {
    let markersData;

    if (editor.isMarkdownMode()) {
      markersData = ml.getMarkersData();
    } else if (editor.isViewer() || editor.isWysiwygMode()) {
      mm.updateMarkersByContent(editor.getValue().replace(FIND_CRLF_RX, ''));
      markersData = ml.getMarkersData();
      mm.updateMarkersByContent(getHelper().getTextContent());
    }

    return markersData;
  };

  /**
   * selectMarker
   * Make selection with marker that have given id
   * @param {string} id id of marker
   */
  editor.selectMarker = id => {
    const helper = getHelper();
    const marker = editor.getMarker(id);

    if (marker) {
      helper.selectOffsetRange(marker.start, marker.end);
    }
  };

  /**
   * addMarker
   * Add Marker with given id
   * if you pass just id then it uses current selection for marker
   * or you can pass start and end offset for marker
   * @param {number|string} start start offset or id
   * @param {number} end end offset
   * @param {string} id id of marker
   * @returns {object} marker that have made
   */
  editor.addMarker = (start, end, id) => {
    let marker;
    const helper = getHelper();

    if (!id) {
      id = start;
      marker = helper.getMarkerInfoOfCurrentSelection();
    } else {
      marker = {
        start,
        end
      };

      marker = helper.updateMarkerWithExtraInfo(marker);
    }

    if (marker) {
      marker.id = id;
      marker = ml.addMarker(marker);
      ml.sortBy('end');
      editor.eventManager.emit('markerUpdated', [marker]);
    }

    return marker;
  };

  /**
   * clearSelect
   * Clear selection
   */
  editor.clearSelect = () => {
    getHelper().clearSelect();
  };

  if (!editor.isViewer()) {
    editor.on('changeMode', () => {
      editor._updateMarkers();
    });

    editor.on('change', util.debounce(() => {
      editor._updateMarkers();
    }, MARKER_UPDATE_DELAY));

    /**
     * _updateMarkers
     * Update markers with current text content
     */
    editor._updateMarkers = () => {
      const helper = getHelper();

      if (!ml.getAll().length) {
        return;
      }

      mm.updateMarkersByContent(helper.getTextContent());

      ml.getAll().forEach(marker => {
        helper.updateMarkerWithExtraInfo(marker);
      });

      editor.eventManager.emit('markerUpdated', ml.getAll());
    };
  }
}
220761
function(editor, syntax, profile) {
			var info = editorUtils.outputInfo(editor, syntax, profile);
			if (!~cssSyntaxes.indexOf(info.syntax)) {
				return false;
			}
			
			// let's see if we are expanding gradient definition
			var caret = editor.getCaretPos();
			var content = info.content;
			var gradients = this.gradientsFromCSSProperty(content, caret);
			if (gradients) {
				if (!isValidCaretPosition(gradients, caret, info.syntax)) {
					return false;
				}

				var cssProperty = gradients.property;
				var cssRule = cssProperty.parent;
				var ruleStart = cssRule.options.offset || 0;
				var ruleEnd = ruleStart + cssRule.toString().length;
				
				// Handle special case:
				// user wrote gradient definition between existing CSS 
				// properties and did not finished it with semicolon.
				// In this case, we have semicolon right after gradient 
				// definition and re-parse rule again
				if (/[\n\r]/.test(cssProperty.value())) {
					// insert semicolon at the end of gradient definition
					var insertPos = cssProperty.valueRange(true).start + utils.last(gradients.gradients).matchedPart.end;
					content = utils.replaceSubstring(content, ';', insertPos);
					
					var _gradients = this.gradientsFromCSSProperty(content, caret);
					if (_gradients) {
						gradients = _gradients;
						cssProperty = gradients.property;
						cssRule = cssProperty.parent;
					}
				}
				
				// make sure current property has terminating semicolon
				cssProperty.end(';');
				
				// resolve CSS property name
				var resolvedName = resolvePropertyName(cssProperty.name(), syntax);
				if (resolvedName) {
					cssProperty.name(resolvedName);
				}
				
				pasteGradient(cssProperty, gradients.gradients);
				editor.replaceContent(cssRule.toString(), ruleStart, ruleEnd, true);
				return true;
			}
			
			return this.expandGradientOutsideValue(editor, syntax);
		}
183365
function getAttributeQuote(editor, attr) {
	const range = new Range(attr.value ? attr.value.end : attr.end, attr.end);
	return range.isEmpty() ? '' : editor.getTextInBufferRange(range);
}
456935
function(editor, abbr) {
			abbr = abbr || editor.prompt("Enter abbreviation");

			if (!abbr) {
				return false;
			}

			var content = editor.getContent();
			var ctx = actionUtils.captureContext(editor);
			var tag = this.getUpdatedTag(abbr, ctx, content);

			if (!tag) {
				// nothing to update
				return false;
			}

			// check if tag name was updated
			if (tag.name() != ctx.name && ctx.match.close) {
				editor.replaceContent('</' + tag.name() + '>', ctx.match.close.range.start, ctx.match.close.range.end, true);
			}

			editor.replaceContent(tag.source, ctx.match.open.range.start, ctx.match.open.range.end, true);
			return true;
		}
335773
function( editor ) {

			// Preview is not used for the inline creator.
			if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE )
				return;

			pluginPath = this.path;

			editor.addCommand( pluginName, previewCmd );
			editor.ui.addButton && editor.ui.addButton( 'Preview', {
				label: editor.lang.preview.preview,
				command: pluginName,
				toolbar: 'document,40'
			} );
		}
879145
def get_editor_buffer_for_location(self, location):
        
        for eb in self.editor_buffers:
            if eb.location == location:
                return eb
308973
function( editor, output )
		{
			var env = CKEDITOR.env;

			var id = 'cke_' + this.id;
			var clickFn = CKEDITOR.tools.addFunction( function( $element )
				{
					var _ = this._;

					if ( _.state == CKEDITOR.TRISTATE_DISABLED )
						return;

					this.createPanel( editor );

					if ( _.on )
					{
						_.panel.hide();
						return;
					}

					this.commit();
					var value = this.getValue();
					if ( value )
						_.list.mark( value );
					else
						_.list.unmarkAll();

					_.panel.showBlock( this.id, new CKEDITOR.dom.element( $element ), 4 );
				},
				this );

			var instance = {
				id : id,
				combo : this,
				focus : function()
				{
					var element = CKEDITOR.document.getById( id ).getChild( 1 );
					element.focus();
				},
				clickFn : clickFn
			};

			function updateState()
			{
				var state = this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;
				this.setState( editor.readOnly && !this.readOnly ? CKEDITOR.TRISTATE_DISABLED : state );
				this.setValue( '' );
			}

			editor.on( 'mode', updateState, this );
			// If this combo is sensitive to readOnly state, update it accordingly.
			!this.readOnly && editor.on( 'readOnly', updateState, this);

			var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element )
				{
					ev = new CKEDITOR.dom.event( ev );

					var keystroke = ev.getKeystroke();
					switch ( keystroke )
					{
						case 13 :	// ENTER
						case 32 :	// SPACE
						case 40 :	// ARROW-DOWN
							// Show panel
							CKEDITOR.tools.callFunction( clickFn, element );
							break;
						default :
							// Delegate the default behavior to toolbar button key handling.
							instance.onkey( instance,  keystroke );
					}

					// Avoid subsequent focus grab on editor document.
					ev.preventDefault();
				});

			var focusFn = CKEDITOR.tools.addFunction( function() { instance.onfocus && instance.onfocus(); } );

			// For clean up
			instance.keyDownFn = keyDownFn;

			output.push(
				'<span class="cke_rcombo" role="presentation">',
				'<span id=', id );

			if ( this.className )
				output.push( ' class="', this.className, ' cke_off"');

			output.push(
				' role="presentation">',
					'<span id="' + id+ '_label" class=cke_label>', this.label, '</span>',
					'<a hidefocus=true title="', this.title, '" tabindex="-1"',
						env.gecko && env.version >= 10900 && !env.hc ? '' : ' href="javascript:void(\'' + this.label + '\')"',
						' role="button" aria-labelledby="', id , '_label" aria-describedby="', id, '_text" aria-haspopup="true"' );

			// Some browsers don't cancel key events in the keydown but in the
			// keypress.
			// TODO: Check if really needed for Gecko+Mac.
			if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
			{
				output.push(
					' onkeypress="return false;"' );
			}

			// With Firefox, we need to force it to redraw, otherwise it
			// will remain in the focus state.
			if ( CKEDITOR.env.gecko )
			{
				output.push(
					' onblur="this.style.cssText = this.style.cssText;"' );
			}

			output.push(
					' onkeydown="CKEDITOR.tools.callFunction( ', keyDownFn, ', event, this );"' +
					' onfocus="return CKEDITOR.tools.callFunction(', focusFn, ', event);" ' +
					( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) +		// #188
						'="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' +
						'<span>' +
							'<span id="' + id + '_text" class="cke_text cke_inline_label">' + this.label + '</span>' +
						'</span>' +
						'<span class=cke_openbutton><span class=cke_icon>' + ( CKEDITOR.env.hc ? '&#9660;' : CKEDITOR.env.air ?  '&nbsp;' : '' ) + '</span></span>' +	// BLACK DOWN-POINTING TRIANGLE
					'</a>' +
				'</span>' +
				'</span>' );

			if ( this.onRender )
				this.onRender();

			return instance;
		}
551827
function getNestedEditableIn( editablesContainer, remainingEditables ) {
		if ( remainingEditables == null )
			remainingEditables = findNestedEditables( editablesContainer );

		var editable;

		while ( ( editable = remainingEditables.shift() ) ) {
			if ( isIterableEditable( editable ) )
				return { element: editable, remaining: remainingEditables };
		}

		return null;
	}
668054
function(e) {
    if (this.props.parameters.autoIndent) {
      var state = this.state.state;
      var selection = state.getSelection();

      var indentationLevel = indentationLevelAt(state.getCurrentContent(),
                                                selection.getFocusKey(),
                                                selection.getFocusOffset());

      if (state.getCurrentContent().getBlockForKey(selection.getFocusKey())
               .getText().substr(selection.getFocusOffset())
               .trim().startsWith("}")) {
        indentationLevel--;
      }

      state = EditorState.push(
          state,
          this._insertLineAfter(state.getCurrentContent(),
            selection,
            this._generateIndentation(indentationLevel)),
          "inserted-text"
          );

      this.setState({state: state});

      return "handled";
    } else {
      return "not-handled";
    }
  }
361355
def get_editorTab(self, editor):
        

        for i in range(self.Script_Editor_tabWidget.count()):
            if not self.get_widget(i) == editor:
                continue

            LOGGER.debug("> Editor '{0}': Tab index '{1}'.".format(editor, i))
            return i
965387
def indexOf(self, editor):
        
        lay = self.layout()
        for i in range(lay.count()):
            if lay.itemAt(i).widget() == editor:
                return i
        return -1
61805
function emptyEditorOnDeleteEverything() {
        function isEverythingSelected(editor) {
          var caretWalker = new CaretWalker(editor.getBody());
          var rng = editor.selection.getRng();
          var startCaretPos = CaretPosition.fromRangeStart(rng);
          var endCaretPos = CaretPosition.fromRangeEnd(rng);
          var prev = caretWalker.prev(startCaretPos);
          var next = caretWalker.next(endCaretPos);

          return !editor.selection.isCollapsed() &&
            (!prev || (prev.isAtStart() && startCaretPos.isEqual(prev))) &&
            (!next || (next.isAtEnd() && startCaretPos.isEqual(next)));
        }

        // Type over case delete and insert this won't cover typeover with a IME but at least it covers the common case
        editor.on('keypress', function (e) {
          if (!isDefaultPrevented(e) && !selection.isCollapsed() && e.charCode > 31 && !VK.metaKeyPressed(e)) {
            if (isEverythingSelected(editor)) {
              e.preventDefault();
              editor.setContent(String.fromCharCode(e.charCode));
              editor.selection.select(editor.getBody(), true);
              editor.selection.collapse(false);
              editor.nodeChanged();
            }
          }
        });

        editor.on('keydown', function (e) {
          var keyCode = e.keyCode;

          if (!isDefaultPrevented(e) && (keyCode == DELETE || keyCode == BACKSPACE)) {
            if (isEverythingSelected(editor)) {
              e.preventDefault();
              editor.setContent('');
              editor.nodeChanged();
            }
          }
        });
      }