/*
Highlight lines to start or end delimiter
178713
private void highlightLinesAfter( String content, int line )
    throws BadLocationException
  {
    int offset = _root.getElement( line ).getEndOffset();
    // Start/End delimiter not found, nothing to do
    int startDelimiter = indexOf( content, getStartDelimiter(), offset );
    int endDelimiter = indexOf( content, getEndDelimiter(), offset );
    if( startDelimiter < 0 )
    {
      startDelimiter = content.length();
    }
    if( endDelimiter < 0 )
    {
      endDelimiter = content.length();
    }
    int delimiter = Math.min( startDelimiter, endDelimiter );
    if( delimiter < offset )
    {
      return;
    }
    // Start/End delimiter found, reapply highlighting
    int endLine = _root.getElementIndex( delimiter );
    for( int i = line + 1; i < endLine; i++ )
    {
      Element branch = _root.getElement( i );
      Element leaf = getCharacterElement( branch.getStartOffset() );
      AttributeSet as = leaf.getAttributes();
      if( as.isEqual( _comment ) )
      {
        applyHighlighting( content, i );
      }
    }
  }
246258
def _highlight_lines(self, tokensource):
        
        hls = self.hl_lines

        for i, (t, value) in enumerate(tokensource):
            if t != 1:
                yield t, value
            if i + 1 in hls:  # i + 1 because Python indexes start at 0
                if self.noclasses:
                    style = ''
                    if self.style.highlight_color is not None:
                        style = (' style="background-color: %s"' %
                                 (self.style.highlight_color,))
                    yield 1, '<span%s>%s</span>' % (style, value)
                else:
                    yield 1, '<span class="hll">%s</span>' % value
            else:
                yield 1, value
1173173
function removeComplete(regex, lines, start) {
  var matches = lines[start].match(regex);
  var i = 0;
  var s = lines[start];
  matches = s.match(regex);

  while (!matches) {
    i++;
    if ((start + i) > lines.length) return;
    s += lines[start + i];
    matches = s.match(regex);
  }
  lines.splice(start, i + 1);
}
342347
def translate_logical_line(start, end, contents, indent_stack, endmarker=False):
    """"""
    # Remove leading blank lines.
    while contents[0] == '\n':
      start += 1
      contents.pop(0)
    # Remove trailing blank lines.
    while contents[-1] == '\n':
      end -= 1
      contents.pop()

    indent = len(indent_stack[-1]) if indent_stack else 0
    if endmarker:
      indent = len(contents[0])
    return start, end + 1, indent
533755
function() {
        var line, lines = this.sourceText.split(/\n/mg),
            lineLen = lines.length;

        var inCommenting, curComment, closeCommentIdx;

        for (var i = 0; i < lineLen; ++i) {
            line = lines[i].trim();
            if (line.startsWith('/**')) {
                inCommenting = true;
                curComment = new Comment();
                //Comment closed has to starts with "*/"
            } else if (line.startsWith('*/')) {
                inCommenting = false;
                closeCommentIdx = i;
            } else if (!inCommenting && (1 === i - closeCommentIdx) && /(\bfunction\b\s*?(\w+?)\s*\(([^\(\)]*)\))|((\w+)?\s*(?::|=)\s*function\s*\(([^\(\)]*)\))/.test(line)) {
                curComment.setFunc(RegExp.$2 || RegExp.$5, RegExp.$3 || RegExp.$6);
                if ('string' !== typeof curComment.getTag('ignore')) {
                    this.Comments.push(curComment);
                }
                curComment = null;
            } else if (!inCommenting && (1 === i - closeCommentIdx) && /(\w+)\s*(?::|=)(?!\s*function)/.test(line)) {
                curComment.setAttr(RegExp.$1);
                if ('string' !== typeof curComment.getTag('ignore')) {
                    this.Comments.push(curComment);
                }
                curComment = null;
            } else if (inCommenting) {
                line = line.replace(/^\*/, '').trim();
                if (/^@(\w+)([^\r\n]*)/.test(line)) {
                    curComment.addTag(RegExp.$1, RegExp.$2 || "");
                } else {
                    curComment.addDesc(line);
                }
            }

        } //for

        this._merge();
    }
516389
def highlightBlock(self, text):
        
        # Do other syntax formatting
        for expression, nth, format in self.rules:
            index = expression.indexIn(text, 0)

            while index >= 0:
                # We actually want the index of the nth match
                index = expression.pos(nth)
                length = len(expression.cap(nth))
                self.setFormat(index, length, format)
                index = expression.indexIn(text, index + length)

        self.setCurrentBlockState(0)

        # Do multi-line strings
        in_multiline = self.match_multiline(text, *self.tri_single)
        if not in_multiline:
            in_multiline = self.match_multiline(text, *self.tri_double)
692958
function translateLineEndings(text, lineEndings) {
        if (lineEndings !== LINE_ENDINGS_CRLF && lineEndings !== LINE_ENDINGS_LF) {
            lineEndings = getPlatformLineEndings();
        }

        var eolStr = (lineEndings === LINE_ENDINGS_CRLF ? "\r\n" : "\n");
        var findAnyEol = /\r\n|\r|\n/g;

        return text.replace(findAnyEol, eolStr);
    }
16023
function (line) {
		line = line || "";
		line = line.trim();

		if (line.charAt(0) === "#") {
			return true;
		}

		return false;
	}
363329
public static int getDelimiterOffset(final String line, final int start, final char delimiter) {
        int idx = line.indexOf(delimiter, start);
        if (idx >= 0) {
            idx -= start - 1;
        }
        return idx;
    }
693935
private void highlightText(int start) {
        editor.setCaretPosition(editor.getText().length());
        editor.moveCaretPosition(start);
    }
666217
def inline_diff(line, start, ending)
        if start != 0 || ending != 0
          last = ending + line.length
          str = line[0...start] + '\0' + line[start...last] + '\1' + line[last...line.length]
        end
        str || line
      end
884462
private static int skipEndOfLine(String text, int offset)
   {
      char c;
      boolean finished = false;

      while (finished == false)
      {
         c = text.charAt(offset);
         switch (c)
         {
            case ' ': // found that OBJDATA could be followed by a space the EOL
            case '\r':
            case '\n':
            {
               ++offset;
               break;
            }

            case '}':
            {
               offset = -1;
               finished = true;
               break;
            }

            default:
            {
               finished = true;
               break;
            }
         }
      }

      return (offset);
   }
379116
function Delimiters (delims, options) {
  this.options = options || {};
  this.delims = delims || [];

  this.defaults = merge({}, {
    beginning: '^',           // '^' Matches beginning of input.
    matter: '([\\s\\S]+?)',   // The "content" between the delims
    body: '([\\s\\S]+|\\s?)', // The "content" after the delims
    end: '$',                 // '$' Matches end of input.
    flags: ''                 // RegExp flags: g, m, i
  }, options);
}
174990
private void skipToEndOfLine() throws IOException {
    while (pos < limit || fillBuffer(1)) {
      char c = buffer[pos++];
      if (c == '\n') {
        lineNumber++;
        lineStart = pos;
        break;
      } else if (c == '\r') {
        break;
      }
    }
  }
1006509
def highlight_source_at_location(source: "Source", location: "SourceLocation") -> str:
    
    first_line_column_offset = source.location_offset.column - 1
    body = " " * first_line_column_offset + source.body

    line_index = location.line - 1
    line_offset = source.location_offset.line - 1
    line_num = location.line + line_offset

    column_offset = first_line_column_offset if location.line == 1 else 0
    column_num = location.column + column_offset

    lines = _re_newline.split(body)  # works a bit different from splitlines()
    len_lines = len(lines)

    def get_line(index: int) -> Optional[str]:
        return lines[index] if 0 <= index < len_lines else None

    return f"{source.name} ({line_num}:{column_num})\n" + print_prefixed_lines(
        [
            (f"{line_num - 1}: ", get_line(line_index - 1)),
            (f"{line_num}: ", get_line(line_index)),
            ("", " " * (column_num - 1) + "^"),
            (f"{line_num + 1}: ", get_line(line_index + 1)),
        ]
    )
1245236
def erase_end_of_line (self): # <ESC>[0K -or- <ESC>[K
        ''''''

        self.fill_region (self.cur_r, self.cur_c, self.cur_r, self.cols)
704427
function applyInlineFormat(space) {
        var selection, dom, rng, container, offset, startOffset, text, patternRng, pattern, delta, format;

        function splitContainer() {
          // Split text node and remove start/end from text node
          container = container.splitText(startOffset);
          container.splitText(offset - startOffset - delta);
          container.deleteData(0, pattern.start.length);
          container.deleteData(container.data.length - pattern.end.length, pattern.end.length);
        }

        selection = editor.selection;
        dom = editor.dom;

        if (!selection.isCollapsed()) {
          return;
        }

        rng = selection.getRng(true);
        container = rng.startContainer;
        offset = rng.startOffset;
        text = container.data;
        delta = space ? 1 : 0;

        if (container.nodeType != 3) {
          return;
        }

        // Find best matching end
        pattern = findEndPattern(text, offset, delta);
        if (!pattern) {
          return;
        }

        // Find start of matched pattern
        // TODO: Might need to improve this if there is nested formats
        startOffset = Math.max(0, offset - delta);
        startOffset = text.lastIndexOf(pattern.start, startOffset - pattern.end.length - 1);

        if (startOffset === -1) {
          return;
        }

        // Setup a range for the matching word
        patternRng = dom.createRng();
        patternRng.setStart(container, startOffset);
        patternRng.setEnd(container, offset - delta);
        pattern = findPattern(patternRng.toString());

        if (!pattern || !pattern.end) {
          return;
        }

        // If container match doesn't have anything between start/end then do nothing
        if (container.data.length <= pattern.start.length + pattern.end.length) {
          return;
        }

        format = editor.formatter.get(pattern.format);
        if (format && format[0].inline) {
          splitContainer();
          editor.formatter.apply(pattern.format, {}, container);
          return container;
        }
      }