Get line number for given range object.
186615
def get_line_number(doc, wrange):
    """"""
    lineno = 1
    wrange.Select()
    wdFirstCharacterLineNumber = constants("wdFirstCharacterLineNumber")
    wdGoToLine = constants("wdGoToLine")
    wdGoToPrevious = constants("wdGoToPrevious")
    while True:
        curline = doc.Selection.Information(wdFirstCharacterLineNumber)
        doc.Selection.GoTo(wdGoToLine, wdGoToPrevious, Count=1, Name="")
        lineno += 1
        prevline = doc.Selection.Information(wdFirstCharacterLineNumber)
        if prevline == curline:
            break
    return lineno
765701
def goto_line(self, line_number):
        """"""
        if line_number:
            line_number = int(line_number)
            try:
                self.plugin.go_to_line(line_number)
            except AttributeError:
                pass
1108467
def get_range(self):
        """"""
        (min, max) = (100000, -1)
        for cont in self.bar:
            for note in cont[2]:
                if int(note) < int(min):
                    min = note
                elif int(note) > int(max):
                    max = note
        return (min, max)
109608
def _get_line(self):
        """"""
        line = self._f.readline()
        if len(line) == 0:
            raise StopIteration
        return line
1365891
def get_line_number_next_to_cursor_with_string_within(self, s):
        
        line_number, _ = self.get_cursor_position()
        text_buffer = self.text_view.get_buffer()
        line_iter = text_buffer.get_iter_at_line(line_number)

        # find closest before line with string within
        before_line_number = None
        while line_iter.backward_line():
            if s in self.get_text_of_line(line_iter):
                before_line_number = line_iter.get_line()
                break

        # find closest after line with string within
        after_line_number = None
        while line_iter.forward_line():
            if s in self.get_text_of_line(line_iter):
                after_line_number = line_iter.get_line()
                break

        # take closest one to current position
        if after_line_number is not None and before_line_number is None:
            return after_line_number, after_line_number - line_number
        elif before_line_number is not None and after_line_number is None:
            return before_line_number, line_number - before_line_number
        elif after_line_number is not None and before_line_number is not None:
            after_distance = after_line_number - line_number
            before_distance = line_number - before_line_number
            if after_distance < before_distance:
                return after_line_number, after_distance
            else:
                return before_line_number, before_distance
        else:
            return None, None
1091678
function line_number(index, source) {
  // To speed things up, remember the index until which we counted,
  // then next time just begin counting from there.  This way we
  // only count each line once.
  var i = start_index;
  var count = 0;
  while (i < index) {
    if (source[i] === "\n") {
      count++;
    }
    i++;
  }

  start_linenr = count + start_linenr;
  start_index = index;

  return start_linenr;
}
674907
def get_line_at(self, coordinates):
        """"""
        cursor = self.cursorForPosition(coordinates)
        cursor.select(QTextCursor.BlockUnderCursor)
        return to_text_string(cursor.selectedText()).replace(u'\u2029', '')
345945
def get_line_numbers(self, buffer):
        
        # Get absolute cursor positions from the text object.
        from_, to = self.operator_range(buffer.document)
        from_ += buffer.cursor_position
        to += buffer.cursor_position

        # Take the start of the lines.
        from_, _ = buffer.document.translate_index_to_position(from_)
        to, _ = buffer.document.translate_index_to_position(to)

        return from_, to
1353992
def getline(self):
        """"""
        if self.index >= len(self.lines):
            line = ''
        else:
            line = self.lines[self.index]
            self.index += 1
        return line
808448
private int getLineNumber(int pc) {
		LineNumberTable lnt = getMethod().getLineNumberTable();
		if (lnt == null) {
			return pc;
		}

		LineNumber[] lns = lnt.getLineNumberTable();
		if (lns == null) {
			return pc;
		}

		if (pc > lns[lns.length - 1].getStartPC()) {
			return lns[lns.length - 1].getLineNumber();
		}

		int lo = 0;
		int hi = lns.length - 2;
		int mid = 0;
		while (lo <= hi) {
			mid = (lo + hi) >>> 1;
			if (pc < lns[mid].getStartPC()) {
				hi = mid - 1;
			} else if (pc >= lns[mid + 1].getStartPC()) {
				lo = mid + 1;
			} else {
				break;
			}
		}

		return lns[mid].getLineNumber();
	}
136726
def detect_range(line = None):
    '''
    
    '''
    if (not line.startswith("[") and
        line.find("[") != -1 and
        line.find(":") != -1 and
        line.find("]") != -1 and
        line.index("[") < line.index(":") < line.index("]")):
        return True
    else:
        return False
1048852
function getNumberingRanges(str) {
    return findUnescapedTokens(str || '', numberingToken)
    .reduce((out, range) => {
        // skip ranges that actually belongs to output placeholder or tabstops
        if (!/[#{]/.test(str[range[0] + 1] || '')) {
            const lastRange = out[out.length - 1];
            if (lastRange && lastRange[0] + lastRange[1] === range[0]) {
                lastRange[1] += range[1];
            } else {
                out.push(range);
            }
        }

        return out;
    }, []);
}
148283
def line_range(self):
        
        num_lines = len(self.text().split('\n'))
        end_line = self._start_line + num_lines - 1
        return (self._start_line, end_line)
1026125
public int getLine()
  {
    if (_line >= 0)
      return _line;

    Attribute attr = getAttribute("LineNumberTable");

    if (attr == null) {
      _line = 0;
      return _line;
    }

    _line = 0;
    return _line;
  }
1194757
def _get_struct_linestylearray(self, shape_number):
        """"""
        obj = _make_object("LineStyleArray")
        obj.LineStyleCount = count = unpack_ui8(self._src)
        if count == 0xFF:
            obj.LineStyleCountExtended = count = unpack_ui16(self._src)
        obj.LineStyles = line_styles = []

        for _ in range(count):
            if shape_number <= 3:
                record = _make_object("LineStyle")
                record.Width = unpack_ui16(self._src)
                if shape_number <= 2:
                    record.Color = self._get_struct_rgb()
                else:
                    record.Color = self._get_struct_rgba()
            else:
                record = _make_object("LineStyle2")
                record.Width = unpack_ui16(self._src)

                bc = BitConsumer(self._src)
                record.StartCapStyle = bc.u_get(2)
                record.JoinStyle = bc.u_get(2)
                record.HasFillFlag = bc.u_get(1)
                record.NoHScaleFlag = bc.u_get(1)
                record.NoVScaleFlag = bc.u_get(1)
                record.PixelHintingFlag = bc.u_get(1)

                bc.u_get(5)  # reserved
                record.NoClose = bc.u_get(1)
                record.EndCapStyle = bc.u_get(2)

                if record.JoinStyle == 2:
                    record.MiterLimitFactor = unpack_ui16(self._src)
                if record.HasFillFlag == 0:
                    record.Color = self._get_struct_rgba()
                else:
                    record.Color = self._get_struct_fillstyle(shape_number)

            line_styles.append(record)

        return obj
907740
def _check_range(range_):
        """"""
        try:
            if not isinstance(range_, list):
                range_ = list(range_)
            min_, max_ = range_
        except (ValueError, TypeError):
            raise TypeError("each range in ising_linear_ranges should be a list of length 2.")
        if not isinstance(min_, Number) or not isinstance(max_, Number) or min_ > max_:
            raise ValueError(("each range in ising_linear_ranges should be a 2-tuple "
                              "(min, max) where min <= max"))
        return range_
1183112
function findLineInRange(sdpLines, startLine, endLine, prefix, substr) {
            var realEndLine = endLine !== -1 ? endLine : sdpLines.length;
            for (var i = startLine; i < realEndLine; ++i) {
                if (sdpLines[i].indexOf(prefix) === 0) {
                    if (!substr ||
                        sdpLines[i].toLowerCase().indexOf(substr.toLowerCase()) !== -1) {
                        return i;
                    }
                }
            }
            return null;
        }