termiointernals: add termio_internal_get_selection()

This commit is contained in:
Boris Faure 2019-02-10 20:09:20 +01:00
parent 851e68d157
commit 35587220c7
4 changed files with 34 additions and 11 deletions

View File

@ -903,6 +903,27 @@ termio_take_selection_text(Termio *sd, Elm_Sel_Type type, const char *text)
sd->sel_str = text; sd->sel_str = text;
} }
Eina_Bool
termio_take_selection(Evas_Object *obj, Elm_Sel_Type type)
{
Termio *sd = termio_get_from_obj(obj);
const char *s = NULL;
size_t len = 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
s = termio_internal_get_selection(sd, &len);
if (s)
{
if ((sd->win) && (len > 0))
termio_take_selection_text(sd, type, s);
eina_stringshare_del(s);
return EINA_TRUE;
}
return EINA_FALSE;
}
static void static void
_cb_ctxp_link_content_copy(void *data, _cb_ctxp_link_content_copy(void *data,
Evas_Object *obj, Evas_Object *obj,

View File

@ -315,10 +315,9 @@ _sel_fill_in_codepoints_array(Termio *sd)
sd->pty->selection.codepoints = buf.codepoints; sd->pty->selection.codepoints = buf.codepoints;
} }
Eina_Bool const char *
termio_take_selection(Evas_Object *obj, Elm_Sel_Type type) termio_internal_get_selection(Termio *sd, size_t *lenp)
{ {
Termio *sd = termio_get_from_obj(obj);
int start_x = 0, start_y = 0, end_x = 0, end_y = 0; int start_x = 0, start_y = 0, end_x = 0, end_y = 0;
const char *s = NULL; const char *s = NULL;
size_t len = 0; size_t len = 0;
@ -382,14 +381,8 @@ termio_take_selection(Evas_Object *obj, Elm_Sel_Type type)
} }
end: end:
if (s) *lenp = len;
{ return s;
if ((sd->win) && (len > 0))
termio_take_selection_text(sd, type, s);
eina_stringshare_del(s);
return EINA_TRUE;
}
return EINA_FALSE;
} }
static void static void

View File

@ -136,4 +136,6 @@ void
termio_internal_render(Termio *sd, termio_internal_render(Termio *sd,
Evas_Coord ox, Evas_Coord oy, Evas_Coord ox, Evas_Coord oy,
int *preedit_xp, int *preedit_yp); int *preedit_xp, int *preedit_yp);
const char *
termio_internal_get_selection(Termio *sd, size_t *lenp);
#endif #endif

View File

@ -199,6 +199,13 @@ termio_block_activate(Evas_Object *obj EINA_UNUSED,
{ {
} }
Eina_Bool
termio_take_selection(Evas_Object *obj EINA_UNUSED,
Elm_Sel_Type type EINA_UNUSED)
{
return EINA_FALSE;
}
#ifndef TYTEST #ifndef TYTEST
void void
termio_set_cursor_shape(Evas_Object *obj EINA_UNUSED, termio_set_cursor_shape(Evas_Object *obj EINA_UNUSED,