Thursday, 2 August 2012

Re: Amiga and BeOS front end selection/clipboard handling

On 02/08/2012 18:28, Chris Young wrote:
> On Thu, 02 Aug 2012 17:01:39 +0200, François Revol wrote:
>
>> From memory this is used to walk the text to collect the font and
>> colors
>> to create the text_runs to include in the clipboard:
>> http://revolf.free.fr/beos/shots/shot_beos_netsurf_styled_clipboard.png
>
> I didn't know selection_traverse could get colours and text styles,
> how does that work?

See netsurf/beos/window.cpp:copy_handler:

on each copy_handler() call it just checks for box->style,
converts it using font_plot_style_from_css() into something I can
extract the BFont object and color info.
There I create a text_run object which just holds both info and char
count, and add it to the list.
It'd probably need some optimisation to merge identical runs but it works.

The list or text_runs is then committed as a separate object along with
the plain/text item in the clipboard, which applications like StyledEdit
can use.

The API could probably be made cleaner by hiding the box struct though.

François.

No comments:

Post a Comment