Page MenuHomePhabricator

New filter APIs for copy and paste text hooking
Open, NormalPublic

Description

I would like to suggest new filter APIs for copy and paste text hooking
like elm_cnp_selection_set_filter_add() / elm_cnp_selection_get_filter_add() (not fixed the APIs name)
This functions will support to modify the text before copying and pasting.

For example, If we want to add and remove application's tag before copying and pasting
we can use the above APIs.

please tell me your opinions.
Thanks.

herb created this task.Apr 10 2017, 3:06 AM
herb added a project: Restricted Project.Apr 10 2017, 9:13 PM
herb edited projects, added efl; removed Restricted Project.
herb added subscribers: cedric, jpeg, Hermet.
herb raised the priority of this task from Wishlist to Incoming Queue.Apr 11 2017, 8:50 PM

in general i think the idea sounds good. shouldn't it be done on an object by object basis? ie set a filer on an entry? a global func imho would be tricky to make work well.

thiepha added a subscriber: thiepha.Jun 6 2017, 8:09 PM

I think this should be done on objects which provide the default copy/paste function (like the entry). I guess that because entry implements the copy/paste by itself, in some cases, the copied/pasted data is not as the one which applications want. With the idea from this task, applications can change data format as they want. If so, implement this function in entry is better than in elm_cnp.
@herb Is there any specific reasons that we should do it in elm_cnp as you did in patch D4928?

herb added a comment.Jun 6 2017, 8:49 PM

I think we support other input texts which are not entry since application which does not use entry can not apply own tags.

@thiepha - agreed. entry handles its own cnp and would normally just paste exactly what it gets into the entry (after conversion e.g. if textblock markup then no conversion at all, or if plain text, then convert etc.).

i totally see there is a need for someone being able to step in the middle and filter/convert that text before being actually inserted or before being "copied out" to another destination.

this smells like a good use of a filter api ON each object. the right thing to do with eo api would be to have a filter class, inherit from it with the default implementation in the class filter methods being "do nothing to the text and just pass it on" and now you can inherit and override that method with your own filter method if you want. legacy api would require a wrapper that uses the "override this method for this class for just this one object" feature in eo -> efl_object_override()

anywhere else code would use the elm cnp api directly to do its own copy & paste handling and thus can filter there already on its own and needs no hooks/ability to insert in the text "pipeline".

herb added a comment.Jun 13 2017, 1:24 AM

@raster
In summary, create a filter class to apply custom tags and then make entry inherit the filter class. (default behavior is just copying and pasting original text)
support legacy filter API of entry using it.
If someone want to apply custom tag to the entry,
just override filter functions using efl_object_override(entry, ...) in application side. right :)?

If right, I am going to make filter class like efl/src/lib/efl/interfaces/efl_markup_filter.eo
and make elm_entry inherit the filter class.
support legacy elm_entry_markup_filter APIs using it.

please let me know your opinion :)

jpeg added a comment.Jun 13 2017, 1:31 AM

I'd rather find a solution that does not require efl_override. Right now efl_override is not well suited to this kind of task.

@herb - yes. but you want to add a legacy func to "set the text in.out filter func" that internal calls efl_object_override. efl_object_override is for the new eo c api.

@jpeg - in c++.java etc. you'd inherit the entry class and override the method. that'd be following the design patterns common there for this. in js/lua/c we can use the override trivially... :)

jpeg added a comment.EditedJun 13 2017, 3:00 AM
In T5378#88825, @raster wrote:

@jpeg - in c++.java etc. you'd inherit the entry class and override the method. that'd be following the design patterns common there for this. in js/lua/c we can use the override trivially... :)

Yes my comment was because right now efl_obbject_override does not have a great flexible implementation. But I believe that could be changed (technically very easy to do), it's just a matter of policy.
The alternative is to use delegate objects... on which still have to override a function. The advantage of using a delegate object is that it can be applied to part apis too.

herb added a comment.Jun 14 2017, 11:03 PM

I made the Efl Markup Filter interface and uploaded the patch about it.
please check and review :)
you can see the code using the following url
https://phab.enlightenment.org/D4966

herb added a comment.Jun 20 2017, 7:00 PM

I updated the following patch
https://phab.enlightenment.org/D4966
please check and review again :)

jpeg added a comment.Jun 20 2017, 10:19 PM

Please just write like this: D4966. Phabricator will do the URL for you :)

jpeg triaged this task as Normal priority.
jpeg added a project: Restricted Project.
jpeg reassigned this task from raster to herb.Sep 19 2017, 2:58 AM
jpeg added a subscriber: raster.
jpeg reassigned this task from herb to thiepha.Jan 18 2018, 2:17 AM

What was this for? Is it needed?
I see no update on D4966

zmike edited projects, added Restricted Project; removed efl.Jun 11 2018, 6:58 AM
zmike edited projects, added efl: rendering; removed Restricted Project.Jun 11 2018, 9:06 AM

@herb

Could you tell us what the current status of this task is?