From b6c149f3d68c6ae179b0f7917b0e7b85bf29aae5 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 13 Aug 2012 14:52:59 +0100 Subject: Convert to use selection_copy_to_clipboard() and font style passed via gui_add_to_clipboard. Note: untested. --- beos/window.cpp | 47 ++++++++++------------------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) (limited to 'beos') diff --git a/beos/window.cpp b/beos/window.cpp index 572aa86dd..845c8ac8f 100644 --- a/beos/window.cpp +++ b/beos/window.cpp @@ -1672,6 +1672,15 @@ bool gui_add_to_clipboard(const char *text, size_t length, bool space, const plot_font_style_t *fstyle) { BString s; + BFont font; + text_run *run = new text_run; + + nsbeos_style_to_font(font, &fstyle); + run->offset = current_selection.Length(); + run->font = font; + run->color = nsbeos_rgb_colour(fstyle->foreground); + current_selection_textruns.AddItem(run); + s.SetTo(text, length); current_selection << s; if (space) @@ -1712,45 +1721,9 @@ bool gui_commit_clipboard(void) return true; } -static bool copy_handler(const char *text, size_t length, struct box *box, - void *handle, const char *whitespace_text, - size_t whitespace_length) -{ - bool space = false; - //XXX: handle box->style to StyledEdit / RTF ? - /* add any whitespace which precedes the text from this box */ - if (whitespace_text) { - if (!gui_add_to_clipboard(whitespace_text, - whitespace_length, false, - plot_style_font)) { - return false; - } - } - - // add a text_run for StyledEdit-like text formating - if (box && box->style) { - text_run *run = new text_run; - BFont font; - plot_font_style_t style; - font_plot_style_from_css(box->style, &style); - nsbeos_style_to_font(font, &style); - run->offset = current_selection.Length(); - run->font = font; - run->color = nsbeos_rgb_colour(style->foreground); - current_selection_textruns.AddItem(run); - space = box->space != 0; - } - - /* add the text from this box */ - if (!gui_add_to_clipboard(text, length, space, plot_style_font)) - return false; - - return true; -} - bool gui_copy_to_clipboard(struct selection *s) { - if (s->defined && selection_traverse(s, copy_handler, NULL)) + if (s->defined && selection_copy_to_clipboard(s)) gui_commit_clipboard(); return true; } -- cgit v1.2.3