... | ... |
@@ -179,9 +179,6 @@ redata_highlighter_add_or_unadd(redata_t *redata, redata_plugin_t *slot, undo_t |
179 | 179 |
if(redata==NULL || slot==NULL || hl==NULL || undo==NULL || stack==NULL || slot->active==0) |
180 | 180 |
return(-1); /* sanity check failed */ |
181 | 181 |
if(hl->usedlines==0) { |
182 |
-#if 0 |
|
183 |
-fprintf(stderr,"INVALIDATING USEDLINELINES==0 (nothing to do)\n"); |
|
184 |
-#endif |
|
185 | 182 |
return(0); /* nothing to do */ |
186 | 183 |
} |
187 | 184 |
/* get the first pos of the operation */ |
... | ... |
@@ -203,9 +200,6 @@ fprintf(stderr,"INVALIDATING USEDLINELINES==0 (nothing to do)\n"); |
203 | 200 |
/* invalidate from this line on */ |
204 | 201 |
nline=(nline<0)?0:nline; |
205 | 202 |
hl_invalidatefrom(redata,hl,nline); |
206 |
-#if 0 |
|
207 |
-fprintf(stderr,"INVALIDATING LINE %i\n",nline); |
|
208 |
-#endif |
|
209 | 203 |
return(0); |
210 | 204 |
} |
211 | 205 |
|
... | ... |
@@ -372,9 +366,6 @@ hl_doline(redata_t *redata, highlighter_t *hl, int nline) |
372 | 366 |
} |
373 | 367 |
/* make sure we have previous lines highlighted */ |
374 | 368 |
for(i=hl->usedlines;i<nline;i++) { |
375 |
-#if 0 |
|
376 |
-fprintf(stderr,"Recursing from %i to %i\n",nline,i); |
|
377 |
-#endif |
|
378 | 369 |
if(hl_doline(redata,hl,i)==-1) |
379 | 370 |
return(-1); /* error highlighting line */ |
380 | 371 |
} |
... | ... |
@@ -395,77 +386,24 @@ fprintf(stderr,"Recursing from %i to %i\n",nline,i); |
395 | 386 |
opaque=0; |
396 | 387 |
linecolor=hl_addtolinecolor(&opaque,hl,NULL,color_normal,0); |
397 | 388 |
posoffset=0; |
398 |
-#if 0 |
|
399 |
-fprintf(stderr,"Doing line %i pos:%li\n",nline,line->pos); |
|
400 |
-#endif |
|
401 | 389 |
prev_char='\0'; |
402 | 390 |
prev_char_mask=0xff; |
403 | 391 |
hl->usedkeywordbuf=0; |
404 | 392 |
hl->useddirectivebuf=0; |
405 | 393 |
mlcprevmode=mode_whatever; |
406 | 394 |
do { |
407 |
- if(redata_line_rawinfo(redata,realpos+posoffset,&pos,&ptr,&len,NULL)==-1) { |
|
408 |
-#if 0 |
|
409 |
-fprintf(stderr,"nline:%i ERROR: couldn't get lineinfo for realpos:%li posoffset:%i realpos+posoffset:%li redataused:%li\n", |
|
410 |
-nline,realpos,posoffset,realpos+posoffset,redata_getused(redata)); |
|
411 |
-#endif |
|
395 |
+ if(redata_line_rawinfo(redata,realpos+posoffset,&pos,&ptr,&len,NULL)==-1) |
|
412 | 396 |
return(-1); /* couldn't get line data */ |
413 |
- } |
|
414 | 397 |
has_nl=((len>0 && ptr[len-1]=='\n')?1:0); |
415 | 398 |
has_next=(len==0)?1:(ptr[len-1]=='\n')?0:1; |
416 | 399 |
/* special case: line with only a newline */ |
417 | 400 |
if(posoffset==0 && has_nl==1 && len==1) { |
418 | 401 |
/* delete the existing linecolor and break */ |
419 | 402 |
line->len=0; |
420 |
-#if 0 |
|
421 |
-fprintf(stderr,"nline:%i detected blank line, exiting\n",nline); |
|
422 |
-#endif |
|
423 | 403 |
break; |
424 | 404 |
} |
425 | 405 |
/* iterate */ |
426 |
-#if 0 |
|
427 |
-#define HDEBUGLINE 775 |
|
428 |
-if(nline==HDEBUGLINE || nline==(HDEBUGLINE+1)) { |
|
429 |
-fprintf(stderr,"Line %i chunk at posoffset:%i (realpos:%li)\n",nline, posoffset,realpos); |
|
430 |
-fprintf(stderr,"NEW RAWINFO, nline:%i len:%i has_nl:%i has_next:%i mode:%s(%i) mlcprevmode:%s(%i)\n",nline,len,has_nl,has_next, |
|
431 |
-mode==mode_whatever?"whatever": |
|
432 |
-mode==mode_in_multilinecomment?"mlc": |
|
433 |
-mode==mode_in_linecomment?"comment": |
|
434 |
-mode==mode_in_directive?"directive": |
|
435 |
-mode==mode_in_string?"string": |
|
436 |
-mode==mode_in_directivestring?"directivestring":"unknown", |
|
437 |
-mode, |
|
438 |
-mlcprevmode==mode_whatever?"whatever": |
|
439 |
-mlcprevmode==mode_in_multilinecomment?"mlc": |
|
440 |
-mlcprevmode==mode_in_linecomment?"comment": |
|
441 |
-mlcprevmode==mode_in_directive?"directive": |
|
442 |
-mlcprevmode==mode_in_string?"string": |
|
443 |
-mlcprevmode==mode_in_directivestring?"directivestring":"unknown", |
|
444 |
-mlcprevmode |
|
445 |
-); |
|
446 |
-} |
|
447 |
-#endif |
|
448 | 406 |
for(i=0;i<(len-has_nl);prev_char=(ptr[i]&prev_char_mask),prev_char_mask=0xff,i++) { |
449 |
-#if 0 |
|
450 |
-if(nline==HDEBUGLINE || nline==(HDEBUGLINE+1)) { |
|
451 |
-fprintf(stderr,"ptr[%i]='%c' prev_char='%s%c' mode=%s(%i) mlcprevmode=%s(%i)\n",i,ptr[i],(prev_char=='\0')?"\\":"",(prev_char=='\0')?'0':prev_char, |
|
452 |
-mode==mode_whatever?"whatever": |
|
453 |
-mode==mode_in_multilinecomment?"mlc": |
|
454 |
-mode==mode_in_linecomment?"comment": |
|
455 |
-mode==mode_in_directive?"directive": |
|
456 |
-mode==mode_in_string?"string": |
|
457 |
-mode==mode_in_directivestring?"directivestring":"unknown", |
|
458 |
-mode, |
|
459 |
-mlcprevmode==mode_whatever?"whatever": |
|
460 |
-mlcprevmode==mode_in_multilinecomment?"mlc": |
|
461 |
-mlcprevmode==mode_in_linecomment?"comment": |
|
462 |
-mlcprevmode==mode_in_directive?"directive": |
|
463 |
-mlcprevmode==mode_in_string?"string": |
|
464 |
-mlcprevmode==mode_in_directivestring?"directivestring":"unknown", |
|
465 |
-mlcprevmode |
|
466 |
-); |
|
467 |
-} |
|
468 |
-#endif |
|
469 | 407 |
/* special case: keyword ends in a change of mode */ |
470 | 408 |
if(mode!=mode_whatever && hl->usedkeywordbuf>0) { |
471 | 409 |
if(hl_searchlist(keywords,nkeywords,hl->keywordbuf,hl->usedkeywordbuf,NULL)==0) { |
... | ... |
@@ -793,31 +731,6 @@ hl_addtolinecolor(int *opaque, highlighter_t *hl,linecolor_t *linecolor,int poso |
793 | 731 |
hline_t *line; |
794 | 732 |
if(opaque==NULL || *opaque<0 || hl==NULL || (posoff!=0 && linecolor==NULL) || color<0 || posoff<0) |
795 | 733 |
return(NULL); /* sanity check failed */ |
796 |
-#if 0 |
|
797 |
-#define DEBUGLINE 775 |
|
798 |
-if(hl->usedlines==DEBUGLINE || hl->usedlines==(DEBUGLINE+1)) { |
|
799 |
-int i,k; |
|
800 |
-int l=hl->lines[hl->usedlines].len; |
|
801 |
-linecolor_t *lc=(linecolor_t *) (hl->buf+hl->lines[hl->usedlines].off); |
|
802 |
-fprintf(stderr,"addtolinecolor pre.: nline:%i *opaque:%i posoff:%i color:%i current:\"",hl->usedlines,*opaque,posoff,color); |
|
803 |
-for(k=0;k<l;k+=sizeof(linecolor_t),lc++) { |
|
804 |
- for(i=0;i<lc->len;i++) |
|
805 |
- fprintf(stderr,"%x",lc->color); |
|
806 |
-} |
|
807 |
-hl->keywordbuf[hl->usedkeywordbuf]='\0'; |
|
808 |
-hl->directivebuf[hl->useddirectivebuf]='\0'; |
|
809 |
-fprintf(stderr,"\" (%i%s%s%s,%i%s%s%s)\n", |
|
810 |
-hl->usedkeywordbuf, |
|
811 |
-(hl->usedkeywordbuf==0)?"":" \"", |
|
812 |
-(hl->usedkeywordbuf==0)?"":hl->keywordbuf, |
|
813 |
-(hl->usedkeywordbuf==0)?"":"\"", |
|
814 |
-hl->useddirectivebuf, |
|
815 |
-(hl->useddirectivebuf==0)?"":" \"", |
|
816 |
-(hl->useddirectivebuf==0)?"":hl->directivebuf, |
|
817 |
-(hl->useddirectivebuf==0)?"":"\"" |
|
818 |
-); |
|
819 |
-} |
|
820 |
-#endif |
|
821 | 734 |
/* make sure there is a space for a linecolor_t in buf */ |
822 | 735 |
if((hl->usedbuf+sizeof(linecolor_t))>=hl->sizebuf) { |
823 | 736 |
char *newbuf; |
... | ... |
@@ -838,19 +751,6 @@ hl->useddirectivebuf, |
838 | 751 |
linecolor->len=1; |
839 | 752 |
linecolor->color=color; |
840 | 753 |
*opaque=1; |
841 |
-#if 0 |
|
842 |
-if(hl->usedlines==DEBUGLINE || hl->usedlines==(DEBUGLINE+1)) { |
|
843 |
-int i,k; |
|
844 |
-int l=hl->lines[hl->usedlines].len; |
|
845 |
-linecolor_t *lc=(linecolor_t *) (hl->buf+hl->lines[hl->usedlines].off); |
|
846 |
-fprintf(stderr,"addtolinecolor post: nline:%i *opaque:%i posoff:%i color:%i \"",hl->usedlines,*opaque,posoff,color); |
|
847 |
-for(k=0;k<l;k+=sizeof(linecolor_t),lc++) { |
|
848 |
- for(i=0;i<lc->len;i++) |
|
849 |
- fprintf(stderr,"%x",lc->color); |
|
850 |
-} |
|
851 |
-fprintf(stderr,"\"\n"); |
|
852 |
-} |
|
853 |
-#endif |
|
854 | 754 |
return(linecolor); |
855 | 755 |
} |
856 | 756 |
/* if posoff was already done, truncate */ |
... | ... |
@@ -877,19 +777,6 @@ fprintf(stderr,"\"\n"); |
877 | 777 |
int added=(posoff-*opaque)+1; |
878 | 778 |
linecolor[-1].len+=added; |
879 | 779 |
*opaque+=added; |
880 |
-#if 0 |
|
881 |
-if(hl->usedlines==DEBUGLINE || hl->usedlines==(DEBUGLINE+1)) { |
|
882 |
-int i,k; |
|
883 |
-int l=hl->lines[hl->usedlines].len; |
|
884 |
-linecolor_t *lc=(linecolor_t *) (hl->buf+hl->lines[hl->usedlines].off); |
|
885 |
-fprintf(stderr,"addtolinecolor post: nline:%i *opaque:%i posoff:%i color:%i \"",hl->usedlines,*opaque,posoff,color); |
|
886 |
-for(k=0;k<l;k+=sizeof(linecolor_t),lc++) { |
|
887 |
- for(i=0;i<lc->len;i++) |
|
888 |
- fprintf(stderr,"%x",lc->color); |
|
889 |
-} |
|
890 |
-fprintf(stderr,"\"\n"); |
|
891 |
-} |
|
892 |
-#endif |
|
893 | 780 |
return(linecolor-1); |
894 | 781 |
} |
895 | 782 |
/* add new linecolor */ |
... | ... |
@@ -898,19 +785,6 @@ fprintf(stderr,"\"\n"); |
898 | 785 |
*opaque+=1; |
899 | 786 |
line->len+=sizeof(linecolor_t); |
900 | 787 |
hl->usedbuf+=sizeof(linecolor_t); |
901 |
-#if 0 |
|
902 |
-if(hl->usedlines==DEBUGLINE || hl->usedlines==(DEBUGLINE+1)) { |
|
903 |
-int i,k; |
|
904 |
-int l=hl->lines[hl->usedlines].len; |
|
905 |
-linecolor_t *lc=(linecolor_t *) (hl->buf+hl->lines[hl->usedlines].off); |
|
906 |
-fprintf(stderr,"addtolinecolor post: nline:%i *opaque:%i posoff:%i color:%i \"",hl->usedlines,*opaque,posoff,color); |
|
907 |
-for(k=0;k<l;k+=sizeof(linecolor_t),lc++) { |
|
908 |
- for(i=0;i<lc->len;i++) |
|
909 |
- fprintf(stderr,"%x",lc->color); |
|
910 |
-} |
|
911 |
-fprintf(stderr,"\"\n"); |
|
912 |
-} |
|
913 |
-#endif |
|
914 | 788 |
return(linecolor); |
915 | 789 |
} |
916 | 790 |
|
... | ... |
@@ -16,35 +16,6 @@ |
16 | 16 |
#include <time.h> |
17 | 17 |
|
18 | 18 |
#include "re_data.h" |
19 |
-#if 0 |
|
20 |
-#define INITIALCHUNK 20 |
|
21 |
-#define MAXDUMP 25 |
|
22 |
-static void |
|
23 |
-redata_debug_chunkdump(redata_t *redata, char *title) |
|
24 |
-{ |
|
25 |
- int m,k; |
|
26 |
- char c; |
|
27 |
- title=(title==NULL)?"":title; |
|
28 |
- fprintf(stderr,"%s:CHUNKDUMP (sizechunks:%i)\n",title,redata->sizechunks); |
|
29 |
- for(m=INITIALCHUNK;m<redata->sizechunks && m<MAXDUMP;m++) { |
|
30 |
- fprintf(stderr,"%s:chunk[%i] len:%-5i data:\"",title,m,redata->chunks[m]->useddata); |
|
31 |
- for(k=0;k<redata->chunks[m]->useddata;k++) { |
|
32 |
- c=redata->chunks[m]->data[k]; |
|
33 |
- if(c=='\n' || c=='\0') |
|
34 |
- fprintf(stderr,"\\%c",(c=='\n')?'n':'0'); |
|
35 |
- else if(c<' ' || c>'~' || c=='\\') |
|
36 |
- fprintf(stderr,"\\x%02X",((unsigned char *)redata->chunks[m]->data)[k]); |
|
37 |
- else |
|
38 |
- fprintf(stderr,"%c",c); |
|
39 |
- } |
|
40 |
- fprintf(stderr,"\"\n"); |
|
41 |
- } |
|
42 |
-} |
|
43 |
-#define CHUNKDEBUG(a) redata_debug_chunkdump a |
|
44 |
-#else |
|
45 |
-#define CHUNKDEBUG(a) |
|
46 |
-#endif |
|
47 |
- |
|
48 | 19 |
#include "re_plugin_unsaved.h" |
49 | 20 |
#include "re_plugin_highlighter.h" |
50 | 21 |
#include "re_ui.h" |
... | ... |
@@ -1019,9 +990,6 @@ re_drawcontents(re_t *re) |
1019 | 990 |
/* draw the lines */ |
1020 | 991 |
drawn_cursor=0; |
1021 | 992 |
colors=redata_highlighter_getcolors(re->data,&ncolors); |
1022 |
-#if 0 |
|
1023 |
-CHUNKDEBUG((re->data,"Pre-display")); |
|
1024 |
-#endif |
|
1025 | 993 |
for(y=re->y;y<(re->y+re->h);y+=re->ui->fontheight,row++) { |
1026 | 994 |
/* definiciton of vars for teacking linecolor usage */ |
1027 | 995 |
int curlinecolor; /* current linecolor */ |
... | ... |
@@ -1032,19 +1000,6 @@ CHUNKDEBUG((re->data,"Pre-display")); |
1032 | 1000 |
} |
1033 | 1001 |
in_error=0; |
1034 | 1002 |
linecolors=(colors==NULL)?NULL:redata_highlighter_getline(re->data,re->originline+row,&nlinecolors); |
1035 |
-#if 0 |
|
1036 |
-#define DEBUGLINE 12 |
|
1037 |
-if((re->origincol+row)==DEBUGLINE) { |
|
1038 |
-int i,k,l=nlinecolors*sizeof(linecolor_t); |
|
1039 |
-linecolor_t *lc=linecolors; |
|
1040 |
-fprintf(stderr,"linecolors for line:%i \"",re->origincol+row); |
|
1041 |
-for(k=0;k<l;k+=sizeof(linecolor_t),lc++) { |
|
1042 |
- for(i=0;i<lc->len;i++) |
|
1043 |
- fprintf(stderr,"%x",lc->color); |
|
1044 |
-} |
|
1045 |
-fprintf(stderr,"\"\n"); |
|
1046 |
-} |
|
1047 |
-#endif |
|
1048 | 1003 |
curlinecolor=0; |
1049 | 1004 |
usedlenlinecolor=0; |
1050 | 1005 |
for(tmpcol=0,pos=realstart,availcol=0;tmpcol<(re->origincol+re->maxcol) && pos<=realend;pos=newpos+len,tmpcol+=availcol) { |
... | ... |
@@ -1060,16 +1015,6 @@ fprintf(stderr,"\"\n"); |
1060 | 1015 |
used=usedcol=0; |
1061 | 1016 |
/* while the avail text is larger than the linecolor len */ |
1062 | 1017 |
while((len-has_nl-used)>=(linecolors[curlinecolor].len-usedlenlinecolor)) { |
1063 |
-#if 0 |
|
1064 |
-if((re->origincol+row)==DEBUGLINE) { |
|
1065 |
-int i,l; |
|
1066 |
-fprintf(stderr,"ui_write (full) for line:%i curlinecolor:%i color:%i at:%i str:\"",(re->origincol+row),curlinecolor,linecolors[curlinecolor].color,(tmpcol-re->origincol+usedcol)); |
|
1067 |
-l=linecolors[curlinecolor].len-usedlenlinecolor; |
|
1068 |
-for(i=0;i<l;i++) |
|
1069 |
-fprintf(stderr,"%c",ptr[used+i]); |
|
1070 |
-fprintf(stderr,"\" (used:%i)\n",used); |
|
1071 |
-} |
|
1072 |
-#endif |
|
1073 | 1018 |
reui_write(re->ui,re->x+(tmpcol-re->origincol+usedcol)*re->ui->fontwidth,y,colors[linecolors[curlinecolor].color].rgba,ptr+used,linecolors[curlinecolor].len-usedlenlinecolor); |
1074 | 1019 |
usedcol+=redata_generic_utf8len(ptr+used,linecolors[curlinecolor].len-usedlenlinecolor); |
1075 | 1020 |
used+=linecolors[curlinecolor].len-usedlenlinecolor; |
... | ... |
@@ -1078,27 +1023,11 @@ fprintf(stderr,"\" (used:%i)\n",used); |
1078 | 1023 |
} |
1079 | 1024 |
/* for the last bytes of avail text, after writing them we save how many bytes we have processed of that linecolor to be able to continue later */ |
1080 | 1025 |
if((len-has_nl-used)>0 && (linecolors[curlinecolor].len-usedlenlinecolor)>(len-has_nl-used)) { |
1081 |
-#if 0 |
|
1082 |
-if((re->origincol+row)==DEBUGLINE) { |
|
1083 |
-int i,l; |
|
1084 |
-fprintf(stderr,"ui_write (last) for line:%i curlinecolor:%i color:%i at:%i str:\"",(re->origincol+row),curlinecolor,linecolors[curlinecolor].color,(tmpcol-re->origincol+usedcol)); |
|
1085 |
-l=(len-has_nl-used); |
|
1086 |
-for(i=0;i<l;i++) |
|
1087 |
-fprintf(stderr,"%c",ptr[used+i]); |
|
1088 |
-fprintf(stderr,"\" (used:%i)\n",used); |
|
1089 |
-} |
|
1090 |
-#endif |
|
1091 | 1026 |
reui_write(re->ui,re->x+(tmpcol-re->origincol+usedcol)*re->ui->fontwidth,y,colors[linecolors[curlinecolor].color].rgba,ptr+used,(len-has_nl-used)); |
1092 | 1027 |
usedcol+=redata_generic_utf8len(ptr+used,(len-has_nl-used)); |
1093 | 1028 |
usedlenlinecolor+=(len-has_nl-used); |
1094 | 1029 |
used+=(len-has_nl-used); |
1095 | 1030 |
} |
1096 |
-#if 0 |
|
1097 |
-if((re->origincol+row)==DEBUGLINE) { |
|
1098 |
-fprintf(stderr,"AFTER (used:%i)\n",used); |
|
1099 |
-} |
|
1100 |
-#endif |
|
1101 |
- |
|
1102 | 1031 |
} else { |
1103 | 1032 |
reui_write(re->ui,re->x+(tmpcol-re->origincol)*re->ui->fontwidth,y,"\x00\x00\x00\xff",ptr,len-has_nl); |
1104 | 1033 |
} |
... | ... |
@@ -1111,6 +1040,8 @@ fprintf(stderr,"AFTER (used:%i)\n",used); |
1111 | 1040 |
reui_write(re->ui,re->x+re->ui->fontwidth*(re->curcol-re->origincol),y,"\xff\xff\xff\xff",curptr,redata_generic_utf8charlen(curptr,curptrlen)); |
1112 | 1041 |
} |
1113 | 1042 |
#warning TODO: if it is one of '[','{','<','>','}',']', highlight the matching bracket/parens/anglebracket. |
1043 |
+#warning If it is ourside of the visible part of the code, put a comic baloon (with some transparency) in that dir. (up, down or right) at the correct height/position to mark the direction of where it is. |
|
1044 |
+#warning TODO: Select(control+k+b/control+k+k/...) |
|
1114 | 1045 |
} |
1115 | 1046 |
} |
1116 | 1047 |
if(row==(re->curline-re->originline) && !drawn_cursor) |