Returns the line number from the y_pos.

        :param y_pos: Y pos in the editor
        :return: Line number (0 based), -1 if out of range
490712
def line_nbr_from_position(self, y_pos):
        
        editor = self._editor
        height = editor.fontMetrics().height()
        for top, line, block in editor.visible_blocks:
            if top <= y_pos <= top + height:
                return line
        return -1
458026
function posToLine(pos, src) {
    if (pos >= src.length) {
        pos = src.length - 1;
    }

    if (pos <= -1) {
        return -1;
    }

    let line = 1;
    for (let i = 0; i < pos; i++) {
        if (src[i] === "\n") {
            ++line;
        }
    }

    return line;
}
165337
def cursor(self, pos):
        
        index = self.splitAt(pos)

        if len(self._rects[index[0]])-1 < index[1]:
            if index[1] == 0:
                # empty row
                x = 0
            else:
                rect = self._rects[index[0]][index[1]-1]
                x = rect.x() + rect.width()
        else:
            rect = self._rects[index[0]][index[1]]
            x = rect.x()

        y0 = index[0]*(ROW_HEIGHT + ROW_SPACE) + ROW_SPACE
        y1 = y0 + ROW_HEIGHT

        # adjust for scrolled viewport
        x -= self.horizontalScrollBar().value()
        y0 -= self.verticalScrollBar().value()
        y1 -= self.verticalScrollBar().value()
        
        return QtCore.QLine(x,y0,x,y1)
1325290
function(pos) {
      if (posLess(pos, change.from)) return pos;
      if (!posLess(change.to, pos)) return end;

      var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
      if (pos.line == change.to.line) ch += end.ch - change.to.ch;
      return Pos(line, ch);
    }
1040139
public int column(int pos) {
        int currPrePos = 0;
        while ((pos + currPrePos) > 0 && !sequence.peek(pos, currPrePos).startsWith("\n")) {
            currPrePos--;
        }
        return (currPrePos * -1);
    }
602044
def get_monitor_pos(monitor):
    
    xpos_value = ctypes.c_int(0)
    xpos = ctypes.pointer(xpos_value)
    ypos_value = ctypes.c_int(0)
    ypos = ctypes.pointer(ypos_value)
    _glfw.glfwGetMonitorPos(monitor, xpos, ypos)
    return xpos_value.value, ypos_value.value
145549
def cursor_pos(self):
        """"""
        if len(self) == 0:
            return self.left + self.default_text.get_width()

        papy = self._surface.get_width()
        if papy > self.w:
            shift = papy - self.width
        else:
            shift = 0

        return self.left + self.font.size(self.shawn_text[:self.cursor])[0] - shift
1084547
def get_record_pos(self, record):
        
        if self.is_stopword_record(record):
            return '~' + record.pos
        else:
            return record.pos
579760
def linecol_to_pos(text, line, col):
    
    nth_newline_offset = 0
    for i in range(line - 1):
        new_offset = text.find("\n", nth_newline_offset)
        if new_offset < 0:
            raise ValueError("Text does not have {0} lines."
                             .format(line))
        nth_newline_offset = new_offset + 1
    offset = nth_newline_offset + col
    if offset > len(text):
        raise ValueError("Line {0} column {1} is not within the text"
                         .format(line, col))
    return offset
815019
def _get_pos(self):
        
        if self._h >= len(self._options):
            return 0
        else:
            return self._start_line / (len(self._options) - self._h)
1215495
public int getLineNumber(Location start) {
        LineNumberTableAttr table = mOldLineNumberTable;
        if (table == null) {
            table = mLineNumberTable;
        }

        if (table == null || start.getLocation() < 0) {
            return -1;
        } else {
            return table.getLineNumber(start);
        }
    }
1245155
public int getLine(int pos) {
	for (int i = 0; i < lines.length; i++) {
	    if (pos <= lines[i].intValue()) return i + 1;
	}
	return lines.length;
    }
325353
def _getLPA( self ):
        "  "
        return str( self.line ) + ":" + \
               str( self.pos ) + ":" + \
               str( self.absPosition )
931388
def get_line_number(line_map, offset):
    """"""
    for lineno, line_offset in enumerate(line_map, start=1):
        if line_offset > offset:
            return lineno
    return -1
711226
def get_start_of_line_position(self, after_whitespace=False):
        
        if after_whitespace:
            current_line = self.current_line
            return len(current_line) - len(current_line.lstrip()) - self.cursor_position_col
        else:
            return - len(self.current_line_before_cursor)
936335
def _get_y(self, kwargs):
        '''
        
        '''
        if 'y' in kwargs:
            return round(float(kwargs['y']), 6)
        elif self._element_y in kwargs:
            return round(float(kwargs[self._element_y]), 6)
        elif self._type == 3 and self._element_1my in kwargs:
            return round(1. - float(kwargs[self._element_1my]), 6)
        else:
            raise TypeError()
816042
def _readue(self, pos):
        
        oldpos = pos
        try:
            while not self[pos]:
                pos += 1
        except IndexError:
            raise ReadError("Read off end of bitstring trying to read code.")
        leadingzeros = pos - oldpos
        codenum = (1 << leadingzeros) - 1
        if leadingzeros > 0:
            if pos + leadingzeros + 1 > self.len:
                raise ReadError("Read off end of bitstring trying to read code.")
            codenum += self._readuint(leadingzeros, pos + 1)
            pos += leadingzeros + 1
        else:
            assert codenum == 0
            pos += 1
        return codenum, pos