How to use the text-buffer.Point function in text-buffer

To help you get started, we’ve selected a few text-buffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github manaflair / mylittledom / sources / core / misc / TextFormatter.js View on Github external
moveRight(position, { copy = false } = {}) {

        if (this.lineInfo.length === 0)
            return new Point();

        position = Point.fromObject(position, copy);

        let tokenLocator = this.tokenLocatorForPosition(position);

        if (!tokenLocator)
            return null;

        let [ row, tokenIndex, line, token ] = tokenLocator;

        // if we're inside the token, or on its left edge
        if (position.column < token.outputOffset + token.outputLength) {

            // if we're a static token, we can just move inside the token
            if (token.type === STATIC_TOKEN) {
                position.column += 1;
github atom / atom / src / text-mate-language-mode.js View on Github external
row === lastRow ||
          _.isEqual(this.stackForRow(row), previousStack)
        ) {
          filledRegion = true;
          endRow = row;
          break;
        }
        row++;
      }

      this.validateRow(endRow);
      if (!filledRegion) this.invalidateRow(endRow + 1);

      this.emitter.emit(
        'did-change-highlighting',
        Range(Point(startRow, 0), Point(endRow + 1, 0))
      );
    }

    if (this.firstInvalidRow() != null) {
      this.tokenizeInBackground();
    } else {
      this.markTokenizationComplete();
    }
  }
github atom / atom / src / text-mate-language-mode.js View on Github external
getFoldableRanges(tabLength) {
    const result = [];
    let row = 0;
    const lineCount = this.buffer.getLineCount();
    while (row < lineCount) {
      const endRow = this.endRowForFoldAtRow(row, tabLength);
      if (endRow != null) {
        result.push(Range(Point(row, Infinity), Point(endRow, Infinity)));
      }
      row++;
    }
    return result;
  }
github atom / atom / src / text-mate-language-mode.js View on Github external
suggestedIndentForEditedBufferRow(bufferRow, tabLength) {
    const line = this.buffer.lineForRow(bufferRow);
    const currentIndentLevel = this.indentLevelForLine(line, tabLength);
    if (currentIndentLevel === 0) return;

    const scopeDescriptor = this.scopeDescriptorForPosition(
      new Point(bufferRow, 0)
    );
    const decreaseIndentRegex = this.decreaseIndentRegexForScopeDescriptor(
      scopeDescriptor
    );
    if (!decreaseIndentRegex) return;

    if (!decreaseIndentRegex.testSync(line)) return;

    const precedingRow = this.buffer.previousNonBlankRow(bufferRow);
    if (precedingRow == null) return;

    const precedingLine = this.buffer.lineForRow(precedingRow);
    let desiredIndentLevel = this.indentLevelForLine(precedingLine, tabLength);

    const increaseIndentRegex = this.increaseIndentRegexForScopeDescriptor(
      scopeDescriptor
github atom / atom / src / cursor.js View on Github external
getCurrentWordBufferRange(options = {}) {
    const position = this.getBufferPosition();
    const ranges = this.editor.buffer.findAllInRangeSync(
      options.wordRegex || this.wordRegExp(options),
      new Range(new Point(position.row, 0), new Point(position.row, Infinity))
    );
    const range = ranges.find(
      range =>
        range.end.column >= position.column &&
        range.start.column <= position.column
    );
    return range ? Range.fromObject(range) : new Range(position, position);
  }
github atom / atom / src / text-mate-language-mode.js View on Github external
this.openScopeIds = [];
    this.closeScopeIds = [];
    while (true) {
      if (this.tagIndex === this.currentLineTags.length) {
        if (this.isAtTagBoundary()) {
          break;
        } else if (!this.moveToNextLine()) {
          return false;
        }
      } else {
        const tag = this.currentLineTags[this.tagIndex];
        if (tag >= 0) {
          if (this.isAtTagBoundary()) {
            break;
          } else {
            this.position = Point(
              this.position.row,
              Math.min(
                this.currentLineLength,
                this.position.column + this.currentLineTags[this.tagIndex]
              )
            );
          }
        } else {
          const scopeId = fromFirstMateScopeId(tag);
          if ((tag & 1) === 0) {
            if (this.openScopeIds.length > 0) {
              break;
            } else {
              this.closeScopeIds.push(scopeId);
            }
          } else {

text-buffer

A container for large mutable strings with annotated regions

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages