696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
|
if(i&~0xFFFF) return;
if(replay_size<i) replay_list=realloc(replay_list,replay_size=i);
if(!replay_list) fatal("Allocation failed");
replay_count=i;
if(i) memcpy(replay_list,sqlite3_column_blob(st,1),i);
}
static void copy_text_to_plain(unsigned char*out,int maxlen,const unsigned char*in) {
int at=0;
if(!in) {
*out=0;
return;
}
while(*in && at<maxlen) switch(*in) {
case 10: if(at && out[at-1]!=32) out[at++]=32; in++; break;
case 14: case 30: in=strchrnul(in,'\\'); if(*in) in++; break;
case 31: in++; if(*in) out[at++]=*in++; break;
case 32 ... 255: out[at++]=*in++; break;
default: in++;
}
out[at]=0;
}
static int list_levels(void) {
static Sint8 mo=-1;
static Uint8 columns=0;
static int scroll=0;
sqlite3_stmt*st;
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
if(i&~0xFFFF) return;
if(replay_size<i) replay_list=realloc(replay_list,replay_size=i);
if(!replay_list) fatal("Allocation failed");
replay_count=i;
if(i) memcpy(replay_list,sqlite3_column_blob(st,1),i);
}
static int copy_text_to_plain(unsigned char*out,int maxlen,const unsigned char*in) {
int at=0;
if(!in) {
*out=0;
return 0;
}
while(*in && at<maxlen) switch(*in) {
case 10: if(at && out[at-1]!=32) out[at++]=32; in++; break;
case 14: case 30: in=strchrnul(in,'\\'); if(*in) in++; break;
case 31: in++; if(*in) out[at++]=*in++; break;
case 32 ... 255: out[at++]=*in++; break;
default: in++;
}
out[at]=0;
return at;
}
static inline void levels_column(int x,int y,int n,int bg,sqlite3_stmt*st,char*buf) {
const DisplayColumn*dc=ll_disp+n;
Uint8 co=dc->color;
int w=dc->width;
int nc=dc->data+(dc->flag&4?0:8);
int t=sqlite3_column_type(st,nc);
int a=0;
int i;
const char*p;
sqlite3_int64 v;
if(t==SQLITE_NULL) return;
if(dc->flag&1) w=255;
if(t==SQLITE_BLOB || t==SQLITE_TEXT) {
blob:
i=copy_text_to_plain(buf,w,sqlite3_column_text(st,nc));
if(dc->form[0]=='R') a=w-i;
if(dc->flag&2) co=0xFF;
} else {
// This implementation does not check that the format is necessarily valid.
// You should not rely on the use of any undocumented format.
v=sqlite3_column_int64(st,nc);
if(dc->flag&2) {
//TODO: colours
}
switch(dc->form[0]) {
case 'L': case 'R':
if(dc->form[1]) {
if(v<0 || v>w) v=w;
memset(buf,dc->form[1],v);
buf[v]=0;
if(dc->form[0]=='R') a=w-v;
} else {
goto blob;
}
break;
case 'd':
snprintf(buf,w+1,"%*lld",w,(long long)(dc->form[1] && v<0?-v:v));
if(dc->form[1]=='-') *buf=v<0?'-':' ';
if(dc->form[1]=='+') *buf=v<0?'-':'+';
break;
case 'o':
snprintf(buf,w+1,dc->form[1]?"%0*llo":"%*llo",w,(unsigned long long)v);
break;
case 'u':
snprintf(buf,w+1,dc->form[1]?"%0*llu":"%*llu",w,(unsigned long long)v);
break;
case 'x':
snprintf(buf,w+1,dc->form[1]?"%0*llx":"%*llx",w,(unsigned long long)v);
break;
case 'X':
snprintf(buf,w+1,dc->form[1]?"%0*llX":"%*llX",w,(unsigned long long)v);
break;
default: *buf=0;
}
}
draw_text(a*8+x,y,buf,bg,co);
}
static int list_levels(void) {
static Sint8 mo=-1;
static Uint8 columns=0;
static int scroll=0;
sqlite3_stmt*st;
|
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
|
draw_text(2*8,y,"\x10",b=0xF8,0xFE);
} else {
draw_text(2*8,y,"\xB3",b=0x02,0xF8);
}
snprintf(buf,6,"%5u",mo&2?sqlite3_column_int(st,0):i);
draw_text(3*8,y,buf,b,sqlite3_column_int(st,6)?0xFA:0xFC);
draw_text(8*8,y,"\xB3",b,b^0xFA);
snprintf(buf,6,"%2u %2u",sqlite3_column_int(st,3),sqlite3_column_int(st,4));
draw_text(9*8,y,buf,b,0xFF);
draw_text(11*8,y,"\xB3",b,b^0xFA);
draw_text(14*8,y,"\xB3",b,b^0xFA);
copy_text_to_plain(buf,255,sqlite3_column_text(st,5));
draw_text(15*8,y,buf,b,0xFF);
}
} else {
scrmax=(level_nindex+columns-1)/columns;
draw_text(0,16,mo&2?"(ID)":"(Ord)",0xF7,0xF1);
if(rescroll) {
if(sel<scroll*columns) scroll=sel/columns;
if(sel>(scroll+screen->h/8-3)*columns) scroll=(sel+3-screen->h/8)/columns;
|
>
>
>
>
>
>
>
>
|
|
|
|
|
|
>
|
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
|
draw_text(2*8,y,"\x10",b=0xF8,0xFE);
} else {
draw_text(2*8,y,"\xB3",b=0x02,0xF8);
}
snprintf(buf,6,"%5u",mo&2?sqlite3_column_int(st,0):i);
draw_text(3*8,y,buf,b,sqlite3_column_int(st,6)?0xFA:0xFC);
draw_text(8*8,y,"\xB3",b,b^0xFA);
if(ll_ndisp) {
x=9*8;
for(i=0;i<ll_ndisp && x<screen->w;i++) {
levels_column(x,y,i,b,st,buf);
x+=ll_disp[i].width*8+8;
if(x<screen->w && !(ll_disp[i].flag&1)) draw_text(x-8,y,"\xB3",b,b^0xFA);
}
} else {
snprintf(buf,6,"%2u %2u",sqlite3_column_int(st,3),sqlite3_column_int(st,4));
draw_text(9*8,y,buf,b,0xFF);
draw_text(11*8,y,"\xB3",b,b^0xFA);
draw_text(14*8,y,"\xB3",b,b^0xFA);
copy_text_to_plain(buf,255,sqlite3_column_text(st,5));
draw_text(15*8,y,buf,b,0xFF);
}
}
} else {
scrmax=(level_nindex+columns-1)/columns;
draw_text(0,16,mo&2?"(ID)":"(Ord)",0xF7,0xF1);
if(rescroll) {
if(sel<scroll*columns) scroll=sel/columns;
if(sel>(scroll+screen->h/8-3)*columns) scroll=(sel+3-screen->h/8)/columns;
|