Gtk.TextView.prototype.get_iter_at_location

function get_iter_at_location(x:Number, y:Number):void {
    // Gjs wrapper for gtk_text_view_get_iter_at_location()
}

Retrieves the iterator at buffer coordinates x and y. Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with Gtk.window_to_buffer_coords.

x

x position, in buffer coordinates

y

y position, in buffer coordinates