Page Menu
Home
Search
Configure Global Search
Log In
Files
F7285
GlobalClipboard2.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ian Thompson (alienit)
Nov 13 2013, 1:45 PM
Size
5 KB
Subscribers
None
GlobalClipboard2.patch
View Options
Index: source/blender/src/interface.c
===================================================================
--- source/blender/src/interface.c (revision 15636)
+++ source/blender/src/interface.c (working copy)
@@ -129,9 +129,6 @@
static uiFont UIfont[UI_ARRAY]; // no init needed
uiBut *UIbuttip;
-static char but_copypaste_str[256]="";
-static double but_copypaste_val=0.0;
-static float but_copypaste_rgb[3];
static ColorBand but_copypaste_coba;
/* ************* PROTOTYPES ***************** */
@@ -468,21 +465,38 @@
static int ui_but_copy_paste(uiBut *but, char mode)
{
void *poin;
+ char buf[UI_MAX_DRAW_STR+1];
+ double val;
+ float f[3];
if(mode=='v' && but->lock) return 0;
poin= but->poin;
+
+ if(mode=='v') {
+ /* get first line from clipboard */
+ char *p = getClipboard(0);
+ int i = 0;
+ while (*p && *p!='\r' && *p!='\n' && i<UI_MAX_DRAW_STR) {
+ buf[i++]=*p;
+ p++;
+ }
+ buf[i]= 0;
+ }
if ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI) {
if(poin==NULL);
else if(mode=='c') {
- but_copypaste_val= ui_get_but_val(but);
+ sprintf(buf, "%f", ui_get_but_val(but));
+ putClipboard(buf, 0);
}
else {
- ui_set_but_val(but, but_copypaste_val);
- uibut_do_func(but);
- ui_check_but(but);
- return 1;
+ if (sscanf(buf, " %lf ", &val) == 1) {
+ ui_set_but_val(but, val);
+ uibut_do_func(but);
+ ui_check_but(but);
+ return 1;
+ }
}
}
else if(but->type==COL) {
@@ -491,33 +505,37 @@
else if(mode=='c') {
if(but->pointype==FLO) {
float *fp= (float *) poin;
- but_copypaste_rgb[0]= fp[0];
- but_copypaste_rgb[1]= fp[1];
- but_copypaste_rgb[2]= fp[2];
+ sprintf(buf, "[%f, %f, %f]", fp[0], fp[1], fp[2]);
+ putClipboard(buf, 0);
}
else if (but->pointype==CHA) {
char *cp= (char *) poin;
- but_copypaste_rgb[0]= (float)(cp[0]/255.0);
- but_copypaste_rgb[1]= (float)(cp[1]/255.0);
- but_copypaste_rgb[2]= (float)(cp[2]/255.0);
+ f[0]= (float)(cp[0]/255.0);
+ f[1]= (float)(cp[1]/255.0);
+ f[2]= (float)(cp[2]/255.0);
+ sprintf(buf, "[%f, %f, %f]", f[0], f[1], f[2]);
+ putClipboard(buf, 0);
}
}
else {
if(but->pointype==FLO) {
float *fp= (float *) poin;
- fp[0] = but_copypaste_rgb[0];
- fp[1] = but_copypaste_rgb[1];
- fp[2] = but_copypaste_rgb[2];
- return 1;
+ if (sscanf(buf, "[%f, %f, %f]", &f[0], &f[1], &f[2]) == 3) {
+ fp[0]= f[0];
+ fp[1]= f[1];
+ fp[2]= f[2];
+ return 1;
+ }
}
else if (but->pointype==CHA) {
char *cp= (char *) poin;
- cp[0] = (char)(but_copypaste_rgb[0]*255.0);
- cp[1] = (char)(but_copypaste_rgb[1]*255.0);
- cp[2] = (char)(but_copypaste_rgb[2]*255.0);
-
- return 1;
+ if (sscanf(buf, "[%f, %f, %f]", &f[0], &f[1], &f[2]) == 3) {
+ cp[0]= (char)(f[0]*255.0);
+ cp[1]= (char)(f[1]*255.0);
+ cp[2]= (char)(f[2]*255.0);
+ return 1;
+ }
}
}
@@ -525,7 +543,9 @@
else if(but->type==TEX) {
if(poin==NULL);
else if(mode=='c') {
- strncpy(but_copypaste_str, but->poin, but->max);
+ strncpy(buf, but->poin, but->max);
+ buf[(int)but->max]= 0;
+ putClipboard(buf, 0);
}
else {
char backstr[UI_MAX_DRAW_STR];
@@ -535,7 +555,7 @@
strncpy(backstr, but->drawstr, UI_MAX_DRAW_STR);
but->func_arg2= backstr;
}
- strncpy(but->poin, but_copypaste_str, but->max);
+ strncpy(but->poin, buf, but->max);
uibut_do_func(but);
ui_check_but(but);
return 1;
@@ -544,10 +564,14 @@
else if(but->type==IDPOIN) {
if(mode=='c') {
ID *id= *but->idpoin_idpp;
- if(id) strncpy(but_copypaste_str, id->name+2, 22);
+ if(id) {
+ strncpy(buf, id->name+2, 22);
+ buf[22]= 0;
+ putClipboard(buf, 0);
+ }
}
else {
- but->idpoin_func(but_copypaste_str, but->idpoin_idpp);
+ but->idpoin_func(buf, but->idpoin_idpp);
ui_check_but(but);
return 1;
}
@@ -1766,36 +1790,47 @@
((G.qual & LR_COMMANDKEY) || (G.qual & LR_CTRLKEY)) &&
((dev==XKEY) || (dev==CKEY) || (dev==VKEY)) ) {
+ char buf[UI_MAX_DRAW_STR];
/* paste */
if (dev==VKEY) {
+
+ /* extract the first line from the clipboard */
+ char *p = getClipboard(0);
+ int i = 0;
+ while (*p && *p!='\r' && *p!='\n' && i<UI_MAX_DRAW_STR) {
+ buf[i++]=*p;
+ p++;
+ }
+ buf[i]= 0;
+
/* paste over the current selection */
if ((but->selend - but->selsta) > 0) {
len -= ui_delete_selection_edittext(but);
}
- for (y=0; y<strlen(but_copypaste_str); y++)
+ for (y=0; y<strlen(buf); y++)
{
/* add contents of buffer */
if(len < but->max) {
for(x= but->max; x>but->pos; x--)
str[x]= str[x-1];
- str[but->pos]= but_copypaste_str[y];
+ str[but->pos]= buf[y];
but->pos++;
len++;
str[len]= '\0';
}
}
- if (strlen(but_copypaste_str) > 0) dodraw= 1;
+ if (strlen(buf) > 0) dodraw= 1;
}
/* cut & copy */
else if ( (dev==XKEY) || (dev==CKEY) ) {
/* copy the contents to the copypaste buffer */
for(x= but->selsta; x <= but->selend; x++) {
if (x==but->selend)
- but_copypaste_str[x] = '\0';
+ buf[x] = '\0';
else
- but_copypaste_str[(x - but->selsta)] = str[x];
+ buf[(x - but->selsta)] = str[x];
}
/* for cut only, delete the selection afterwards */
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9c/44/f7e7cdaf6bdcf2f240057b1c1495
Event Timeline
Log In to Comment