Example #1
0
bool ami_easy_clipboard(char *text)
{
	if(!gui_empty_clipboard()) return false;
	if(!gui_add_to_clipboard(text,strlen(text),false)) return false;
	if(!gui_commit_clipboard()) return false;

	return true;
}
Example #2
0
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)) {
			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;
		css_color csscolor;
		if (css_computed_color(box->style, &csscolor) == CSS_COLOR_COLOR) {
			run->color = nsbeos_rgb_colour(nscss_color_to_ns(csscolor));
		}
		current_selection_textruns.AddItem(run);
		space = box->space != 0;
	}

	/* add the text from this box */
	if (!gui_add_to_clipboard(text, length, space))
		return false;

	return true;
}