... | ... |
@@ -168,6 +168,41 @@ redata_highlighter_getcolorindex(redata_t *redata, int line, int nthbyte) |
168 | 168 |
return(-1); |
169 | 169 |
} |
170 | 170 |
|
171 |
+static void |
|
172 |
+redata_highlighter_util_applytheme(int *template3,hcolor_t *color,int invert) |
|
173 |
+{ |
|
174 |
+ unsigned char c[3]; |
|
175 |
+ if(template3==NULL || color==NULL || template3[0]<0 || template3[0]>2 || template3[1]<0 || template3[1]>2 || template3[2]<0 || template3[2]>2) |
|
176 |
+ return; /* sanity check error */ |
|
177 |
+ if(invert==0) { |
|
178 |
+ ((unsigned char *)color->rgba)[0]=((unsigned char *)color->origrgba)[template3[0]]; |
|
179 |
+ ((unsigned char *)color->rgba)[1]=((unsigned char *)color->origrgba)[template3[1]]; |
|
180 |
+ ((unsigned char *)color->rgba)[2]=((unsigned char *)color->origrgba)[template3[2]]; |
|
181 |
+ } else { |
|
182 |
+ ((unsigned char *)color->rgba)[0]=255-((unsigned char *)color->origrgba)[template3[0]]; |
|
183 |
+ ((unsigned char *)color->rgba)[1]=255-((unsigned char *)color->origrgba)[template3[1]]; |
|
184 |
+ ((unsigned char *)color->rgba)[2]=255-((unsigned char *)color->origrgba)[template3[2]]; |
|
185 |
+ } |
|
186 |
+ return; |
|
187 |
+} |
|
188 |
+ |
|
189 |
+int |
|
190 |
+redata_highlighter_settheme(redata_t *redata, int ntheme, int invert) |
|
191 |
+{ |
|
192 |
+ int permutations[6][3]={{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,1,0},{2,0,1}}; |
|
193 |
+ int *permutationtemplate; |
|
194 |
+ hcolor_t *colors; |
|
195 |
+ int ncolors,i; |
|
196 |
+ ntheme=(ntheme<0)?0:ntheme; |
|
197 |
+ ntheme%=6; |
|
198 |
+ permutationtemplate=permutations[ntheme]; |
|
199 |
+ if((colors=redata_highlighter_getcolors(redata, &ncolors))==NULL) |
|
200 |
+ return(-1); |
|
201 |
+ for(i=0;i<ncolors;i++) |
|
202 |
+ redata_highlighter_util_applytheme(permutationtemplate,colors+i,invert); |
|
203 |
+ return; |
|
204 |
+} |
|
205 |
+ |
|
171 | 206 |
static int |
172 | 207 |
redata_highlighter_add_or_unadd(redata_t *redata, redata_plugin_t *slot, undo_t *undo, int is_unadd) |
173 | 208 |
{ |
... | ... |
@@ -248,6 +283,8 @@ hl_initcolors(int *ncolors, /* int color, char *colordef, */ ...) |
248 | 283 |
colordef=va_arg(paramlist,char *); |
249 | 284 |
maxcolor=(maxcolor<color)?color:maxcolor; |
250 | 285 |
if(round==1) { |
286 |
+ strncpy(hcolors[color].origrgba,colordef,sizeof(hcolors[color].origrgba)); |
|
287 |
+ hcolors[color].origrgba[sizeof(hcolors[color].origrgba)-1]='\0'; |
|
251 | 288 |
strncpy(hcolors[color].rgba,colordef,sizeof(hcolors[color].rgba)); |
252 | 289 |
hcolors[color].rgba[sizeof(hcolors[color].rgba)-1]='\0'; |
253 | 290 |
} |
... | ... |
@@ -788,3 +825,4 @@ hl_addtolinecolor(int *opaque, highlighter_t *hl,linecolor_t *linecolor,int poso |
788 | 825 |
return(linecolor); |
789 | 826 |
} |
790 | 827 |
|
828 |
+ |
... | ... |
@@ -26,7 +26,8 @@ typedef struct line_t { |
26 | 26 |
} hline_t; |
27 | 27 |
|
28 | 28 |
typedef struct hcolor_t { |
29 |
- char rgba[9]; |
|
29 |
+ char origrgba[5]; |
|
30 |
+ char rgba[5]; |
|
30 | 31 |
} hcolor_t; |
31 | 32 |
|
32 | 33 |
typedef struct highlighter_t { |
... | ... |
@@ -55,4 +56,6 @@ int redata_highlighter_unregister(redata_t *redata, redata_plugin_t *slot,char * |
55 | 56 |
hcolor_t *redata_highlighter_getcolors(redata_t *redata, int *ncolors); |
56 | 57 |
linecolor_t *redata_highlighter_getline(redata_t *redata, int line, int *nlinecolors); |
57 | 58 |
int redata_highlighter_getcolorindex(redata_t *redata, int line, int nthbyte); |
59 |
+int redata_highlighter_settheme(redata_t *redata, int ntheme, int invert); |
|
60 |
+ |
|
58 | 61 |
|
... | ... |
@@ -547,8 +547,8 @@ redata_unsaved_loadquestion(redata_t *redata, redata_plugin_t *slot,char *filena |
547 | 547 |
static char mybody[]={"The file you're trying to load has some unsaved data from a previous session. I can recover the data. What do you want to do?"}; |
548 | 548 |
static char *myopts[]={"Recover unsaved data (safest option)","Don't use old unsaved data, delete old unsaved data (if you're sure what you're doing)"}; |
549 | 549 |
static char mytitleshort[]={"Unsaved data found"}; |
550 |
- static char mybodyshort[]={"Should try to recover the data?"}; |
|
551 |
- static char *myoptsshort[]={"Recover","Ignore it"}; |
|
550 |
+ static char mybodyshort[]={"Try to recover the data?"}; |
|
551 |
+ static char *myoptsshort[]={"Recover data","Ignore data","Quit"}; |
|
552 | 552 |
question_t *q; |
553 | 553 |
if(redata==NULL || slot==NULL || filename==NULL) |
554 | 554 |
return(-1); /* sanity check failed */ |
... | ... |
@@ -563,7 +563,7 @@ redata_unsaved_loadquestion(redata_t *redata, redata_plugin_t *slot,char *filena |
563 | 563 |
q->bodyshort=mybodyshort; |
564 | 564 |
q->opts=myopts; |
565 | 565 |
q->optsshort=myoptsshort; |
566 |
- q->nopts=2; |
|
566 |
+ q->nopts=3; |
|
567 | 567 |
q->defaultoption=1; |
568 | 568 |
q->selectedoption=-1; |
569 | 569 |
return(0); |
... | ... |
@@ -582,6 +582,11 @@ redata_unsaved_postload(redata_t *redata, redata_plugin_t *slot,char *filename) |
582 | 582 |
return(redata_unsaved_truncload(redata, slot, filename)); |
583 | 583 |
else if(selectedoption==0) /* recover */ |
584 | 584 |
return(redata_unsaved_loadappend(redata, slot, filename)); |
585 |
+#if 0 |
|
586 |
+#error TODO: implement be able to force-quit from plugin */ |
|
587 |
+ else if(selectedoption==2) /* quit */ |
|
588 |
+ return(-1); |
|
589 |
+#endif |
|
585 | 590 |
return(-1); |
586 | 591 |
} |
587 | 592 |
|