termio: add external API to set selection

This commit is contained in:
Boris Faure 2023-08-20 13:10:20 +02:00
parent 880489ced2
commit 9f96788e0a
Signed by: borisfaure
GPG Key ID: EAA9CD729F522998
2 changed files with 16 additions and 8 deletions

View File

@ -1011,11 +1011,10 @@ _lost_selection(void *data, Elm_Sel_Type selection)
}
}
/* Set the @type selection to @text.
* This does not modify the widget itself */
void
termio_set_selection_text(Termio *sd, Elm_Sel_Type type, const char *text)
_termio_set_selection_text(Termio *sd, Elm_Sel_Type type, const char *text)
{
EINA_SAFETY_ON_NULL_RETURN(sd);
@ -1037,6 +1036,15 @@ termio_set_selection_text(Termio *sd, Elm_Sel_Type type, const char *text)
sd->sel_str = eina_stringshare_add(text);
}
void
termio_set_selection_text(Evas_Object *obj, Elm_Sel_Type type, const char *text)
{
Termio *sd = termio_get_from_obj(obj);
EINA_SAFETY_ON_NULL_RETURN(sd);
_termio_set_selection_text(sd, type, text);
}
Eina_Bool
termio_take_selection(Evas_Object *obj, Elm_Sel_Type type)
@ -1051,7 +1059,7 @@ termio_take_selection(Evas_Object *obj, Elm_Sel_Type type)
if (s)
{
if ((sd->win) && (len > 0))
termio_set_selection_text(sd, type, s);
_termio_set_selection_text(sd, type, s);
eina_stringshare_del(s);
return EINA_TRUE;
}
@ -1073,7 +1081,7 @@ _cb_ctxp_link_content_copy(void *data,
if (!hl->url)
return;
termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, hl->url);
_termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, hl->url);
}
else
{
@ -1085,7 +1093,7 @@ _cb_ctxp_link_content_copy(void *data,
sd->link.x2, sd->link.y2,
&sb, EINA_FALSE);
raw_link = ty_sb_steal_buf(&sb);
termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, raw_link);
_termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, raw_link);
free(raw_link);
}
@ -1102,7 +1110,7 @@ _cb_ctxp_link_copy(void *data,
Termio *sd = evas_object_smart_data_get(term);
EINA_SAFETY_ON_NULL_RETURN(sd);
EINA_SAFETY_ON_NULL_RETURN(sd->link.string);
termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, sd->link.string);
_termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, sd->link.string);
sd->ctxpopup = NULL;
evas_object_del(obj);
@ -1260,7 +1268,7 @@ _cb_ctxp_color_copy(void *data,
txt = _color_to_txt(sd);
if (!txt) return;
termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, txt);
_termio_set_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, txt);
eina_stringshare_del(txt);
sd->ctxpopup = NULL;

View File

@ -17,7 +17,7 @@ Termio *termio_get_from_obj(Evas_Object *obj);
void termio_win_set(Evas_Object *obj, Evas_Object *win);
void termio_theme_set(Evas_Object *obj, Evas_Object *theme);
Eina_Bool termio_selection_exists(const Evas_Object *obj);
void termio_set_selection_text(Termio *sd, Elm_Sel_Type type, const char *text);
void termio_set_selection_text(Evas_Object *obj, Elm_Sel_Type type, const char *text);
void termio_scroll_top_backlog(Evas_Object *obj);
void termio_scroll_delta(Evas_Object *obj, int delta, int by_page);
void termio_scroll_set(Evas_Object *obj, int scroll);