API to get text for currently marked URL

This commit is contained in:
Kovid Goyal 2021-06-04 14:35:22 +05:30
parent 1b3742efbb
commit a8d1c73fec
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -2434,10 +2434,10 @@ copy_colors_from(Screen *self, Screen *other) {
}
static PyObject*
text_for_selection(Screen *self, PyObject *a UNUSED) {
text_for_selections(Screen *self, Selections *selections) {
PyObject *lines = NULL;
for (size_t i = 0; i < self->selections.count; i++) {
PyObject *temp = text_for_range(self, self->selections.items + i, true);
for (size_t i = 0; i < selections->count; i++) {
PyObject *temp = text_for_range(self, selections->items + i, true);
if (temp) {
if (lines) {
lines = extend_tuple(lines, temp);
@ -2450,6 +2450,17 @@ text_for_selection(Screen *self, PyObject *a UNUSED) {
return lines;
}
static PyObject*
text_for_selection(Screen *self, PyObject *a UNUSED) {
return text_for_selections(self, &self->selections);
}
static PyObject*
text_for_marked_url(Screen *self, PyObject *a UNUSED) {
return text_for_selections(self, &self->url_ranges);
}
bool
screen_selection_range_for_line(Screen *self, index_type y, index_type *start, index_type *end) {
if (y >= self->lines) { return false; }
@ -2991,6 +3002,7 @@ static PyMethodDef methods[] = {
MND(rescale_images, METH_NOARGS)
MND(current_key_encoding_flags, METH_NOARGS)
MND(text_for_selection, METH_NOARGS)
MND(text_for_marked_url, METH_NOARGS)
MND(is_rectangle_select, METH_NOARGS)
MND(scroll, METH_VARARGS)
MND(send_escape_code_to_child, METH_VARARGS)