mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-08 20:12:01 +03:00
Pass font plot style out to front end clipboard append function.
This commit is contained in:
parent
68947c377e
commit
d106091d6e
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/box.h"
|
||||
@ -245,7 +246,8 @@ bool gui_empty_clipboard(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
/* This might crash or at least not work if gui_empty_clipboard isn't called first,
|
||||
and gui_commit_clipboard after.
|
||||
@ -418,7 +420,8 @@ void ami_drag_selection(struct selection *s)
|
||||
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_add_to_clipboard(text,strlen(text),false,plot_style_font))
|
||||
return false;
|
||||
if(!gui_commit_clipboard()) return false;
|
||||
|
||||
return true;
|
||||
|
@ -643,7 +643,8 @@ bool gui_empty_clipboard(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space)
|
||||
bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
LOG(("(%s): %s (%d)\n", (space)?"space":"", (char*)text_utf8, (int)length_utf8));
|
||||
char * oldptr = tmp_clipboard;
|
||||
|
@ -1668,7 +1668,8 @@ bool gui_empty_clipboard(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
BString s;
|
||||
s.SetTo(text, length);
|
||||
@ -1720,7 +1721,8 @@ static bool copy_handler(const char *text, size_t length, struct box *box,
|
||||
/* add any whitespace which precedes the text from this box */
|
||||
if (whitespace_text) {
|
||||
if (!gui_add_to_clipboard(whitespace_text,
|
||||
whitespace_length, false)) {
|
||||
whitespace_length, false,
|
||||
plot_style_font)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1740,7 +1742,7 @@ static bool copy_handler(const char *text, size_t length, struct box *box,
|
||||
}
|
||||
|
||||
/* add the text from this box */
|
||||
if (!gui_add_to_clipboard(text, length, space))
|
||||
if (!gui_add_to_clipboard(text, length, space, plot_style_font))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -56,7 +56,8 @@ bool gui_empty_clipboard(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
if (nil == cocoa_clipboard_string) return false;
|
||||
|
||||
|
@ -129,7 +129,8 @@ void gui_clear_selection(struct gui_window *g);
|
||||
|
||||
void gui_paste_from_clipboard(struct gui_window *g, int x, int y);
|
||||
bool gui_empty_clipboard(void);
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space);
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle);
|
||||
bool gui_commit_clipboard(void);
|
||||
bool gui_copy_to_clipboard(struct selection *s);
|
||||
|
||||
|
@ -753,7 +753,7 @@ static bool selection_copy_handler(const char *text, size_t length,
|
||||
/* add any whitespace which precedes the text from this box */
|
||||
if (whitespace_text != NULL && whitespace_length > 0) {
|
||||
if (!gui_add_to_clipboard(whitespace_text,
|
||||
whitespace_length, false)) {
|
||||
whitespace_length, false, &style)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -772,7 +772,7 @@ static bool selection_copy_handler(const char *text, size_t length,
|
||||
}
|
||||
|
||||
/* add the text from this box */
|
||||
if (!gui_add_to_clipboard(text, length, add_space))
|
||||
if (!gui_add_to_clipboard(text, length, add_space, &style))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -69,7 +69,8 @@ bool gui_empty_clipboard(void)
|
||||
* \return true iff successful
|
||||
*/
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
size_t new_length = gui_clipboard.length + length + (space ? 1 : 0) + 1;
|
||||
|
||||
|
@ -31,12 +31,13 @@ static GString *current_selection = NULL;
|
||||
static GtkClipboard *clipboard;
|
||||
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
/* add the text from this box */
|
||||
current_selection = g_string_append_len (current_selection,
|
||||
current_selection = g_string_append_len(current_selection,
|
||||
text, length);
|
||||
if (space) g_string_append (current_selection, " ");
|
||||
if (space) g_string_append(current_selection, " ");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,8 @@ gui_empty_clipboard(void)
|
||||
}
|
||||
|
||||
bool
|
||||
gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -554,8 +554,8 @@ static bool textinput_textarea_cut(struct content *c,
|
||||
struct box *next = box->next;
|
||||
|
||||
if (box->type == BOX_BR) {
|
||||
if (clipboard &&
|
||||
!gui_add_to_clipboard("\n", 1, false)) {
|
||||
if (clipboard && !gui_add_to_clipboard("\n", 1, false,
|
||||
plot_style_font)) {
|
||||
gui_commit_clipboard();
|
||||
return false;
|
||||
}
|
||||
@ -565,7 +565,7 @@ static bool textinput_textarea_cut(struct content *c,
|
||||
if (clipboard &&
|
||||
!gui_add_to_clipboard(box->text + start_idx,
|
||||
box->length - start_idx,
|
||||
SPACE_LEN(box))) {
|
||||
SPACE_LEN(box), plot_style_font)) {
|
||||
gui_commit_clipboard();
|
||||
return false;
|
||||
}
|
||||
@ -593,7 +593,8 @@ static bool textinput_textarea_cut(struct content *c,
|
||||
/* and the last box */
|
||||
if (box) {
|
||||
if (clipboard && !gui_add_to_clipboard(box->text + start_idx,
|
||||
end_idx - start_idx, end_idx > box->length)) {
|
||||
end_idx - start_idx, end_idx > box->length,
|
||||
plot_style_font)) {
|
||||
success = false;
|
||||
} else {
|
||||
if (del) {
|
||||
|
@ -229,10 +229,12 @@ void gui_clear_selection(struct gui_window *g)
|
||||
* \param text text to be added
|
||||
* \param length length of text in bytes
|
||||
* \param space indicates whether a trailing space should be appended also
|
||||
* \param fstyle font plot style for text
|
||||
* \return true iff successful
|
||||
*/
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
size_t new_length = clip_length + length + (space ? 1 : 0);
|
||||
|
||||
|
@ -1766,7 +1766,8 @@ bool gui_empty_clipboard(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
||||
bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
const plot_font_style_t *fstyle)
|
||||
{
|
||||
HANDLE hnew;
|
||||
char *new, *original;
|
||||
|
Loading…
Reference in New Issue
Block a user